Advertisement
Guest User

Untitled

a guest
Nov 19th, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.36 KB | None | 0 0
  1. #include "..\..\script_macros.hpp"
  2. /*
  3. File: fn_useItem.sqf
  4. Author: Bryan "Tonic" Boardwine
  5.  
  6. Description:
  7. Main function for item effects and functionality through the player menu.
  8. */
  9. private "_item";
  10. disableSerialization;
  11. if ((lbCurSel 2005) isEqualTo -1) exitWith {hint localize "STR_ISTR_SelectItemFirst";};
  12. _item = CONTROL_DATA(2005);
  13.  
  14. switch (true) do {
  15. case (_item in ["waterBottle","coffee","redgull"]): {
  16. if ([false,_item,1] call life_fnc_handleInv) then {
  17. life_thirst = 100;
  18. life_drink = life_drink - 0.02;
  19. if (LIFE_SETTINGS(getNumber,"enable_fatigue") isEqualTo 1) then {player setFatigue 0;};
  20. if (_item isEqualTo "redgull" && {LIFE_SETTINGS(getNumber,"enable_fatigue") isEqualTo 1}) then {
  21. [] spawn {
  22. life_redgull_effect = time;
  23. titleText[localize "STR_ISTR_RedGullEffect","PLAIN"];
  24. player enableFatigue false;
  25. waitUntil {!alive player || ((time - life_redgull_effect) > (3 * 60))};
  26. player enableFatigue true;
  27. };
  28. };
  29. };
  30. };
  31.  
  32. case (_item isEqualTo "boltcutter"): {
  33. [cursorObject] spawn life_fnc_boltcutter;
  34. closeDialog 0;
  35. };
  36.  
  37. case (_item isEqualTo "blastingcharge"): {
  38. player reveal fed_bank;
  39. (group player) reveal fed_bank;
  40. [cursorObject] spawn life_fnc_blastingCharge;
  41. closeDialog 0;
  42. };
  43.  
  44. case (_item isEqualTo "defusekit"): {
  45. [cursorObject] spawn life_fnc_defuseKit;
  46. closeDialog 0;
  47. };
  48.  
  49. case (_item isEqualTo "storagesmall"): {
  50. [false] call life_fnc_storageBox;
  51. };
  52.  
  53. case (_item isEqualTo "storagebig"): {
  54. [true] call life_fnc_storageBox;
  55. };
  56.  
  57. case (_item isEqualTo "spikeStrip"): {
  58. if (!isNull life_spikestrip) exitWith {hint localize "STR_ISTR_SpikesDeployment"; closeDialog 0};
  59. if ([false,_item,1] call life_fnc_handleInv) then {
  60. [] spawn life_fnc_spikeStrip;
  61. closeDialog 0;
  62. };
  63. };
  64.  
  65. case (_item isEqualTo "gpstracker"): {
  66. [cursorTarget] spawn life_fnc_gpsTracker;
  67. };
  68.  
  69. case (_item isEqualTo "scalpel"): {
  70. closeDialog 0; titleText["Cet objet sert a prelever les organes, menottez votre victime avant de pouvoir l'utiliser !","PLAIN"];
  71. };
  72.  
  73. case (_item isEqualTo "kidney"): {
  74. if(([false,_item,1] call life_fnc_handleInv)) then
  75. {
  76. player setVariable["missingOrgan",false,true];
  77. life_thirst = 100;
  78. life_hunger = 100;
  79. player setFatigue .5;
  80. };
  81. };
  82.  
  83. case (_item isEqualTo "cigarette"):
  84. {
  85. if(([false,_item,1] call life_fnc_handleInv)) then
  86. {
  87. [] spawn life_fnc_cigarette;
  88. };
  89. };
  90.  
  91. case (_item isEqualTo "marijuana"):
  92. {
  93. if((player getVariable ["Druged",FALSE])) exitWith {hint "Vous consommez deja de la drogue";};
  94. if(([false,_item,1] call life_fnc_handleInv)) then
  95. {
  96. if(isNil "life_drug") then {life_drug = 0;};
  97. life_drug = life_drug + 0.05;
  98. if (life_drug < 0.00) exitWith {};
  99. [] spawn life_fnc_weed;
  100. };
  101. };
  102.  
  103. case (_item isEqualTo "cocaine_processed"):
  104. {
  105. if((player getVariable ["Druged",FALSE])) exitWith {hint "Vous consommez deja de la drogue";};
  106. if(([false,_item,1] call life_fnc_handleInv)) then
  107. {
  108. if(isNil "life_drug") then {life_drug = 0;};
  109. life_drug = life_drug + 0.07;
  110. if (life_drug < 0.00) exitWith {};
  111. [] spawn life_fnc_cocaine;
  112. };
  113. };
  114.  
  115. case (_item isEqualTo "Methp"):
  116. {
  117. if((player getVariable ["Druged",FALSE])) exitWith {hint "Vous consommez deja de la drogue";};
  118. if(([false,_item,1] call life_fnc_handleInv)) then
  119. {
  120. if(isNil "life_drug") then {life_drug = 0;};
  121. life_drug = life_drug + 0.09;
  122. if (life_drug < 0.00) exitWith {};
  123. [] spawn life_fnc_meth;
  124. };
  125. };
  126.  
  127. case (_item isEqualTo "opium_3"):
  128. {
  129. if((player getVariable ["Druged",FALSE])) exitWith {hint "Vous consommez deja de la drogue";};
  130. if(([false,_item,1] call life_fnc_handleInv)) then
  131. {
  132. if(isNil "life_drug") then {life_drug = 0;};
  133. life_drug = life_drug + 0.09;
  134. if (life_drug < 0.00) exitWith {};
  135. [] spawn life_fnc_opium;
  136. };
  137. };
  138.  
  139. //Alcool
  140.  
  141. case (_item isEqualTo "vin"):
  142. {
  143. if((player getVariable ["inDrink",FALSE])) exitWith {hint "Vous etes deja en train de boire";};
  144. if(([false,_item,1] call life_fnc_handleInv)) then
  145. {
  146. if(isNil "life_drink") then {life_drink = 0;};
  147. life_drink = life_drink + 0.05;
  148. if (life_drink < 0.06) exitWith {};
  149. [] spawn life_fnc_vin;
  150. };
  151. };
  152.  
  153. case (_item isEqualTo "drinkvin"):
  154. {
  155. if((player getVariable ["inDrink",FALSE])) exitWith {hint "Vous etes deja en train de boire";};
  156. if(([false,_item,1] call life_fnc_handleInv)) then
  157. {
  158. if(isNil "life_drink") then {life_drink = 0;};
  159. life_drink = life_drink + 0.05;
  160. if (life_drink < 0.06) exitWith {};
  161. [] spawn life_fnc_drinkvin;
  162. };
  163. };
  164.  
  165. case (_item isEqualTo "drinkvodka"):
  166. {
  167. if((player getVariable ["inDrink",FALSE])) exitWith {hint "Vous etes deja en train de boire";};
  168. if(([false,_item,1] call life_fnc_handleInv)) then
  169. {
  170. if(isNil "life_drink") then {life_drink = 0;};
  171. life_drink = life_drink + 0.09;
  172. if (life_drink < 0.10) exitWith {};
  173. [] spawn life_fnc_drinkvodka;
  174. };
  175. };
  176.  
  177. case (_item isEqualTo "drinkbiere"):
  178. {
  179. if((player getVariable ["inDrink",FALSE])) exitWith {hint "Vous etes deja en train de boire";};
  180. if(([false,_item,1] call life_fnc_handleInv)) then
  181. {
  182. if(isNil "life_drink") then {life_drink = 0;};
  183. life_drink = life_drink + 0.03;
  184. if (life_drink < 0.06) exitWith {};
  185. [] spawn life_fnc_drinkbiere;
  186. };
  187. };
  188.  
  189. case (_item isEqualTo "drinkwhisky"):
  190. {
  191. if((player getVariable ["inDrink",FALSE])) exitWith {hint "Vous etes deja en train de boire";};
  192. if(([false,_item,1] call life_fnc_handleInv)) then
  193. {
  194. if(isNil "life_drink") then {life_drink = 0;};
  195. life_drink = life_drink + 0.10;
  196. if (life_drink < 0.11) exitWith {};
  197. [] spawn life_fnc_drinkwhisky;
  198. };
  199. };
  200.  
  201. case (_item isEqualTo "fuelFull"): {
  202. if (vehicle player != player) exitWith {hint localize "STR_ISTR_RefuelInVehicle"};
  203. [] spawn life_fnc_jerryRefuel;
  204. closeDialog 0;
  205. };
  206.  
  207. case (_item isEqualTo "fuelEmpty"): {
  208. [] spawn life_fnc_jerryCanRefuel;
  209. closeDialog 0;
  210. };
  211.  
  212. case (_item isEqualTo "lockpick"): {
  213. [] spawn life_fnc_lockpick;
  214. closeDialog 0;
  215. };
  216.  
  217. case (_item isEqualTo "morphine"): {
  218. if(([false,_item,1] call life_fnc_handleInv)) then
  219. {
  220. [] spawn life_fnc_morphine;
  221. };
  222. };
  223.  
  224. //Carte de crédit
  225.  
  226. case (_item isEqualTo "credit_1"):
  227. {
  228. if(([false,_item,1] call life_fnc_handleInv)) then
  229. {
  230. [] spawn life_fnc_credit_1;
  231. closeDialog 0;
  232. };
  233. };
  234.  
  235. case (_item isEqualTo "credit_2"):
  236. {
  237. if(([false,_item,1] call life_fnc_handleInv)) then
  238. {
  239. [] spawn life_fnc_credit_2;
  240. closeDialog 0;
  241. };
  242. };
  243.  
  244. case (_item isEqualTo "credit_3"):
  245. {
  246. if(([false,_item,1] call life_fnc_handleInv)) then
  247. {
  248. [] spawn life_fnc_credit_3;
  249. closeDialog 0;
  250. };
  251. };
  252.  
  253. case (_item isEqualTo "credit_4"):
  254. {
  255. if(([false,_item,1] call life_fnc_handleInv)) then
  256. {
  257. [] spawn life_fnc_credit_4;
  258. closeDialog 0;
  259. };
  260. };
  261.  
  262. case (_item isEqualTo "credit_5"):
  263. {
  264. if(([false,_item,1] call life_fnc_handleInv)) then
  265. {
  266. [] spawn life_fnc_credit_5;
  267. closeDialog 0;
  268. };
  269. };
  270.  
  271. case (_item isEqualTo "credit_6"):
  272. {
  273. if(([false,_item,1] call life_fnc_handleInv)) then
  274. {
  275. [] spawn life_fnc_credit_6;
  276. closeDialog 0;
  277. };
  278. };
  279.  
  280. case (_item isEqualTo "credit_7"):
  281. {
  282. if(([false,_item,1] call life_fnc_handleInv)) then
  283. {
  284. [] spawn life_fnc_credit_7;
  285. closeDialog 0;
  286. };
  287. };
  288.  
  289. case (_item isEqualTo "credit_8"):
  290. {
  291. if(([false,_item,1] call life_fnc_handleInv)) then
  292. {
  293. [] spawn life_fnc_credit_8;
  294. closeDialog 0;
  295. };
  296. };
  297.  
  298. case (_item isEqualTo "credit_9"):
  299. {
  300. if(([false,_item,1] call life_fnc_handleInv)) then
  301. {
  302. [] spawn life_fnc_credit_9;
  303. closeDialog 0;
  304. };
  305. };
  306.  
  307. case (_item isEqualTo "credit_10"):
  308. {
  309. if(([false,_item,1] call life_fnc_handleInv)) then
  310. {
  311. [] spawn life_fnc_credit_10;
  312. closeDialog 0;
  313. };
  314. };
  315.  
  316. case (_item in ["apple","rabbit","salema","ornate","mackerel","tuna","mullet","catshark","turtle_soup","hen","rooster","sheep","goat","donuts","tbacon","peach"]): {
  317. if (!(M_CONFIG(getNumber,"VirtualItems",_item,"edible") isEqualTo -1)) then {
  318. if ([false,_item,1] call life_fnc_handleInv) then {
  319. _val = M_CONFIG(getNumber,"VirtualItems",_item,"edible");
  320. _sum = life_hunger + _val;
  321. switch (true) do {
  322. case (_val < 0 && _sum < 1): {life_hunger = 5;}; //This adds the ability to set the entry edible to a negative value and decrease the hunger without death
  323. case (_sum > 100): {life_hunger = 100;};
  324. default {life_hunger = _sum;};
  325. };
  326. };
  327. };
  328. };
  329.  
  330. default {
  331. hint localize "STR_ISTR_NotUsable";
  332. };
  333. };
  334.  
  335. [] call life_fnc_p_updateMenu;
  336. [] call life_fnc_hudUpdate;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement