Advertisement
Guest User

fn_weaponshopbuysell.sqf

a guest
Feb 25th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.47 KB | None | 0 0
  1. #include "..\..\script_macros.hpp"
  2. /*
  3. File: fn_weaponShopBuySell.sqf
  4. Author: Bryan "Tonic" Boardwine
  5.  
  6. Description:
  7. Master handling of the weapon shop for buying / selling an item.
  8. */
  9. disableSerialization;
  10. private ["_price","_item","_itemInfo","_bad","_shop","_deduction"];
  11. if ((lbCurSel 38403) isEqualTo -1) exitWith {hint localize "STR_Shop_Weapon_NoSelect"};
  12. _price = lbValue[38403,(lbCurSel 38403)]; if (isNil "_price") then {_price = 0;};
  13. _item = lbData[38403,(lbCurSel 38403)];
  14. _itemInfo = [_item] call life_fnc_fetchCfgDetails;
  15. _shop = cursorObject;
  16.  
  17. //if ((LIFE_SETTINGS(getNumber,"debit_weapons") isEqualTo 1) && (life_has_debit isEqualTo true)) then {
  18. // CASH = BANK;
  19. // _tax = 0.1;
  20. //} else {
  21. // CASH = CASH;
  22. //};
  23.  
  24. _bad = "";
  25.  
  26. if ((_itemInfo select 6) != "CfgVehicles") then {
  27. if ((_itemInfo select 4) in [4096,131072]) then {
  28. if (!(player canAdd _item) && (uiNamespace getVariable ["Weapon_Shop_Filter",0]) != 1) exitWith {_bad = (localize "STR_NOTF_NoRoom")};
  29. };
  30. };
  31.  
  32. if (_bad != "") exitWith {hint _bad};
  33.  
  34. if ((uiNamespace getVariable ["Weapon_Shop_Filter",0]) isEqualTo 1) then {
  35. CASH = CASH + _price;
  36. [_item,false] call life_fnc_handleItem;
  37. hint parseText format [localize "STR_Shop_Weapon_Sold",_itemInfo select 1,[_price] call life_fnc_numberText];
  38. [nil,(uiNamespace getVariable ["Weapon_Shop_Filter",0])] call life_fnc_weaponShopFilter; //Update the menu.
  39. } else {
  40. private _altisArray = ["Land_u_Barracks_V2_F","Land_i_Barracks_V2_F"];
  41. private _tanoaArray = ["Land_School_01_F","Land_Warehouse_03_F","Land_House_Small_02_F"];
  42. private _stratisArray = ["Land_Barracks_01_camo_F","Land_u_Barracks_V2_F","Land_i_Barracks_V2_F","Land_Cargo_HQ_V2_F"];
  43. private _hideoutObjs = [[["Altis", _altisArray], ["Tanoa", _tanoaArray], ["Stratis", _stratisArray]]] call TON_fnc_terrainSort;
  44. private _hideout = (nearestObjects[getPosATL player,_hideoutObjs,25]) select 0;
  45. if (!isNil "_hideout" && {!isNil {group player getVariable "gang_bank"}} && {(group player getVariable "gang_bank") >= _price}) then {
  46. _action = [
  47. 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>",
  48. [(group player getVariable "gang_bank")] call life_fnc_numberText,
  49. [CASH] call life_fnc_numberText
  50. ],
  51. localize "STR_Shop_Virt_YourorGang",
  52. localize "STR_Shop_Virt_UI_GangFunds",
  53. localize "STR_Shop_Virt_UI_YourCASH"
  54. ] call BIS_fnc_guiMessage;
  55. if (_action) then {
  56. hint parseText format [localize "STR_Shop_Weapon_BoughtGang",_itemInfo select 1,[_price] call life_fnc_numberText];
  57. _funds = group player getVariable "gang_bank";
  58. if(str(_shop) == "RebelDealer") then {
  59. _deduction = (_price * 0.1);
  60. _price = _price + _deduction;
  61. [_deduction] remoteExec ["TON_fnc_cartelWeapons",RSERV];
  62. };
  63. _funds = _funds - _price;
  64. group player setVariable ["gang_bank",_funds,true];
  65. [_item,true] spawn life_fnc_handleItem;
  66.  
  67. if (life_HC_isActive) then {
  68. [1,group player] remoteExecCall ["HC_fnc_updateGang",HC_Life];
  69. } else {
  70. [1,group player] remoteExecCall ["TON_fnc_updateGang",RSERV];
  71. };
  72.  
  73.  
  74. } else {
  75. if (_price > CASH) exitWith {hint localize "STR_NOTF_NotEnoughMoney"};
  76. hint parseText format [localize "STR_Shop_Weapon_BoughtItem",_itemInfo select 1,[_price] call life_fnc_numberText];
  77. if(str(_shop) == "RebelDealer") then {
  78. _deduction = (_price * 0.1);
  79. _price = _price + _deduction;
  80. [_deduction] remoteExec ["TON_fnc_cartelWeapons",RSERV];
  81. };
  82.  
  83. CASH = CASH - _price;
  84.  
  85. [_item,true] spawn life_fnc_handleItem;
  86. };
  87. } else {
  88. if (_price > CASH) exitWith {hint localize "STR_NOTF_NotEnoughMoney"};
  89. hint parseText format [localize "STR_Shop_Weapon_BoughtItem",_itemInfo select 1,[_price] call life_fnc_numberText];
  90. if(str(_shop) == "RebelDealer") then {
  91. _deduction = (_price * 0.1);
  92. _price = _price + _deduction;
  93. [_deduction] remoteExec ["TON_fnc_cartelWeapons",RSERV];
  94. };
  95. CASH = CASH - _price;
  96. [_item,true] spawn life_fnc_handleItem;
  97. };
  98. };
  99. [0] call SOCK_fnc_updatePartial;
  100. [] call life_fnc_saveGear;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement