Advertisement
Guest User

Untitled

a guest
Dec 9th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.52 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.             if (LIFE_SETTINGS(getNumber,"enable_fatigue") isEqualTo 1) then {player setFatigue 0;};
  19.             if (_item isEqualTo "redgull" && {LIFE_SETTINGS(getNumber,"enable_fatigue") isEqualTo 1}) then {
  20.                 [] spawn {
  21.                     life_redgull_effect = time;
  22.                     titleText[localize "STR_ISTR_RedGullEffect","PLAIN"];
  23.                     player enableFatigue false;
  24.                     waitUntil {!alive player || ((time - life_redgull_effect) > (3 * 60))};
  25.                     player enableFatigue true;
  26.                 };
  27.             };
  28.         };
  29.     };
  30.  
  31.     case (_item isEqualTo "boltcutter"): {
  32.         [cursorObject] spawn life_fnc_boltcutter;
  33.         closeDialog 0;
  34.     };
  35.  
  36.     case (_item isEqualTo "blastingcharge"): {
  37.         player reveal fed_bank;
  38.         (group player) reveal fed_bank;
  39.         [cursorObject] spawn life_fnc_blastingCharge;
  40.         closeDialog 0;
  41.     };
  42.  
  43.     case (_item isEqualTo "defusekit"): {
  44.         [cursorObject] spawn life_fnc_defuseKit;
  45.         closeDialog 0;
  46.     };
  47.  
  48.     case (_item isEqualTo "storagesmall"): {
  49.         [false] call life_fnc_storageBox;
  50.     };
  51.  
  52.     case (_item isEqualTo "storagebig"): {
  53.         [true] call life_fnc_storageBox;
  54.     };
  55.  
  56.     case (_item isEqualTo "spikeStrip"): {
  57.         if (!isNull life_spikestrip) exitWith {hint localize "STR_ISTR_SpikesDeployment"; closeDialog 0};
  58.         if ([false,_item,1] call life_fnc_handleInv) then {
  59.             [] spawn life_fnc_spikeStrip;
  60.             closeDialog 0;
  61.         };
  62.     };
  63.  
  64.     case (_item isEqualTo "fuelFull"): {
  65.         if !(isNull objectParent player) exitWith {hint localize "STR_ISTR_RefuelInVehicle"};
  66.         [] spawn life_fnc_jerryRefuel;
  67.         closeDialog 0;
  68.     };
  69.  
  70.     case (_item isEqualTo "fuelEmpty"): {
  71.         [] spawn life_fnc_jerryCanRefuel;
  72.         closeDialog 0;
  73.     };
  74.  
  75.     case (_item isEqualTo "lockpick"): {
  76.         [] spawn life_fnc_lockpick;
  77.         closeDialog 0;
  78.     };
  79.  
  80.     case (_item in ["apple","rabbit","salema","ornate","mackerel","tuna","mullet","catshark","turtle_soup","hen","rooster","sheep","goat","donuts","tbacon","peach"]): {
  81.         if (!(M_CONFIG(getNumber,"VirtualItems",_item,"edible") isEqualTo -1)) then {
  82.             if ([false,_item,1] call life_fnc_handleInv) then {
  83.                 _val = M_CONFIG(getNumber,"VirtualItems",_item,"edible");
  84.                 _sum = life_hunger + _val;
  85.                 #include "..\..\The-Programmer\Plants\scripts\useItemSelect.sqf"
  86.                 switch (true) do {
  87.                     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
  88.                     case (_sum > 100): {life_hunger = 100;};
  89.                     default {life_hunger = _sum;};
  90.                 };
  91.             };
  92.         };
  93.     };
  94.  
  95.     default {
  96.         hint localize "STR_ISTR_NotUsable";
  97.     };
  98. };
  99.  
  100. [] call life_fnc_p_updateMenu;
  101. [] call life_fnc_hudUpdate;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement