Advertisement
Guest User

Fn_virt_buydebit.sqf

a guest
Feb 25th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.50 KB | None | 0 0
  1. #include "..\..\script_macros.hpp"
  2. /*
  3. File: fn_virt_buyDebit.sqf
  4. Author: Bryan "Tonic" Boardwine
  5. Edited by: Ilusionz
  6.  
  7. Description:
  8. Buy a virtual item from the store using a debit card.
  9. */
  10. private ["_type","_price","_amount","_diff","_name","_hideout","_realPrice","_priceAfterTax","_debitTax","_realTaxAmount"];
  11. if ((lbCurSel 2401) isEqualTo -1) exitWith {hint localize "STR_Shop_Virt_Nothing"};
  12. _type = lbData[2401,(lbCurSel 2401)];
  13. _price = lbValue[2401,(lbCurSel 2401)];
  14. _amount = ctrlText 2404;
  15. if (!([_amount] call TON_fnc_isnumber)) exitWith {hint localize "STR_Shop_Virt_NoNum";};
  16. _diff = [_type,parseNumber(_amount),life_carryWeight,life_maxWeight] call life_fnc_calWeightDiff;
  17. _amount = parseNumber(_amount);
  18. if (_diff <= 0) exitWith {hint localize "STR_NOTF_NoSpace"};
  19. _amount = _diff;
  20. private _altisArray = ["Land_u_Barracks_V2_F","Land_i_Barracks_V2_F"];
  21. private _tanoaArray = ["Land_School_01_F","Land_Warehouse_03_F","Land_House_Small_02_F"];
  22. private _stratisArray = ["Land_Barracks_01_camo_F","Land_u_Barracks_V2_F","Land_i_Barracks_V2_F","Land_Cargo_HQ_V2_F"];
  23. private _hideoutObjs = [[["Altis", _altisArray], ["Tanoa", _tanoaArray], ["Stratis", _stratisArray]]] call TON_fnc_terrainSort;
  24. _hideout = (nearestObjects[getPosATL player,_hideoutObjs,25]) select 0;
  25. if ((time - life_action_delay) < 0.2) exitWith {hint localize "STR_NOTF_ActionDelay";};
  26. life_action_delay = time;
  27. _realPrice = _price * _amount;
  28.  
  29. _name = M_CONFIG(getText,"VirtualItems",_type,"displayName");
  30.  
  31. if ([true,_type,_amount] call life_fnc_handleInv) then {
  32. if (!isNil "_hideout" && {!isNil {group player getVariable "gang_bank"}} && {(group player getVariable "gang_bank") >= _price}) then {
  33. _action = [
  34. format [(localize "STR_Shop_Virt_Gang_FundsMSG")+ "<br/><br/>" +(localize "STR_Shop_Virt_Gang_Funds")+ " <t color='#8cff9b'>$%1</t><br/>" +(localize "STR_Shop_Virt_YourFunds")+ " <t color='#8cff9b'>$%2</t>",
  35. [(group player getVariable "gang_bank")] call life_fnc_numberText,
  36. [CASH] call life_fnc_numberText
  37. ],
  38. localize "STR_Shop_Virt_YourorGang",
  39. localize "STR_Shop_Virt_UI_GangFunds",
  40. localize "STR_Shop_Virt_UI_YourCash"
  41. ] call BIS_fnc_guiMessage;
  42.  
  43. if (_action) then {
  44. hint format [localize "STR_Shop_Virt_BoughtGang",_amount,(localize _name),[(_price * _amount)] call life_fnc_numberText];
  45. _funds = group player getVariable "gang_bank";
  46. _funds = _funds - (_price * _amount);
  47. group player setVariable ["gang_bank",_funds,true];
  48.  
  49. if (life_HC_isActive) then {
  50. [1,group player] remoteExecCall ["HC_fnc_updateGang",HC_Life];
  51. } else {
  52. [1,group player] remoteExecCall ["TON_fnc_updateGang",RSERV];
  53. };
  54.  
  55. } else {
  56. try {
  57. if (CASH < _realPrice) then {
  58. if (BANK < _realPrice) then {
  59. hint localize "STR_NOTF_NotEnoughMoney"; [false,_type,_amount] call life_fnc_handleInv;
  60. throw "No money";
  61. };
  62. };
  63.  
  64. if ((BANK > _realPrice) && (CASH < _realPrice)) then {
  65. if (LIFE_SETTINGS(getNumber,"debit_tax") isEqualTo 1) then {
  66. _debitTax = LIFE_SETTINGS(getNumber,"debit_taxAmount");
  67. _realTaxAmount = _debitTax * _realPrice;
  68. _priceAfterTax = _realPrice + _realTaxAmount;
  69. BANK = BANK - _priceAfterTax;
  70. [1] call SOCK_fnc_updatePartial;
  71. hint parseText format [localize "STR_Debit_Virt_BoughtItemTax",_amount,(localize _name),[_realPrice] call life_fnc_numberText,[_realTaxAmount] call life_fnc_numberText];
  72. } else {
  73. BANK = BANK - _realPrice;
  74. hint parseText format [localize "STR_Debit_Virt_BoughtItem",_amount,(localize _name),[_realPrice] call life_fnc_numberText];
  75. [1] call SOCK_fnc_updatePartial;
  76. };
  77. } else {
  78. if (life_has_debit isEqualTo true) then {
  79. hint parseText format [localize "STR_Debit_Virt_UsedOnHandCash",_amount,(localize _name),[_realPrice] call life_fnc_numberText];
  80. CASH = CASH - _realPrice;
  81. [0] call SOCK_fnc_updatePartial;
  82. } else {
  83. CASH = CASH - _realPrice;
  84. [0] call SOCK_fnc_updatePartial;
  85. };
  86. };
  87. } catch {
  88. };
  89. };
  90. } else {
  91. try {
  92. if (CASH < _realPrice) then {
  93. if (BANK < _realPrice) then {
  94. hint localize "STR_NOTF_NotEnoughMoney"; [false,_type,_amount] call life_fnc_handleInv;
  95. throw "No money";
  96. };
  97. };
  98.  
  99. if ((BANK > _realPrice) && (CASH < _realPrice)) then {
  100. if (LIFE_SETTINGS(getNumber,"debit_tax") isEqualTo 1) then {
  101. _debitTax = LIFE_SETTINGS(getNumber,"debit_taxAmount");
  102. _realTaxAmount = _debitTax * _realPrice;
  103. _priceAfterTax = _realPrice + _realTaxAmount;
  104. BANK = BANK - _priceAfterTax;
  105. [1] call SOCK_fnc_updatePartial;
  106. hint parseText format [localize "STR_Debit_Virt_BoughtItemTax",_amount,(localize _name),[_realPrice] call life_fnc_numberText,[_realTaxAmount] call life_fnc_numberText];
  107. } else {
  108. BANK = BANK - _realPrice;
  109. hint parseText format [localize "STR_Debit_Virt_BoughtItem",_amount,(localize _name),[_realPrice] call life_fnc_numberText];
  110. [1] call SOCK_fnc_updatePartial;
  111. };
  112. } else {
  113. if (life_has_debit isEqualTo true) then {
  114. hint parseText format [localize "STR_Debit_Virt_UsedOnHandCash",_amount,(localize _name),[_realPrice] call life_fnc_numberText];
  115. CASH = CASH - _realPrice;
  116. [0] call SOCK_fnc_updatePartial;
  117. } else {
  118. CASH = CASH - _realPrice;
  119. [0] call SOCK_fnc_updatePartial;
  120. };
  121. };
  122. } catch {
  123. };
  124. };
  125. [] call life_fnc_virt_update;
  126. };
  127.  
  128. [3] call SOCK_fnc_updatePartial;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement