Advertisement
Guest User

other

a guest
Aug 6th, 2017
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.53 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. private _vaultHouse = [[["Altis", "Land_Research_house_V1_F"], ["Tanoa", "Land_Medevac_house_V1_F"]]] call TON_fnc_terrainSort;
  65. private _altisArray = [16019.5,16952.9,0];
  66. private _tanoaArray = [11074.2,11501.5,0.00137329];
  67. private _pos = [[["Altis", _altisArray], ["Tanoa", _tanoaArray]]] call TON_fnc_terrainSort;
  68.  
  69. if (_curObject isKindOf "House_F" && {player distance _curObject < 12} || ((nearestObject [_pos,"Land_Dome_Big_F"]) isEqualTo _curObject || (nearestObject [_pos,_vaultHouse]) isEqualTo _curObject)) exitWith {
  70. [_curObject] call life_fnc_houseMenu;
  71. };
  72.  
  73. if (dialog) exitWith {}; //Don't bother when a dialog is open.
  74. if !(isNull objectParent player) exitWith {}; //He's in a vehicle, cancel!
  75. life_action_inUse = true;
  76.  
  77. //Temp fail safe.
  78. [] spawn {
  79. sleep 60;
  80. life_action_inUse = false;
  81. };
  82.  
  83. //Check if it's a dead body.
  84. if (_curObject isKindOf "Man" && !(_curObject isKindOf "Animal") && {!alive _curObject} && !(_curObject getVariable ["Revive",false])) exitWith {
  85. //Hotfix code by ins0
  86. if ((playerSide isEqualTo west && {(LIFE_SETTINGS(getNumber,"revive_cops") isEqualTo 1)}) || {(playerSide isEqualTo civilian && {(LIFE_SETTINGS(getNumber,"revive_civ") isEqualTo 1)})} || {(playerSide isEqualTo east && {(LIFE_SETTINGS(getNumber,"revive_east") isEqualTo 1)})} || {playerSide isEqualTo independent}) then {
  87. if (life_inv_defibrillator > 0) then {
  88. [_curObject] call life_fnc_revivePlayer;
  89. };
  90. };
  91. };
  92.  
  93. //If target is a player then check if we can use the cop menu.
  94. if (isPlayer _curObject && _curObject isKindOf "Man") then {
  95. if ((_curObject getVariable ["restrained",false]) && !dialog && playerSide isEqualTo west) then {
  96. [_curObject] call life_fnc_copInteractionMenu;
  97. };
  98. } else {
  99. //OK, it wasn't a player so what is it?
  100. private ["_isVehicle","_miscItems","_money","_list"];
  101.  
  102. _list = ["landVehicle","Ship","Air"];
  103. _isVehicle = if (KINDOF_ARRAY(_curObject,_list)) then {true} else {false};
  104. _miscItems = ["Land_BottlePlastic_V1_F","Land_TacticalBacon_F","Land_Can_V3_F","Land_CanisterFuel_F","Land_Suitcase_F"];
  105.  
  106. //It's a vehicle! open the vehicle interaction key!
  107. if (_isVehicle) then {
  108. if (!dialog) then {
  109. if (player distance _curObject < ((boundingBox _curObject select 1) select 0)+2 && (!(player getVariable ["restrained",false])) && (!(player getVariable ["playerSurrender",false])) && !life_isknocked && !life_istazed) then {
  110. [_curObject] call life_fnc_vInteractionMenu;
  111. };
  112. };
  113. } else {
  114. //OK, it wasn't a vehicle so let's see what else it could be?
  115. if ((typeOf _curObject) in _miscItems) then {
  116. [_curObject,player,false] remoteExecCall ["TON_fnc_pickupAction",RSERV];
  117. } else {
  118. //It wasn't a misc item so is it money?
  119. if ((typeOf _curObject) isEqualTo "Land_Money_F" && {!(_curObject getVariable ["inUse",false])}) then {
  120. [_curObject,player,true] remoteExecCall ["TON_fnc_pickupAction",RSERV];
  121. };
  122. };
  123. };
  124. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement