Advertisement
DarkSilencer

Untitled

Jan 17th, 2016
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.89 KB | None | 0 0
  1. #include "..\..\script_macros.hpp"
  2. /*
  3. File: fn_clothingMenu.sqf
  4. Author: Bryan "Tonic" Boardwine
  5. Description:
  6. Opens and initializes the clothing store menu.
  7. Started clean, finished messy.
  8. */
  9. private["_list","_clothes","_pic","_filter","_pos","_oldPos","_oldDir","_oldBev","_flag","_shopTitle","_license","_shopSide","_exit","_testLogic","_ut1","_ut2","_ut3","_ut4","_ut5","_light"];
  10. _exit = false;
  11. if(player != vehicle player) exitWith {titleText[localize "STR_NOTF_ActionInVehicle","PLAIN"];};
  12.  
  13. /* License check & config validation */
  14. if(!isClass(missionConfigFile >> "Clothing" >> (SEL(_this,3)))) exitWith {}; //Bad config entry.
  15. _shopTitle = M_CONFIG(getText,"Clothing",(SEL(_this,3)),"title");
  16. _shopSide = M_CONFIG(getText,"Clothing",(SEL(_this,3)),"side");
  17. _license = M_CONFIG(getText,"Clothing",(SEL(_this,3)),"license");
  18.  
  19. if(!(EQUAL(_license,""))) then {
  20. _flag = M_CONFIG(getText,"Licenses",_license,"side");
  21. if(!(LICENSE_VALUE(_license,_flag))) exitWith {hint localize "STR_Shop_Veh_NoLicense"; _exit = true;};
  22. };
  23. if(_exit) exitWith {};
  24.  
  25. _flag = switch(playerSide) do {case west: {"cop"}; case independent: {"med"}; default {"civ"};};
  26. if(!(EQUAL(_flag,_shopSide))) exitWith {};
  27.  
  28. ctrlSetText [3103,localize _shopTitle];
  29. /* Open up the menu */
  30. createDialog "Life_Clothing";
  31. disableSerialization;
  32.  
  33. (findDisplay 3100) displaySetEventHandler ["KeyDown","if((_this select 1) == 1) then {closeDialog 0; [] call life_fnc_playerSkins;}"]; //Fix Custom Skin after ESC
  34.  
  35. //Cop / Civ Pre Check
  36. if((SEL(_this,3) in ["bruce","dive","reb","kart"] && playerSide != civilian)) exitWith {hint localize "STR_Shop_NotaCiv"; closeDialog 0;};
  37. if((SEL(_this,3) == "reb" && !license_civ_rebel)) exitWith {hint localize "STR_Shop_NotaReb"; closeDialog 0;};
  38. if((SEL(_this,3) in ["cop"] && playerSide != west)) exitWith {hint localize "STR_Shop_NotaCop"; closeDialog 0;};
  39. if((SEL(_this,3) in ["dive"] && !license_civ_dive)) exitWith { hint localize "STR_Shop_NotaDive"; closeDialog 0;};
  40.  
  41. _pos = [1000,1000,10000];
  42. _oldDir = getDir player;
  43. _oldPos = visiblePositionASL player;
  44. _oldBev = behaviour player;
  45.  
  46. _testLogic = "Logic" createVehicleLocal _pos;
  47. _testLogic setPosATL _pos;
  48.  
  49. _ut1 = "UserTexture10m_F" createVehicleLocal (_testLogic modelToWorld [0,5,10]);
  50. _ut1 attachTo [_testLogic,[0,5,5]];
  51. _ut1 setDir 0;
  52. _ut4 = "UserTexture10m_F" createVehicleLocal (_testLogic modelToWorld [0,-5,10]);
  53. _ut4 attachTo [_testLogic,[0,-5,5]];
  54. _ut4 setDir 180;
  55. _ut2 = "UserTexture10m_F" createVehicleLocal (_testLogic modelToWorld [5,0,10]);
  56. _ut2 attachTo [_testLogic,[5,0,5]];
  57. _ut2 setDir (getDir _testLogic) + 90;
  58. _ut3 = "UserTexture10m_F" createVehicleLocal (_testLogic modelToWorld [-5,0,10]);
  59. _ut3 attachTo [_testLogic,[-5,0,5]];
  60. _ut3 setDir (getDir _testLogic) - 90;
  61. _ut5 = "UserTexture10m_F" createVehicleLocal (_testLogic modelToWorld [0,0,10]);
  62. _ut5 attachTo [_testLogic,[0,0,0]];
  63. _ut5 setObjectTexture [0,"a3\map_data\gdt_concrete_co.paa"];
  64. detach _ut5;
  65. _ut5 setVectorDirAndUp [[0,0,-.33],[0,.33,0]];
  66.  
  67. _light = "#lightpoint" createVehicleLocal _pos;
  68. _light setlightbrightness 0.5;
  69. _light setlightcolor [1,1,1];
  70. _light setlightambient [1,1,1];
  71. _light lightAttachObject [_testLogic, [0,0,0]];
  72.  
  73. {if(_x != player) then {_x hideObject true;};} foreach playableUnits;
  74.  
  75. {
  76. _x setObjectTexture [0,"#(argb,8,8,3)color(0,0,0,1)"];
  77. } foreach [_ut1,_ut2,_ut3,_ut4];
  78.  
  79. player setBehaviour "SAFE";
  80. player attachTo [_testLogic,[0,0,0]];
  81. player switchMove "";
  82.  
  83. life_clothing_store = SEL(_this,3);
  84.  
  85. /* Store license check */
  86. if(isClass(missionConfigFile >> "Licenses" >> life_clothing_store)) then {
  87. _flag = M_CONFIG(getText,"Licenses",life_clothing_store,"side");
  88. _displayName = M_CONFIG(getText,"Licenses",life_clothing_store,"displayName");
  89. if(!(LICENSE_VALUE(life_clothing_store,_flag))) exitWith {
  90. hint format[localize "STR_Shop_YouNeed",localize _displayName];
  91. closeDialog 0;
  92. };
  93. };
  94.  
  95. //initialize camera view
  96. life_shop_cam = "CAMERA" camCreate getPos player;
  97. showCinemaBorder false;
  98. life_shop_cam cameraEffect ["Internal", "Back"];
  99. life_shop_cam camSetTarget (player modelToWorld [0,0,1]);
  100. life_shop_cam camSetPos (player modelToWorld [1,4,2]);
  101. life_shop_cam camSetFOV .33;
  102. life_shop_cam camSetFocus [50, 0];
  103. life_shop_cam camCommit 0;
  104. life_cMenu_lock = false;
  105.  
  106. if(isNull (findDisplay 3100)) exitWith {};
  107. _list = (findDisplay 3100) displayCtrl 3101;
  108. _filter = (findDisplay 3100) displayCtrl 3105;
  109. lbClear _filter;
  110. lbClear _list;
  111.  
  112. _filter lbAdd localize "STR_Shop_UI_Clothing";
  113. _filter lbAdd localize "STR_Shop_UI_Hats";
  114. _filter lbAdd localize "STR_Shop_UI_Glasses";
  115. _filter lbAdd localize "STR_Shop_UI_Vests";
  116. _filter lbAdd localize "STR_Shop_UI_Backpack";
  117.  
  118. _filter lbSetCurSel 0;
  119.  
  120. life_oldClothes = uniform player;
  121. life_olduniformItems = uniformItems player;
  122. life_oldBackpack = backpack player;
  123. life_oldVest = vest player;
  124. life_oldVestItems = vestItems player;
  125. life_oldBackpackItems = backpackItems player;
  126. life_oldGlasses = goggles player;
  127. life_oldHat = headgear player;
  128.  
  129. [] call life_fnc_playerSkins;
  130.  
  131. waitUntil {isNull (findDisplay 3100)};
  132. {if(_x != player) then {_x hideObject false;};} foreach playableUnits;
  133. detach player;
  134. player setBehaviour _oldBev;
  135. player setPosASL _oldPos;
  136. player setDir _oldDir;
  137. {deleteVehicle _x;} foreach [_testLogic,_ut1,_ut2,_ut3,_ut4,_ut5,_light];
  138. life_shop_cam cameraEffect ["TERMINATE","BACK"];
  139. camDestroy life_shop_cam;
  140. life_clothing_filter = 0;
  141. if(isNil "life_clothesPurchased") exitWith {
  142. life_clothing_purchase = [-1,-1,-1,-1,-1];
  143. if(life_oldClothes != "") then {player addUniform life_oldClothes;} else {removeUniform player};
  144. if(life_oldHat != "") then {player addHeadgear life_oldHat} else {removeHeadgear player;};
  145. if(life_oldGlasses != "") then {player addGoggles life_oldGlasses;} else {removeGoggles player};
  146. if(backpack player != "") then {
  147. if(life_oldBackpack == "") then {
  148. removeBackpack player;
  149. } else {
  150. removeBackpack player;
  151. player addBackpack life_oldBackpack;
  152. clearAllItemsFromBackpack player;
  153. if(count life_oldBackpackItems > 0) then {
  154. {
  155. [_x,true,true] call life_fnc_handleItem;
  156. } foreach life_oldBackpackItems;
  157. };
  158. };
  159. };
  160.  
  161. if(count life_oldUniformItems > 0) then {
  162. {[_x,true,false,false,true] call life_fnc_handleItem;} foreach life_oldUniformItems;
  163. };
  164.  
  165. if(vest player != "") then {
  166. if(life_oldVest == "") then {
  167. removeVest player;
  168. } else {
  169. player addVest life_oldVest;
  170. if(count life_oldVestItems > 0) then {
  171. {[_x,true,false,false,true] call life_fnc_handleItem;} foreach life_oldVestItems;
  172. };
  173. };
  174. };
  175. [] call life_fnc_playerSkins;
  176. };
  177. life_clothesPurchased = nil;
  178.  
  179. //Check uniform purchase.
  180. if((life_clothing_purchase select 0) == -1) then {
  181. if(life_oldClothes != uniform player) then {player addUniform life_oldClothes;};
  182. };
  183. //Check hat
  184. if((life_clothing_purchase select 1) == -1) then {
  185. if(life_oldHat != headgear player) then {if(life_oldHat == "") then {removeHeadGear player;} else {player addHeadGear life_oldHat;};};
  186. };
  187. //Check glasses
  188. if((life_clothing_purchase select 2) == -1) then {
  189. if(life_oldGlasses != goggles player) then {
  190. if(life_oldGlasses == "") then {
  191. removeGoggles player;
  192. } else {
  193. player addGoggles life_oldGlasses;
  194. };
  195. };
  196. };
  197. //Check Vest
  198. if((life_clothing_purchase select 3) == -1) then {
  199. if(life_oldVest != vest player) then {
  200. if(life_oldVest == "") then {removeVest player;} else {
  201. player addVest life_oldVest;
  202. {[_x,true,false,false,true] call life_fnc_handleItem;} foreach life_oldVestItems;
  203. };
  204. };
  205. };
  206.  
  207. //Check Backpack
  208. if((life_clothing_purchase select 4) == -1) then {
  209. if(life_oldBackpack != backpack player) then {
  210. if(life_oldBackpack == "") then {removeBackpack player;} else {
  211. removeBackpack player;
  212. player addBackpack life_oldBackpack;
  213. {[_x,true,true] call life_fnc_handleItem;} foreach life_oldBackpackItems;
  214. };
  215. };
  216. };
  217.  
  218. life_clothing_purchase = [-1,-1,-1,-1,-1];
  219. [] call life_fnc_saveGear;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement