Guest User

Untitled

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