Advertisement
Guest User

Untitled

a guest
Jan 19th, 2017
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQF 6.31 KB | None | 0 0
  1.     class radioKit {
  2.         variable = "radioKit";
  3.         displayName = "Radio Install Kit";
  4.         weight = 5;
  5.         buyPrice = 1000;
  6.         sellPrice = 500;
  7.         illegal = false;
  8.         edible = -1;
  9.         icon = "icons\badpngradio.paa";
  10.     };
  11.  
  12. // add to bottom of Config_vitems.hpp
  13.  
  14. "radioKit"
  15.  
  16. // add to vitem shop of choosing in Config_vitems.hpp
  17.  
  18.     case (_item isEqualTo "radioKit"): {
  19.         if (vehicle player != player) exitWith {hint "You must be outside of the car in order to install a radio"};
  20.         if ([] call life_fnc_playerSide != civilian) exitWith {hint "Only civilians can use this item"};
  21.         if !(cursorTarget isKindOf "Car") exitWith {hint "This can only be installed on cars"};
  22.         [] spawn life_fnc_installRadio;
  23.         closeDialog 0;
  24.     };
  25.  
  26. // add this case to fn_useItem.sqf
  27.  
  28. // create a file called fn_installRadio.sqf in core/functions
  29.  
  30. // In Functions.hpp add class installRadio {}; in class Functions should look like     class Functions    {
  31.         file = "core\functions";
  32.         //otherstuffhere
  33.         //otherstuffhere
  34.         //otherstuffhere
  35.         //otherstuffhere
  36.         //otherstuffhere
  37.         //etc
  38.         class installRadio {};
  39.  
  40.     };
  41.    
  42.     //
  43.    
  44.     ALTER TABLE vehicles
  45.     ADD tfrradiorange int NOT NULL DEFAULT 0
  46.    
  47.     // run this query in the db
  48.    
  49.  
  50. #include "..\..\script_macros.hpp"
  51.  
  52. private["_veh","_upp","_ui","_progress","_pgText","_cP","_displayName","_test","_sideRepairArray"];
  53. _veh = cursorObject;
  54. life_interrupted = false;
  55. if (isNull _veh) exitWith {};
  56. if ((_veh isKindOf "Car")) then {
  57.     _vehData = _veh getVariable ["vehicle_info_owners",[]];
  58.     if (count _vehData  > 0) then {
  59.     _vehOwner = ((_vehData select 0) select 0);
  60.     if ((getPlayerUID player) != _vehOwner) exitwith {hint "You must be the owner of the vehicle in order to install a radio" _exit = true;};
  61.     };
  62.    
  63.     if !(isNil "_exit") exitwith {};
  64.    
  65.     if (life_inv_radioKit > 0) then {
  66.         life_action_inUse = true;
  67.         _displayName = FETCH_CONFIG2(getText,"CfgVehicles",(typeOf _veh),"displayName");
  68.         _upp = "Installing";
  69.  
  70.         //Setup our progress bar.
  71.         disableSerialization;
  72.         "progressBar" cutRsc ["life_progress","PLAIN"];
  73.         _ui = uiNamespace getVariable "life_progress";
  74.         _progress = _ui displayCtrl 38201;
  75.         _pgText = _ui displayCtrl 38202;
  76.         _pgText ctrlSetText format["%2 (1%1)...","%",_upp];
  77.         _progress progressSetPosition 0.01;
  78.         _cP = 0.01;
  79.  
  80.         for "_i" from 0 to 1 step 0 do {
  81.             if (animationState player != "AinvPknlMstpSnonWnonDnon_medic_1") then {
  82.                 [player,"AinvPknlMstpSnonWnonDnon_medic_1",true] remoteExecCall ["life_fnc_animSync",RCLIENT];
  83.                 player switchMove "AinvPknlMstpSnonWnonDnon_medic_1";
  84.                 player playMoveNow "AinvPknlMstpSnonWnonDnon_medic_1";
  85.             };
  86.  
  87.             sleep 0.27;
  88.             _cP = _cP + 0.01;
  89.             _progress progressSetPosition _cP;
  90.             _pgText ctrlSetText format["%3 (%1%2)...",round(_cP * 100),"%",_upp];
  91.             if (_cP >= 1) exitWith {};
  92.             if (!alive player) exitWith {};
  93.             if (player != vehicle player) exitWith {};
  94.             if (life_interrupted) exitWith {};
  95.         };
  96.  
  97.         life_action_inUse = false;
  98.         "progressBar" cutText ["","PLAIN"];
  99.         player playActionNow "stop";
  100.         if (life_interrupted) exitWith {life_interrupted = false; titleText[localize "STR_NOTF_ActionCancel","PLAIN"]; life_action_inUse = false;};
  101.         if (player != vehicle player) exitWith {titleText[localize "STR_NOTF_ActionInVehicle","PLAIN"];};
  102.  
  103.         _sideRepairArray = LIFE_SETTINGS(getArray,"vehicle_infiniteRepair");
  104.  
  105.  
  106.         [false,"radioKit",1] call life_fnc_handleInv;
  107.         if (life_HC_isActive) then {
  108.         [_vehicle,50000] remoteExec ["HC_fnc_vehicleRadioDbUpdate",HC_Life];
  109.         } else {
  110.         [_vehicle,50000] remoteExec ["TON_fnc_vehicleRadioDbUpdate",RSERV];
  111. };
  112.         titleText[localize "Radio Installed","PLAIN"];
  113.     };
  114. };
  115.  
  116. // paste that code in the fn_installRadio.sqf in core/functions
  117.  
  118. #include "\life_server\script_macros.hpp"
  119.  
  120. 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"];
  121. _vehicle = [_this,0,ObjNull,[ObjNull]] call BIS_fnc_param;
  122. _tfrradiorange = [_this,1,50000,[0]] call BIS_fnc_param;
  123.  
  124.  
  125.  
  126. _vInfo = _vehicle getVariable["dbInfo",[]];
  127.  
  128. if (count _vInfo > 0) then {
  129.     _plate = _vInfo select 1;
  130.     _uid = _vInfo select 0;
  131. };
  132.  
  133. _query = format["UPDATE vehicles SET tfrradiorange='%3' WHERE pid='%1' AND plate='%2'", _uid, _plate, _tfrradiorange];
  134. _thread = [_query,1] call DB_fnc_asyncCall;
  135.  
  136. //create a new file in the life server dir life_server\Functions\Systems\fn_vehicleRadioDbUpdate.sqf and in the file paste the code above
  137.  
  138. _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];
  139.  
  140.  
  141. //in the fn_spawnVehicle.sqf in life_server\Functions\Systems\fn_spawnVehicle.sqf change line 28 to the code above
  142.  
  143.     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];};
  144.  
  145. //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
  146.  
  147. class vehicleRadioDbUpdate {};
  148.  
  149. // in the life server config.cpp the class above to the class
  150.         TON_System {
  151.         tag = "TON";
  152.         class Systems {
  153.             file = "\life_server\Functions\Systems";
  154.             //lots of other lines of shit goes here that i removed to make it shorter
  155.             class vehicleRadioDbUpdate {};
  156.         };
  157.  
  158.  
  159.        
  160.        
  161.        
  162. // 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