Advertisement
DubStepMad

Untitled

May 1st, 2017
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.09 KB | None | 0 0
  1. #include "..\..\script_macros.hpp"
  2. /*
  3. File: fn_actionKeyHandler.sqf
  4. Author: Bryan "Tonic" Boardwine
  5.  
  6. Description:
  7. Master action key handler, handles requests for picking up various items and
  8. interacting with other players (Cops = Cop Menu for unrestrain,escort,stop escort, arrest (if near cop hq), etc).
  9. */
  10. private["_curObject","_isWater","_CrateModelNames","_crate","_fish","_animal","_whatIsIt","_handle"];
  11. _curObject = cursorObject;
  12. if (life_action_inUse) exitWith {}; //Action is in use, exit to prevent spamming.
  13. if (life_interrupted) exitWith {life_interrupted = false;};
  14. _isWater = surfaceIsWater (visiblePositionASL player);
  15.  
  16. if playerSide isEqualTo west && (player getVariable["isEscorting",false]) exitWith {
  17. [] call life_fnc_copInteractionMenu;
  18. };
  19.  
  20. if (LIFE_SETTINGS(getNumber,"global_ATM") isEqualTo 1) then{
  21. //Check if the player is near an ATM.
  22. if ((call life_fnc_nearATM) && {!dialog}) exitWith {
  23. [] call life_fnc_atmMenu;
  24. };
  25. };
  26.  
  27. if (isNull _curObject) exitWith {
  28. if (_isWater) then {
  29. _fish = (nearestObjects[player,(LIFE_SETTINGS(getArray,"animaltypes_fish")),3]) select 0;
  30. if (!isNil "_fish") then {
  31. if (!alive _fish) then {
  32. [_fish] call life_fnc_catchFish;
  33. };
  34. };
  35. } else {
  36. _animal = (nearestObjects[player,(LIFE_SETTINGS(getArray,"animaltypes_hunting")),3]) select 0;
  37. if (!isNil "_animal") then {
  38. if (!alive _animal) then {
  39. [_animal] call life_fnc_gutAnimal;
  40. };
  41. } else {
  42. private "_handle";
  43. if (playerSide isEqualTo civilian && !life_action_gathering) then {
  44. _whatIsIt = [] call life_fnc_whereAmI;
  45. if (life_action_gathering) exitWith {}; //Action is in use, exit to prevent spamming.
  46. switch (_whatIsIt) do {
  47. case "mine" : { _handle = [] spawn life_fnc_mine };
  48. default { _handle = [] spawn life_fnc_gather };
  49. };
  50. life_action_gathering = true;
  51. waitUntil {scriptDone _handle};
  52. life_action_gathering = false;
  53. };
  54. };
  55. };
  56. };
  57.  
  58. if ((_curObject isKindOf "B_supplyCrate_F" || _curObject isKindOf "Box_IND_Grenades_F") && {player distance _curObject < 3} ) exitWith {
  59. if (alive _curObject) then {
  60. [_curObject] call life_fnc_containerMenu;
  61. };
  62. };
  63.  
  64. if (_curObject isKindOf "House_F" && {player distance _curObject < 12} || ((nearestObject [[16019.5,16952.9,0],"Land_Dome_Big_F"]) == _curObject || (nearestObject [[16019.5,16952.9,0],"Land_Research_house_V1_F"]) == _curObject)) exitWith {
  65. [_curObject] call life_fnc_houseMenu;
  66. };
  67.  
  68. if (dialog) exitWith {}; //Don't bother when a dialog is open.
  69. if (vehicle player != player) exitWith {}; //He's in a vehicle, cancel!
  70. life_action_inUse = true;
  71.  
  72. //Temp fail safe.
  73. [] spawn {
  74. sleep 60;
  75. life_action_inUse = false;
  76. };
  77.  
  78. //Check if it's a dead body.
  79. if (_curObject isKindOf "Man" && !(_curObject isKindOf "Animal") && {!alive _curObject} && !(_curObject getVariable["Revive",false]) && {playerSide in [west,independent]}) exitWith {
  80. //Hotfix code by ins0
  81. if (((playerSide isEqualTo west && {(LIFE_SETTINGS(getNumber,"revive_cops") isEqualTo 1)}) || playerSide isEqualTo independent)) then {
  82. if (life_inv_defibrillator > 0) then {
  83. [_curObject] call life_fnc_revivePlayer;
  84. };
  85. };
  86. };
  87.  
  88. //If target is a player then check if we can use the cop menu.
  89. if (isPlayer _curObject && _curObject isKindOf "Man") then {
  90. if ((_curObject getVariable ["restrained",false]) && !dialog && playerSide isEqualTo west) then {
  91. [_curObject] call life_fnc_copInteractionMenu;
  92. };
  93. } else {
  94. //OK, it wasn't a player so what is it?
  95. private["_isVehicle","_miscItems","_money","_list"];
  96.  
  97. _list = ["landVehicle","Ship","Air"];
  98. _isVehicle = if (KINDOF_ARRAY(_curObject,_list)) then {true} else {false};
  99. _miscItems = ["Land_BottlePlastic_V1_F","Land_TacticalBacon_F","Land_Can_V3_F","Land_CanisterFuel_F","Land_Suitcase_F"];
  100.  
  101. //It's a vehicle! open the vehicle interaction key!
  102. if (_isVehicle) then {
  103. if (!dialog) then {
  104. if (player distance _curObject < ((boundingBox _curObject select 1) select 0)+2 && (!(player getVariable ["restrained",false])) && (!(player getVariable ["playerSurrender",false])) && !life_isknocked && !life_istazed) then {
  105. [_curObject] call life_fnc_vInteractionMenu;
  106. };
  107. };
  108. } else {
  109. //OK, it wasn't a vehicle so let's see what else it could be?
  110. if ((typeOf _curObject) in _miscItems) then {
  111. [_curObject,player,false] remoteExecCall ["TON_fnc_pickupAction",RSERV];
  112. } else {
  113. //It wasn't a misc item so is it money?
  114. if ((typeOf _curObject) isEqualTo "Land_Money_F" && {!(_curObject getVariable ["inUse",false])}) then {
  115. [_curObject,player,true] remoteExecCall ["TON_fnc_pickupAction",RSERV];
  116. };
  117. };
  118. };
  119. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement