SHOW:
|
|
- or go back to the newest paste.
1 | #include "..\..\script_macros.hpp" | |
2 | /* | |
3 | File: fn_weaponShopSelection.sqf | |
4 | Author: Bryan "Tonic" Boardwine | |
5 | ||
6 | Description: | |
7 | Checks the weapon & adds the price tag. | |
8 | */ | |
9 | private ["_control","_index","_shop","_priceTag","_price","_item","_itemArray","_bool"]; | |
10 | _control = [_this,0,controlNull,[controlNull]] call BIS_fnc_param; | |
11 | _index = [_this,1,-1,[0]] call BIS_fnc_param; | |
12 | _shop = uiNamespace getVariable ["Weapon_Shop",""]; | |
13 | if (isNull _control) exitWith {closeDialog 0;}; //Bad data | |
14 | if (_index isEqualTo -1) exitWith {}; //Nothing selected | |
15 | ||
16 | _priceTag = CONTROL(38400,38404); | |
17 | ||
18 | if ((uiNamespace getVariable ["Weapon_Shop_Filter",0]) isEqualTo 1) then { | |
19 | _item = CONTROL_DATAI(_control,_index); | |
20 | _itemArray = M_CONFIG(getArray,"WeaponShops",_shop,"items"); | |
21 | _item = [_item,_itemArray] call TON_fnc_index; | |
22 | _price = ((_itemArray select _item) select 3); | |
23 | _priceTag ctrlSetStructuredText parseText format ["<t size='0.8'>Price: <t color='#8cff9b'>$%1</t></t>",[(_price)] call life_fnc_numberText]; | |
24 | _control lbSetValue[_index,_price]; | |
25 | } else { | |
26 | _price = _control lbValue _index; | |
27 | _item = CONTROL_DATAI(_control,_index); | |
28 | _rarityItem = ["weapons", _item] call stock_system_fnc_getRarityItem; | |
29 | _price = [_rarityItem, _price] call stock_system_fnc_getRarityItemPrice; | |
30 | if (_price > CASH) then { | |
31 | _priceTag ctrlSetStructuredText parseText format ["<t size='0.8'>Price: <t color='#ff0000'>$%1</t><br/>You lack: <t color='#8cff9b'>$%2</t></t>",[(_price)] call life_fnc_numberText,[(_price - CASH)] call life_fnc_numberText]; | |
32 | } else { | |
33 | - | _priceTag ctrlSetStructuredText parseText format ["<t size='0.8'>Price: <tcolor='#8cff9b'>$%1</t></t><br/><t size='0.8'>%2</t>",[(_price)] calllife_fnc_numberText, [_rarityItem, false] call stock_system_fnc_getDisplayedText]; |
33 | + | _priceTag ctrlSetStructuredText parseText format ["<t size='0.8'>Price: <tcolor='#8cff9b'>$%1</t></t><br/><t size='0.8'>%2</t>",[(_price)] call life_fnc_numberText, [_rarityItem, false] call stock_system_fnc_getDisplayedText]; |
34 | }; | |
35 | if ((uiNamespace getVariable ["Weapon_Magazine",0]) isEqualTo 0 && (uiNamespace getVariable ["Weapon_Accessories",0]) isEqualTo 0) then { | |
36 | if (isClass (configFile >> "CfgWeapons" >> _item)) then { | |
37 | //Magazines menu | |
38 | if (isArray (configFile >> "CfgWeapons" >> _item >> "magazines")) then { | |
39 | _itemArray = FETCH_CONFIG2(getArray,"CfgWeapons",_item,"magazines"); | |
40 | _bool = false; | |
41 | { | |
42 | _var = _x select 0; | |
43 | _count = {_x == _var} count _itemArray; | |
44 | if (_count > 0) exitWith {_bool = true}; | |
45 | } forEach M_CONFIG(getArray,"WeaponShops",_shop,"mags"); | |
46 | if (_bool) then { | |
47 | ((findDisplay 38400) displayCtrl 38406) ctrlEnable true; | |
48 | } else { | |
49 | ((findDisplay 38400) displayCtrl 38406) ctrlEnable false; | |
50 | }; | |
51 | } else { | |
52 | ((findDisplay 38400) displayCtrl 38406) ctrlEnable false; | |
53 | }; | |
54 | ||
55 | //Accessories Menu | |
56 | if (isClass (configFile >> "CfgWeapons" >> _item >> "WeaponSlotsInfo")) then { | |
57 | private ["_slotArray"]; | |
58 | _itemArray = []; | |
59 | if (isArray (configFile >> "CfgWeapons" >> _item >> "WeaponSlotsInfo" >> "CowsSlot" >> "compatibleItems")) then { | |
60 | _slotArray = FETCH_CONFIG3(getArray,"CfgWeapons",_item,"WeaponSlotsInfo","CowsSlot","compatibleItems"); | |
61 | { | |
62 | _itemArray pushBack _x; | |
63 | } forEach _slotArray; | |
64 | }; | |
65 | if (isArray (configFile >> "CfgWeapons" >> _item >> "WeaponSlotsInfo" >> "MuzzleSlot" >> "compatibleItems")) then { | |
66 | _slotArray = FETCH_CONFIG3(getArray,"CfgWeapons",_item,"WeaponSlotsInfo","MuzzleSlot","compatibleItems"); | |
67 | { | |
68 | _itemArray pushBack _x; | |
69 | } forEach _slotArray; | |
70 | }; | |
71 | if (isArray (configFile >> "CfgWeapons" >> _item >> "WeaponSlotsInfo" >> "PointerSlot" >> "compatibleItems")) then { | |
72 | _slotArray = FETCH_CONFIG3(getArray,"CfgWeapons",_item,"WeaponSlotsInfo","PointerSlot","compatibleItems"); | |
73 | { | |
74 | _itemArray pushBack _x; | |
75 | } forEach _slotArray; | |
76 | }; | |
77 | if (isArray (configFile >> "CfgWeapons" >> _item >> "WeaponSlotsInfo" >> "UnderBarrelSlot" >> "compatibleItems")) then { | |
78 | _slotArray = FETCH_CONFIG3(getArray,"CfgWeapons",_item,"WeaponSlotsInfo","UnderBarrelSlot","compatibleItems"); | |
79 | { | |
80 | _itemArray pushBack _x; | |
81 | } forEach _slotArray; | |
82 | }; | |
83 | ||
84 | _bool = false; | |
85 | { | |
86 | _var = _x select 0; | |
87 | _count = {_x == _var} count _itemArray; | |
88 | if (_count > 0) exitWith {_bool = true}; | |
89 | } forEach M_CONFIG(getArray,"WeaponShops",_shop,"accs"); | |
90 | if (_bool) then { | |
91 | ((findDisplay 38400) displayCtrl 38407) ctrlEnable true; | |
92 | } else { | |
93 | ((findDisplay 38400) displayCtrl 38407) ctrlEnable false; | |
94 | }; | |
95 | } else { | |
96 | ((findDisplay 38400) displayCtrl 38407) ctrlEnable false; | |
97 | }; | |
98 | } else { | |
99 | ((findDisplay 38400) displayCtrl 38406) ctrlEnable false; | |
100 | ((findDisplay 38400) displayCtrl 38407) ctrlEnable false; | |
101 | }; | |
102 | }; | |
103 | }; |