SHARE
TWEET

Bones_fnc_performAction.sqf

a guest May 22nd, 2019 75 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2. Bones Vehicle Repair Script
  3.  
  4. Executed from Bones_fnc_salvageAndRepairMenu.sqf
  5.  
  6. Call as [_action, _vehicle, _items, _price] execVM 'Custom\vehicleService\Bones_fnc_Repair.sqf';
  7.  
  8. */
  9.  
  10. _vehicle1 = [];
  11. if (isNull objectParent player) then {_vehicle1 pushback cursorTarget;} else
  12. {
  13. _vehicleTemp = (objectParent player);
  14. _vehicle1 pushback (nearestObject [player, typeof _vehicleTemp]);
  15. };
  16. _vehicle = (_vehicle1 select 0);
  17. _temp = _this select 0;
  18. _actionData = call compile _temp;
  19. _action = _actionData select 0;
  20.  
  21. if (_action == "rearmall") then
  22. {
  23.     private ["_cost"];
  24.     _cost = 0;
  25.     _cost = [] call Bones_fnc_getReloadCost;
  26.     _exilew = player getVariable ["ExileMoney", 0];
  27.     if (_exilew <_cost) exitWith {["ErrorTitleOnly", ["You don't have enough money!"]] call ExileClient_gui_toaster_addTemplateToast;};
  28.    
  29.     ["Reload.ogg", _Vehicle, 30] call Bones_fnc_playSounds;
  30.    
  31.     _vehicle setVehicleAmmo 1;
  32.     if(_cost > 0 && isTradeEnabled)then
  33.     {
  34.         takegive_poptab = [player,_cost,true];
  35.         publicVariableServer "takegive_poptab";
  36.     };
  37.     [] call Bones_fnc_getReloadable;
  38.     _playerPoptabs = _exilew - _cost;
  39.     _poptabs = (findDisplay 9123 displayCtrl 1001);
  40.     _poptabs ctrlSetText (format ["%1 poptabs", _playerPoptabs]);
  41.     _rearmAll = (findDisplay 9123 displayCtrl 1605);
  42.     _rearmAll ctrlenable false;
  43.     _reloadValueDisplay = 0;
  44.     _reloadCost = (findDisplay 9123 displayCtrl 1006);
  45.     _reloadCost ctrlSetText (format ["%1 Poptabs", _reloadValueDisplay]);
  46.    
  47.     ["SuccessTitleOnly", format ["Reload of All Items Complete, Total Cost was %1 Poptabs", _cost]] call ExileClient_gui_toaster_addTemplateToast;
  48. };
  49.  
  50. if (_action == "repairall") then
  51. {
  52.     _cost = [] call Bones_fnc_getRepairableCosts;
  53.     _exilew = player getVariable ["ExileMoney", 0];
  54.     if (_exilew <_cost) exitWith {["ErrorTitleOnly", ["You don't have enough money!"]] call ExileClient_gui_toaster_addTemplateToast;};
  55.    
  56.     ["Repair.ogg", _Vehicle, 30] call Bones_fnc_playSounds;
  57.  
  58.     _vehicle setdamage 0;
  59.     if(_cost > 0 && isTradeEnabled)then
  60.     {
  61.         takegive_poptab = [player,_cost,true];
  62.         publicVariableServer "takegive_poptab";
  63.     };
  64.     [] call Bones_fnc_getRepairable;
  65.     _playerPoptabs = _exilew - _cost;
  66.     _poptabs = (findDisplay 9123 displayCtrl 1001);
  67.     _poptabs ctrlSetText (format ["%1 poptabs", _playerPoptabs]);
  68.     _repairAll = (findDisplay 9123 displayCtrl 1604);
  69.     _repairAll ctrlenable false;
  70.     _repairValueDisplay = 0;
  71.     _repairCost = (findDisplay 9123 displayCtrl 1008);
  72.     _repairCost ctrlSetText (format ["%1 Poptabs", _repairValueDisplay]);
  73.    
  74.     ["SuccessTitleOnly", format ["Repair of All Items Complete, Total Cost was %1 Poptabs", _cost]] call ExileClient_gui_toaster_addTemplateToast;
  75. };
  76.  
  77. if (_action == "Repair") then
  78.  
  79. {
  80.     _items = _actionData select 1;
  81.     _price = _actionData select 2;
  82.  
  83.     _exilew = player getVariable ["ExileMoney", 0];
  84.     if (_exilew <_price) exitWith {["ErrorTitleOnly", ["You don't have enough money!"]] call ExileClient_gui_toaster_addTemplateToast;};
  85.    
  86.     ["Repair.ogg", _Vehicle, 30] call Bones_fnc_playSounds;
  87.    
  88.     {_vehicle setHitPointDamage [_x, 0]}forEach _items;
  89.    
  90.     if(_price > 0 && isTradeEnabled)then{
  91.             takegive_poptab = [player,_price,true];
  92.             publicVariableServer "takegive_poptab";
  93.     };
  94.  
  95.     [] call Bones_fnc_getRepairable;
  96.     _playerPoptabs = player getVariable ["ExileMoney", 0];
  97.     _poptabs = (findDisplay 9123 displayCtrl 1001);
  98.     _poptabs ctrlSetText (format ["%1 poptabs", _playerPoptabs]);
  99.     _repairValueDisplay = [] call Bones_fnc_getRepairableCosts;
  100.     _repairCost = (findDisplay 9123 displayCtrl 1008);
  101.     _repairCost ctrlSetText (format ["%1 Poptabs", _repairValueDisplay]);
  102.     if(_repairValueDisplay == 0) then
  103.     {
  104.     _repairAll = (findDisplay 9123 displayCtrl 1604);
  105.     _repairAll ctrlenable false;
  106.     };
  107.  
  108.     ["SuccessTitleOnly", format ["Repair of item complete, Total Cost was %1 Poptabs", _price]] call ExileClient_gui_toaster_addTemplateToast;
  109. };
  110.  
  111. if (_action == "Reload") then
  112.  
  113. {
  114.     _items = _actionData select 1;
  115.     _price = _actionData select 2;
  116.     _turretPath = _actionData select 3;
  117.     _bulletAmount = _actionData select 4;
  118.     _pylonIndex = _actionData select 5;
  119.  
  120.     _exilew = player getVariable ["ExileMoney", 0];
  121.     if (_exilew <_price) exitWith {["ErrorTitleOnly", ["You don't have enough money!"]] call ExileClient_gui_toaster_addTemplateToast;};
  122.    
  123.     ["Reload.ogg", _Vehicle, 30] call Bones_fnc_playSounds;
  124.    
  125.     if (["120mm",_items] call BIS_fnc_inString || ["125mm",_items] call BIS_fnc_inString || ["105mm",_items] call BIS_fnc_inString || ["L30A1_Cannon",_items] call BIS_fnc_inString || ["2A46",_items] call BIS_fnc_inString || ["100mm",_items] call BIS_fnc_inString) then
  126.     {
  127.         _vehicle removeMagazinesTurret [_items, _turretPath];
  128.         _vehicle addMagazineTurret [_items,_turretPath,_bulletAmount];
  129.     } else
  130.     {
  131.         //DO THIS IF SMOKE
  132.         if (["smoke",_items] call BIS_fnc_inString) then
  133.         {
  134.             _vehicle removeMagazinesTurret [_items, _turretPath];
  135.             _vehicle removeWeaponTurret ["SmokeLauncher", _turretPath];
  136.             _vehicle addMagazineTurret [_items,_turretPath,_bulletAmount];
  137.             _vehicle addWeaponTurret ["SmokeLauncher", _turretPath];
  138.         } else
  139.         {
  140.             //DO THIS IF CHAFF
  141.             if (["chaff",_items] call BIS_fnc_inString) then
  142.             {
  143.                 _vehicle removeMagazinesTurret [_items, _turretPath];
  144.                 _vehicle removeWeaponTurret ["CMFlareLauncher", _turretPath];
  145.                 _vehicle addMagazineTurret [_items,_turretPath,_bulletAmount];
  146.                 _vehicle addWeaponTurret ["CMFlareLauncher", _turretPath];
  147.             } else
  148.             {
  149.                 //DO THIS IF PYLON
  150.                 if (["pylon",_items] call BIS_fnc_inString) then
  151.                 {
  152.                     _vehicle setAmmoOnPylon [_pylonIndex,_bulletAmount];
  153.                 } else
  154.                 {
  155.                     //FOR EVERYTHING ELSE
  156.                     _maxMagAmmo = (configFile >> "CfgMagazines" >> _items >> "count") call BIS_fnc_getCfgData;
  157.                     _vehicle addMagazineTurret [_items, _turretPath, _bulletAmount];   
  158.                     _numMags = floor (_bulletAmount / _maxMagAmmo);
  159.                     _vehicle removeMagazinesTurret [_items, _turretPath];
  160.                     while {_numMags > 0} do
  161.                     {
  162.                         _vehicle addMagazineTurret [_items, _turretPath];
  163.                         _numMags = _numMags - 1;
  164.                     };
  165.                 };
  166.             };
  167.         };
  168.     };
  169.    
  170.     if(_price > 0 && isTradeEnabled)then{
  171.             takegive_poptab = [player,_price,true];
  172.             publicVariableServer "takegive_poptab";
  173.     };
  174.     [] call Bones_fnc_getReloadable;
  175.     _playerPoptabs = _exilew - _price;
  176.     _poptabs = (findDisplay 9123 displayCtrl 1001);
  177.     _poptabs ctrlSetText (format ["%1 poptabs", _playerPoptabs]);
  178.     _reloadValueDisplay = []call Bones_fnc_getReloadCost;
  179.     _reloadCost = (findDisplay 9123 displayCtrl 1006);
  180.     _reloadCost ctrlSetText (format ["%1 Poptabs", _reloadValueDisplay]);
  181.     if(_reloadValueDisplay == 0) then
  182.     {
  183.     _rearmAll = (findDisplay 9123 displayCtrl 1605);
  184.     _rearmAll ctrlenable false;
  185.     };
  186.    
  187.     ["SuccessTitleOnly", format ["Reload of weapon complete, Total Cost was %2 Poptabs", _items, _price]] call ExileClient_gui_toaster_addTemplateToast;
  188. };
  189.  
  190. if (_action == "refuel") then
  191. {
  192.     _maxFuelAmount = getnumber (configfile >> "cfgvehicles" >> (typeof _vehicle) >> "fuelCapacity");
  193.     _fuelAmountTemp = fuel _vehicle;
  194.     _fuelAmount = _fuelAmountTemp * _maxFuelAmount;
  195.     _refillFuelAmount = round(_maxFuelAmount - _fuelAmount);
  196.     _refuelCost = _refillFuelAmount * fuelingPrice;
  197.     if (_refuelCost == 0) exitwith {["ErrorTitleOnly", ["You're fuel tank is already full!"]] call ExileClient_gui_toaster_addTemplateToast;};
  198.     _exilew = player getVariable ["ExileMoney", 0];
  199.     if (_exilew <_refuelCost) exitWith {["ErrorTitleOnly", ["You don't have enough money!"]] call ExileClient_gui_toaster_addTemplateToast;};
  200.     _vehicle setFuel 1;
  201.     if(_refuelCost > 0 && isTradeEnabled)then
  202.     {
  203.         takegive_poptab = [player,_refuelCost,true];
  204.         publicVariableServer "takegive_poptab";
  205.     };
  206.     _maxFuelAmount = getnumber (configfile >> "cfgvehicles" >> (typeof _vehicle) >> "fuelCapacity");
  207.     _fuelAmountTemp = fuel _vehicle;
  208.     _fuelAmount = _fuelAmountTemp * _maxFuelAmount;
  209.     _refillFuelAmount = round(_maxFuelAmount - _fuelAmount);
  210.     _refuelCost2 = _refillFuelAmount * fuelingPrice;
  211.     if (_refuelCost2 == 0 || enableRefuelOption == 0) then
  212.     {
  213.         _reFuelButton = (findDisplay 9123 displayCtrl 1600);
  214.         _reFuelButton ctrlenable false;
  215.     };
  216.     _refuelDisplay = format["%1 Poptabs", _refuelCost2];
  217.     _reFuelButton = (findDisplay 9123 displayCtrl 1010);
  218.     _reFuelButton ctrlSetText _refuelDisplay;
  219.    
  220.     ["SuccessTitleOnly", format ["Refuelling Complete, Total Cost was %1 Poptabs", _refuelCost]] call ExileClient_gui_toaster_addTemplateToast;
  221. };
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top