Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class radioKit {
- variable = "radioKit";
- displayName = "Radio Install Kit";
- weight = 5;
- buyPrice = 1000;
- sellPrice = 500;
- illegal = false;
- edible = -1;
- icon = "icons\badpngradio.paa";
- };
- // add to bottom of Config_vitems.hpp
- "radioKit"
- // add to vitem shop of choosing in Config_vitems.hpp
- case (_item isEqualTo "radioKit"): {
- if (vehicle player != player) exitWith {hint "You must be outside of the car in order to install a radio"};
- if ([] call life_fnc_playerSide != civilian) exitWith {hint "Only civilians can use this item"};
- if !(cursorTarget isKindOf "Car") exitWith {hint "This can only be installed on cars"};
- [] spawn life_fnc_installRadio;
- closeDialog 0;
- };
- // add this case to fn_useItem.sqf
- // create a file called fn_installRadio.sqf in core/functions
- // In Functions.hpp add class installRadio {}; in class Functions should look like class Functions {
- file = "core\functions";
- //otherstuffhere
- //otherstuffhere
- //otherstuffhere
- //otherstuffhere
- //otherstuffhere
- //etc
- class installRadio {};
- };
- //
- ALTER TABLE vehicles
- ADD tfrradiorange int NOT NULL DEFAULT 0
- // run this query in the db
- #include "..\..\script_macros.hpp"
- private["_veh","_upp","_ui","_progress","_pgText","_cP","_displayName","_test","_sideRepairArray"];
- _veh = cursorObject;
- life_interrupted = false;
- if (isNull _veh) exitWith {};
- if ((_veh isKindOf "Car")) then {
- _vehData = _veh getVariable ["vehicle_info_owners",[]];
- if (count _vehData > 0) then {
- _vehOwner = ((_vehData select 0) select 0);
- if ((getPlayerUID player) != _vehOwner) exitwith {hint "You must be the owner of the vehicle in order to install a radio" _exit = true;};
- };
- if !(isNil "_exit") exitwith {};
- if (life_inv_radioKit > 0) then {
- life_action_inUse = true;
- _displayName = FETCH_CONFIG2(getText,"CfgVehicles",(typeOf _veh),"displayName");
- _upp = "Installing";
- //Setup our progress bar.
- disableSerialization;
- "progressBar" cutRsc ["life_progress","PLAIN"];
- _ui = uiNamespace getVariable "life_progress";
- _progress = _ui displayCtrl 38201;
- _pgText = _ui displayCtrl 38202;
- _pgText ctrlSetText format["%2 (1%1)...","%",_upp];
- _progress progressSetPosition 0.01;
- _cP = 0.01;
- for "_i" from 0 to 1 step 0 do {
- if (animationState player != "AinvPknlMstpSnonWnonDnon_medic_1") then {
- [player,"AinvPknlMstpSnonWnonDnon_medic_1",true] remoteExecCall ["life_fnc_animSync",RCLIENT];
- player switchMove "AinvPknlMstpSnonWnonDnon_medic_1";
- player playMoveNow "AinvPknlMstpSnonWnonDnon_medic_1";
- };
- sleep 0.27;
- _cP = _cP + 0.01;
- _progress progressSetPosition _cP;
- _pgText ctrlSetText format["%3 (%1%2)...",round(_cP * 100),"%",_upp];
- if (_cP >= 1) exitWith {};
- if (!alive player) exitWith {};
- if (player != vehicle player) exitWith {};
- if (life_interrupted) exitWith {};
- };
- life_action_inUse = false;
- "progressBar" cutText ["","PLAIN"];
- player playActionNow "stop";
- if (life_interrupted) exitWith {life_interrupted = false; titleText[localize "STR_NOTF_ActionCancel","PLAIN"]; life_action_inUse = false;};
- if (player != vehicle player) exitWith {titleText[localize "STR_NOTF_ActionInVehicle","PLAIN"];};
- _sideRepairArray = LIFE_SETTINGS(getArray,"vehicle_infiniteRepair");
- [false,"radioKit",1] call life_fnc_handleInv;
- if (life_HC_isActive) then {
- [_vehicle,50000] remoteExec ["HC_fnc_vehicleRadioDbUpdate",HC_Life];
- } else {
- [_vehicle,50000] remoteExec ["TON_fnc_vehicleRadioDbUpdate",RSERV];
- };
- titleText[localize "Radio Installed","PLAIN"];
- };
- };
- // paste that code in the fn_installRadio.sqf in core/functions
- #include "\life_server\script_macros.hpp"
- private["_vehicle","_impound","_vInfo","_vInfo","_plate","_uid","_query","_sql","_unit","_trunk","_vehItems","_vehMags","_vehWeapons","_vehBackpacks","_cargo","_saveItems","_storetext","_resourceItems","_fuel","_damage","_itemList","_totalweight","_weight","_thread"];
- _vehicle = [_this,0,ObjNull,[ObjNull]] call BIS_fnc_param;
- _tfrradiorange = [_this,1,50000,[0]] call BIS_fnc_param;
- _vInfo = _vehicle getVariable["dbInfo",[]];
- if (count _vInfo > 0) then {
- _plate = _vInfo select 1;
- _uid = _vInfo select 0;
- };
- _query = format["UPDATE vehicles SET tfrradiorange='%3' WHERE pid='%1' AND plate='%2'", _uid, _plate, _tfrradiorange];
- _thread = [_query,1] call DB_fnc_asyncCall;
- //create a new file in the life server dir life_server\Functions\Systems\fn_vehicleRadioDbUpdate.sqf and in the file paste the code above
- _query = format["SELECT id, side, classname, type, pid, alive, active, plate, color, inventory, gear, fuel, damage, blacklist, insure, tfrradiorange FROM vehicles WHERE id='%1' AND pid='%2'",_vid,_pid];
- //in the fn_spawnVehicle.sqf in life_server\Functions\Systems\fn_spawnVehicle.sqf change line 28 to the code above
- if (_side in [civilian] && (_vInfo select 14) > 0) then {_vehicle setVariable ["tf_hasRadio", true, true]; _vehicle setVariable ["tf_range", (_vInfo select 14), true]; _vehicle setVariable ["tf_side", west, true]; _vehicle setVariable ["TF_RadioType", "tf_rt1523g", true];};
- //add that code below this code if (_side in [west, independent]) then {_vehicle setVariable ["tf_hasRadio", true, true]; _vehicle setVariable ["tf_range", 50000, true]; _vehicle setVariable ["tf_side", west, true]; _vehicle setVariable ["TF_RadioType", "tf_rt1523g", true];}; in the same life_server\Functions\Systems\fn_spawnVehicle.sqf file
- class vehicleRadioDbUpdate {};
- // in the life server config.cpp the class above to the class
- TON_System {
- tag = "TON";
- class Systems {
- file = "\life_server\Functions\Systems";
- //lots of other lines of shit goes here that i removed to make it shorter
- class vehicleRadioDbUpdate {};
- };
- // download https://drive.google.com/file/d/0B9aTODHbJtEMN2tKVmFhQkJKNlk/view?usp=sharing to mission file / icons folder
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement