Hallo,
Mein erstes Tutorial hier.
In diesem Tutorial zeige ich euch, wie ihr unter eurem leben Icon eine Batterie einfügt.
!!Wenn ihr das SQL Smartphone habt, dann fügt die dateien wie normal in der Anleitung ein und ändert eine datei nach folgendem Post ab:!!
Only 4 GG User
[hide]
fn_callCellPhone.sqf
Spoiler anzeigen
/*
Cell Phone Battery script by KampfKuerbisHD
*/
if(life_battery < 2) exitWith {hint "Deine Batterie ist leer."};
createDialog "Life_my_smartphone";
!!Das Rot markierte bitte vollständig ersetzen.!!
(Das Rot geschriebene hinzufügen/ersetzen)
Dann legen wir mal los
1. core\functions\fn_hudUpdate.sqf
Spoiler anzeigen
/*
/*
File: fn_hudUpdate.sqf
Author: Bryan "Tonic" Boardwine
Description:
Updates the HUD when it needs to.
*/
private["_ui","_food","_water","_health","_battery"];
disableSerialization;
_ui = uiNameSpace getVariable ["playerHUD",displayNull];
if(isNull _ui) then {[] call life_fnc_hudSetup;};
_food = _ui displayCtrl 23500;
_water = _ui displayCtrl 23510;
_health = _ui displayCtrl 23515;
_battery = _ui displayCtrl 23520;
//Update food
_food ctrlSetPosition [safeZoneX+safeZoneW-0.090,safeZoneY+safeZoneH-0.548];
_food ctrlSetText format["%1", life_hunger];
_food ctrlCommit 0;
//Update Water
_water ctrlSetPosition [safeZoneX+safeZoneW-0.090,safeZoneY+safeZoneH-0.502];
_water ctrlSetText format["%1", life_thirst];
_water ctrlCommit 0;
//Update Health
_health ctrlSetPosition [safeZoneX+safeZoneW-0.090,safeZoneY+safeZoneH-0.456];
_health ctrlSetText format["%1", round((1 - (damage player)) * 100)];
_health ctrlCommit 0;
//Update battery
_battery ctrlSetPosition [safeZoneX+safeZoneW-0.090,safeZoneY+safeZoneH-0.410];
_battery ctrlSetText format["%1", life_battery];
_battery ctrlCommit 0;
2. core\init_survival.sqf
Spoiler anzeigen
[] spawn {
private["_fnc_food","_fnc_water","_fnc_battery"];
_fnc_food =
{
if(life_hunger < 2) then {player setDamage 1; hint "Du bist verhungert.";}
else
{
life_hunger = life_hunger - 10;
[] call life_fnc_hudUpdate;
if(life_hunger < 2) then {player setDamage 1; hint "Du bist verhungert.";};
switch(life_hunger) do {
case 30: {hint "Du hast eine Weile nichts gegessen, du solltest schnell etwas finden!";};
case 20: {hint "Du hast angefangen zu verhungern, du musst etwas zu essen finden ansonsten wirst du sterben.";};
case 10: {hint "Du wirst nun zu Tode hungern, du wirst sehr bald sterben, falls du nichts essen solltest";player setFatigue 1;};
};
};
};
_fnc_water =
{
if(life_thirst < 2) then {player setDamage 1; hint "Du bist Ausgetrocknet.";}
else
{
life_thirst = life_thirst - 10;
[] call life_fnc_hudUpdate;
if(life_thirst < 2) then {player setDamage 1; hint "Du bist Ausgetrocknet.";};
switch(life_thirst) do
{
case 30: {hint "Du hast eine Weile nichts getrunken, du solltest bald etwas finden.";};
case 20: {hint "Du hast eine lange Zeit nichts getrunken, du solltest bald etwas zu trinken finden oder du wirst wegen Austrocknung sterben."; player setFatigue 1;};
case 10: {hint "Du leidest unter schwerer Austrocknung, du solltest schnell etwas trinken!"; player setFatigue 1;};
};
};
};
_fnc_battery =
{
if(life_battery < 2) then {hint "Your battery is empty.";}
else
{
life_battery = life_battery - 5;
[] call life_fnc_hudUpdate;
if(life_battery < 2) then {hint "Your battery is empty.";};
switch(life_battery) do
{
case 30: {hint "Message if is battery 30%. (you can remove this line)";};
case 20: {hint "Message if is battery 20%. (you can remove this line)";};
case 10: {hint "Message if is battery 10%. (you can remove this line)";};
};
};
};
while{true} do
{
sleep 600;
[] call _fnc_water;
sleep 10;
[] call _fnc_battery;
sleep 250;
[] call _fnc_food;
};
};
3. dialog\player_sys.sqf
Spoiler anzeigen
#define playersys_DIALOG 2001
#define money_text 2002
#define water_text 2003
#define food_text 2004
#define item_list 2005
#define player_list 2006
#define money_value 2007
#define rogue_text 2008
#define carry_weight 2009
#define item_edit 2010
#define battery_text 2011
4. dialog\player_inv.hpp und suche "class ButtonCell"
Spoiler anzeigen
class ButtonCell : Life_RscButtonMenu {
idc = 2014;
text = "$STR_PM_CellPhone";
onButtonClick = "[] call life_fnc_callCellPhone";
x = 0.42 + (6.25 / 19.8) + (1 / 250 / (safezoneW / safezoneH));
y = 0.8 - (1 / 25);
w = (6.25 / 40);
h = (1 / 25);
};
5. dialog\ui.hpp
Spoiler anzeigen
class playerHUD
{
idd=-1;
movingEnable=0;
fadein=0;
duration = 99999999999999999999999999999999999999999999;
fadeout=0;
name="playerHUD";
onLoad="uiNamespace setVariable ['playerHUD',_this select 0]";
objects[]={};
class controlsBackground
{
class foodHIcon : life_RscPicture
{
idc = -1;
text = "icons\food.paa";
x = safeZoneX+safeZoneW-0.115; y = safeZoneY+safeZoneH-0.54;
w = 0.03; h = 0.04;
};
class waterHIcon : life_RscPicture
{
idc = -1;
text = "icons\water.paa";
x = safeZoneX+safeZoneW-0.12; y = safeZoneY+safeZoneH-0.50;
w = 0.04; h = 0.04;
};
class healthHIcon : life_RscPicture
{
idc = -1;
text = "icons\health.paa";
x = safeZoneX+safeZoneW-0.11; y = safeZoneY+safeZoneH-0.445;
w = 0.02; h = 0.03;
};
class batteryHIcon : life_RscPicture
{
idc = -1;
text = "icons\battery.paa";
x = safeZoneX+safeZoneW-0.11; y = safeZoneY+safeZoneH-0.40;
w = 0.02; h = 0.03;
};
};
class controls
{
class foodtext
{
type=0;
idc=23500;
style=0;
x=-1;
y=-1;
w=0.3;
h=0.05;
sizeEx=0.03;
size=1;
font="PuristaSemibold";
colorBackground[]={0,0,0,0};
colorText[] = { 1 , 1 , 1 , 1 };
shadow=true;
text="";
};
class watertext
{
type=0;
idc=23510;
style=0;
x=-1;
y=-1;
w=0.3;
h=0.05;
sizeEx=0.03;
size=1;
font="PuristaSemibold";
colorBackground[]={0,0,0,0};
colorText[] = { 1 , 1 , 1 , 1 };
shadow=true;
text="";
};
class healthtext
{
type=0;
idc=23515;
style=0;
x=-1;
y=-1;
w=0.3;
h=0.05;
sizeEx=0.03;
size=1;
font="PuristaSemibold";
colorBackground[]={0,0,0,0};
colorText[] = { 1 , 1 , 1 , 1 };
shadow=true;
text="";
};
class batterytext
{
type=0;
idc=23520;
style=0;
x=-1;
y=-1;
w=0.3;
h=0.05;
sizeEx=0.03;
size=1;
font="PuristaSemibold";
colorBackground[]={0,0,0,0};
colorText[] = { 1 , 1 , 1 , 1 };
shadow=true;
text="";
};
};
};
6. core\configuration.sqf
Spoiler anzeigen
#include <macro.h>
/*
Master Life Configuration File
This file is to setup variables for the client, there are still other configuration files in the system
*****************************
****** Backend Variables *****
*****************************
*/
life_query_time = time;
life_action_delay = time;
life_trunk_vehicle = Objnull;
life_session_completed = false;
life_garage_store = false;
life_session_tries = 0;
life_net_dropped = false;
life_hit_explosive = false;
life_siren_active = false;
life_clothing_filter = 0;
life_clothing_uniform = -1;
life_redgull_effect = time;
life_is_processing = false;
life_bail_paid = false;
life_impound_inuse = false;
life_action_inUse = false;
life_spikestrip = ObjNull;
life_respawn_timer = 35;
life_has_insurance = false;
life_knockout = false;
life_interrupted = false;
//Uniform price (0),Hat Price (1),Glasses Price (2),Vest Price (3),Backpack Price (4)
life_clothing_purchase = [-1,-1,-1,-1,-1];
/*
*****************************
****** Weight Variables *****
*****************************
*/
life_maxWeight = 24; //Identifies the max carrying weight (gets adjusted throughout game when wearing different types of clothing).
life_maxWeightT = 24; //Static variable representing the players max carrying weight on start.
life_carryWeight = 0; //Represents the players current inventory weight (MUST START AT 0).
/*
*****************************
****** Food Variables *******
*****************************
*/
life_eat_Salema = 40;
life_eat_Ornate = 20;
life_eat_Mackerel = 20;
life_eat_Tuna = 100;
life_eat_Mullet = 30;
life_eat_CatShark = 60;
life_eat_Rabbit = 20;
life_eat_Apple = 5;
life_eat_turtlesoup = 62;
life_eat_donuts = 30;
/*
*****************************
****** Life Variables *******
*****************************
*/
life_net_dropped = false;
life_hit_explosive = false;
life_siren_active = false;
life_bank_fail = false;
life_use_atm = true;
life_is_arrested = false;
life_delivery_in_progress = false;
life_action_in_use = false;
life_thirst = 100;
life_hunger = 100;
life_battery = 50;
life_paycheck_period = 5;
life_cash = 0;
life_impound_car = 350;
life_impound_boat = 250;
life_impound_air = 850;
life_istazed = false;
life_my_gang = ObjNull;
[...]
7. Functions.h und finde "class Functions"
Spoiler anzeigen
class Functions
{
file = "core\functions";
class calWeightDiff {};
class fetchCfgDetails {};
class handleInv {};
class hudSetup {};
class hudUpdate {};
class fetchGear{};
class tazeSound {};
class animSync {};
class simDisable {};
class keyHandler {};
class dropItems {};
class handleDamage {};
class numberText {};
class handleItem {};
class accType {};
class onPlayerDisconnect {};
class onDeath {};
class onRespawn {};
class receiveItem {};
class giveDiff {};
class receiveMoney {};
class playerTags {};
class clearVehicleAmmo {};
class pulloutVeh {};
class nearUnits {};
class fedSuccess {};
class actionKeyHandler {};
class autoSave {};
class TBHreloader {};
class updateCash {};
class vehicleGarage {};
class holsterHandgun {};
class CarLockSound {};
class CarUnlockSound {};
class callCellPhone {};
};
Nun ist der Batterie Script fertig.
Jetzt fügen wir noch die Batterie in den Markt.
1. core\config\fn_varHandle.sqf
Adde bei "case 0":
Spoiler anzeigen
case "battery": {"life_inv_battery"};
Adde bei "case 1":
Spoiler anzeigen
case "life_inv_battery": {"battery"};
2. core\config\fn_itemWeight.sqf
Adde:
Spoiler anzeigen
case "battery": {1};
3. core\config\fn_varToStr.sqf
Adde
Spoiler anzeigen
case "life_inv_battery": {"Cell Phone Battery"};
4. core\configuration.sqf
Adde bei "life_inv_items" das:
Spoiler anzeigen
"life_inv_battery"
Adde in "sell_array" das:
Spoiler anzeigen
["battery",750]
Adde in "buy_array" das:
Spoiler anzeigen
["battery",1500]
5. core\config\fn_virt_shops.sqf
Adde in "case "market"" das:
Spoiler anzeigen
{["Altis Market",["battery"]]};
Das ganze müsste da so aussehen ungefär
Spoiler anzeigen
case "market": {["Altis Market",["water","rabbit","redgull","tbacon","lockpick","battery","pickaxe","axt","fuelF","pfandflasche","openkokos","storage2"]]};
6. core\pmenu\useItem.sqf
Adde das hinzu
Spoiler anzeigen
case (_item == "battery"):
{
if(([false,_item,1] call life_fnc_handleInv)) then
{
life_battery = 100;
hint "Your battery is full now.";
};
};
Bitte achtet gut, das wenn ihr wo was hinzufügt auf die komas (,) zu achten.
Das letzte darf nie ein (,) haben, jedoch obendrüber alle.
Das war es schon. Nun hat euer Handy einen Akku.
Sollte der Akku mal leer sein, könnt ihr das Handy nicht mehr benutzen bis ihr im Markt eine neue Batterie kauft.
Original Thread: (English) [HOWTO] Add Cell Phone Battery [3.1.2 / 3.1.3] - Editing Docs - Altis Life RPG
Im anhang habe ich noch 2 sachen eingefügt, die ihr in euer FTP laden müsst.
Das Icon, und die fn_callCellPhone.sqf.
Wenn probleme auftretten helfe ich euch gerne.
MfG
Noldy