Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "..\..\script_macros.hpp"
- /*
- File: fn_weaponShopBuySell.sqf
- Author: Bryan "Tonic" Boardwine
- Description:
- Master handling of the weapon shop for buying / selling an item.
- */
- disableSerialization;
- private ["_price","_item","_itemInfo","_bad","_shop","_deduction"];
- if ((lbCurSel 38403) isEqualTo -1) exitWith {hint localize "STR_Shop_Weapon_NoSelect"};
- _price = lbValue[38403,(lbCurSel 38403)]; if (isNil "_price") then {_price = 0;};
- _item = lbData[38403,(lbCurSel 38403)];
- _itemInfo = [_item] call life_fnc_fetchCfgDetails;
- _shop = cursorObject;
- //if ((LIFE_SETTINGS(getNumber,"debit_weapons") isEqualTo 1) && (life_has_debit isEqualTo true)) then {
- // CASH = BANK;
- // _tax = 0.1;
- //} else {
- // CASH = CASH;
- //};
- _bad = "";
- if ((_itemInfo select 6) != "CfgVehicles") then {
- if ((_itemInfo select 4) in [4096,131072]) then {
- if (!(player canAdd _item) && (uiNamespace getVariable ["Weapon_Shop_Filter",0]) != 1) exitWith {_bad = (localize "STR_NOTF_NoRoom")};
- };
- };
- if (_bad != "") exitWith {hint _bad};
- if ((uiNamespace getVariable ["Weapon_Shop_Filter",0]) isEqualTo 1) then {
- CASH = CASH + _price;
- [_item,false] call life_fnc_handleItem;
- hint parseText format [localize "STR_Shop_Weapon_Sold",_itemInfo select 1,[_price] call life_fnc_numberText];
- [nil,(uiNamespace getVariable ["Weapon_Shop_Filter",0])] call life_fnc_weaponShopFilter; //Update the menu.
- } else {
- private _altisArray = ["Land_u_Barracks_V2_F","Land_i_Barracks_V2_F"];
- private _tanoaArray = ["Land_School_01_F","Land_Warehouse_03_F","Land_House_Small_02_F"];
- private _stratisArray = ["Land_Barracks_01_camo_F","Land_u_Barracks_V2_F","Land_i_Barracks_V2_F","Land_Cargo_HQ_V2_F"];
- private _hideoutObjs = [[["Altis", _altisArray], ["Tanoa", _tanoaArray], ["Stratis", _stratisArray]]] call TON_fnc_terrainSort;
- private _hideout = (nearestObjects[getPosATL player,_hideoutObjs,25]) select 0;
- if (!isNil "_hideout" && {!isNil {group player getVariable "gang_bank"}} && {(group player getVariable "gang_bank") >= _price}) then {
- _action = [
- 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>",
- [(group player getVariable "gang_bank")] call life_fnc_numberText,
- [CASH] call life_fnc_numberText
- ],
- localize "STR_Shop_Virt_YourorGang",
- localize "STR_Shop_Virt_UI_GangFunds",
- localize "STR_Shop_Virt_UI_YourCASH"
- ] call BIS_fnc_guiMessage;
- if (_action) then {
- hint parseText format [localize "STR_Shop_Weapon_BoughtGang",_itemInfo select 1,[_price] call life_fnc_numberText];
- _funds = group player getVariable "gang_bank";
- if(str(_shop) == "RebelDealer") then {
- _deduction = (_price * 0.1);
- _price = _price + _deduction;
- [_deduction] remoteExec ["TON_fnc_cartelWeapons",RSERV];
- };
- _funds = _funds - _price;
- group player setVariable ["gang_bank",_funds,true];
- [_item,true] spawn life_fnc_handleItem;
- if (life_HC_isActive) then {
- [1,group player] remoteExecCall ["HC_fnc_updateGang",HC_Life];
- } else {
- [1,group player] remoteExecCall ["TON_fnc_updateGang",RSERV];
- };
- } else {
- if (_price > CASH) exitWith {hint localize "STR_NOTF_NotEnoughMoney"};
- hint parseText format [localize "STR_Shop_Weapon_BoughtItem",_itemInfo select 1,[_price] call life_fnc_numberText];
- if(str(_shop) == "RebelDealer") then {
- _deduction = (_price * 0.1);
- _price = _price + _deduction;
- [_deduction] remoteExec ["TON_fnc_cartelWeapons",RSERV];
- };
- CASH = CASH - _price;
- [_item,true] spawn life_fnc_handleItem;
- };
- } else {
- if (_price > CASH) exitWith {hint localize "STR_NOTF_NotEnoughMoney"};
- hint parseText format [localize "STR_Shop_Weapon_BoughtItem",_itemInfo select 1,[_price] call life_fnc_numberText];
- if(str(_shop) == "RebelDealer") then {
- _deduction = (_price * 0.1);
- _price = _price + _deduction;
- [_deduction] remoteExec ["TON_fnc_cartelWeapons",RSERV];
- };
- CASH = CASH - _price;
- [_item,true] spawn life_fnc_handleItem;
- };
- };
- [0] call SOCK_fnc_updatePartial;
- [] call life_fnc_saveGear;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement