Advertisement
Guest User

fn_insureCar.sqf

a guest
Feb 12th, 2017
299
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.46 KB | None | 0 0
  1. #include "..\..\script_macros.hpp"
  2. /*
  3. File: fn_insureCar.sqf
  4. Author: Guit0x "Lintox"
  5. Description:
  6. Insure a vehicle from the garage.
  7. */
  8. private["_vehicle","_vehicleLife","_vid","_pid","_unit","_multiplier","_price","_purchasePrice","_insurancePrice"];
  9. disableSerialization;
  10. if ((lbCurSel 2802) isEqualTo -1) exitWith {hint localize "STR_Global_NoSelection"};
  11. _vehicle = lbData[2802,(lbCurSel 2802)];
  12. _vehicle = (call compile format["%1",_vehicle]) select 0;
  13. _vehicleLife = _vehicle;
  14. _vid = lbValue [ 2802 , (lbCurSel 2802 )];
  15. _pid = getPlayerUID player;
  16. _unit = player;
  17. if(isNil "_vehicle") exitWith {hint localize "STR_Garage_Selection_Error"};
  18. if ((time - life_action_delay) < 1.5) exitWith {hint localize "STR_NOTF_ActionDelay";};
  19. if (!isClass (missionConfigFile >> "LifeCfgVehicles" >> _vehicleLife)) then {
  20. _vehicleLife = "Default"; //Use Default class if it doesn't exist
  21. diag_log format["%1: LifeCfgVehicles class doesn't exist",_vehicle];
  22. };
  23. _price = M_CONFIG(getNumber,"LifeCfgVehicles",_vehicleLife,"price");
  24. switch (playerSide) do {
  25. case civilian: {
  26. _multiplier = LIFE_SETTINGS(getNumber,"vehicle_insurance_multiplier_CIVILIAN");
  27. _purchasePrice = _price * LIFE_SETTINGS(getNumber,"vehicle_purchase_multiplier_CIVILIAN");
  28. };
  29. case west: {
  30. _multiplier = LIFE_SETTINGS(getNumber,"vehicle_insurance_multiplier_COP");
  31. _purchasePrice = _price * LIFE_SETTINGS(getNumber,"vehicle_purchase_multiplier_COP");
  32. };
  33. case independent: {
  34. _multiplier = LIFE_SETTINGS(getNumber,"vehicle_insurance_multiplier_MEDIC");
  35. _purchasePrice = _price * LIFE_SETTINGS(getNumber,"vehicle_purchase_multiplier_MEDIC");
  36. };
  37. case east: {
  38. _multiplier = LIFE_SETTINGS(getNumber,"vehicle_insurance_multiplier_OPFOR");
  39. _purchasePrice = _price * LIFE_SETTINGS(getNumber,"vehicle_purchase_multiplier_OPFOR");
  40. };
  41. };
  42. _insurancePrice = _purchasePrice * _multiplier;
  43. if(!(_insurancePrice isEqualType 0) || _insurancePrice < 1) then {_insurancePrice = 500};
  44. if(BANK < _insurancePrice) exitWith {hint format[(localize "STR_GNOTF_NotEnoughMoney"),[_insurancePrice] call life_fnc_numberText];};
  45. if (life_HC_isActive) then {
  46. [_vid,_pid,_insurancePrice,player,life_garage_type] remoteExecCall ["HC_fnc_insureCar",HC_Life];
  47. } else {
  48. [_vid,_pid,_insurancePrice,player,life_garage_type] remoteExecCall ["TON_fnc_insureCar",RSERV];
  49. };
  50. hint localize "STR_InsuranceApply";
  51. BANK = BANK - _insurancePrice;
  52. life_action_delay = time;
  53. closeDialog 0;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement