Advertisement
Guest User

Untitled

a guest
Jun 27th, 2017
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 5.88 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. if (playerSide isEqualTo civilian && {player getVariable ["isEscorting",false]} && (!(_curObject getVariable ["restrained",false]))) exitWith {
  20.     [] call life_fnc_copInteractionMenu;
  21. };
  22.  
  23. if (LIFE_SETTINGS(getNumber,"global_ATM") isEqualTo 1) then{
  24.     //Check if the player is near an ATM.
  25.     if ((call life_fnc_nearATM) && {!dialog}) exitWith {
  26.         [] call life_fnc_atmMenu;
  27.     };
  28. };
  29.  
  30. if (isNull _curObject) exitWith {
  31.     if (_isWater) then {
  32.         _fish = (nearestObjects[player,(LIFE_SETTINGS(getArray,"animaltypes_fish")),3]) select 0;
  33.         if (!isNil "_fish") then {
  34.             if (!alive _fish) then {
  35.                 [_fish] call life_fnc_catchFish;
  36.             };
  37.         };
  38.     } else {
  39.         _animal = (nearestObjects[player,(LIFE_SETTINGS(getArray,"animaltypes_hunting")),3]) select 0;
  40.         if (!isNil "_animal") then {
  41.             if (!alive _animal) then {
  42.                 [_animal] call life_fnc_gutAnimal;
  43.             };
  44.         } else {
  45.             private "_handle";
  46.             if (playerSide isEqualTo civilian && !life_action_gathering) then {
  47.           _whatIsIt = [] call life_fnc_whereAmI;
  48.                 if (life_action_gathering) exitWith {};                 //Action is in use, exit to prevent spamming.
  49.                 switch (_whatIsIt) do {
  50.                     case "mine" : { _handle = [] spawn life_fnc_mine };
  51.                     default { _handle = [] spawn life_fnc_gather };
  52.                 };
  53.                 life_action_gathering = true;
  54.                 waitUntil {scriptDone _handle};
  55.                 life_action_gathering = false;
  56.             };
  57.         };
  58.     };
  59. };
  60.  
  61. if ((_curObject isKindOf "B_supplyCrate_F" || _curObject isKindOf "Box_IND_Grenades_F") && {player distance _curObject < 3} ) exitWith {
  62.     if (alive _curObject) then {
  63.         [_curObject] call life_fnc_containerMenu;
  64.     };
  65. };
  66.  
  67. private _vaultHouse = [[["Altis", "Land_Research_house_V1_F"], ["Tanoa", "Land_Medevac_house_V1_F"]]] call TON_fnc_terrainSort;
  68. private _altisArray = [16019.5,16952.9,0];
  69. private _tanoaArray = [11074.2,11501.5,0.00137329];
  70. private _pos = [[["Altis", _altisArray], ["Tanoa", _tanoaArray]]] call TON_fnc_terrainSort;
  71.  
  72. if (_curObject isKindOf "House_F" && {player distance _curObject < 12} || ((nearestObject [_pos,"Land_Dome_Big_F"]) isEqualTo _curObject || (nearestObject [_pos,_vaultHouse]) isEqualTo _curObject)) exitWith {
  73.     [_curObject] call life_fnc_houseMenu;
  74. };
  75.  
  76. if (dialog) exitWith {}; //Don't bother when a dialog is open.
  77. if !(isNull objectParent player) exitWith {}; //He's in a vehicle, cancel!
  78. life_action_inUse = true;
  79.  
  80. //Temp fail safe.
  81. [] spawn {
  82.     sleep 60;
  83.     life_action_inUse = false;
  84. };
  85.  
  86. //Check if it's a dead body.
  87. if (_curObject isKindOf "Man" && !(_curObject isKindOf "Animal") && {!alive _curObject} && !(_curObject getVariable ["Revive",false])) exitWith {
  88.     //Hotfix code by ins0
  89.     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 {
  90.         if (life_inv_defibrillator > 0) then {
  91.             [_curObject] call life_fnc_revivePlayer;
  92.         };
  93.     };
  94. };
  95.  
  96. //If target is a player then check if we can use the cop menu.
  97. if (isPlayer _curObject && _curObject isKindOf "Man") then {
  98.     if ((_curObject getVariable ["restrained",false]) && !dialog && playerSide isEqualTo west) then {
  99.         [_curObject] call life_fnc_copInteractionMenu;
  100.     };
  101.     if ((!(_curObject getVariable ["restrained",false])) && !dialog && playerSide isEqualTo civilian) then {
  102.         [_curObject] call life_fnc_copInteractionMenu;
  103.     };
  104. } else {
  105.     //OK, it wasn't a player so what is it?
  106.     private ["_isVehicle","_miscItems","_money","_list"];
  107.  
  108.     _list = ["landVehicle","Ship","Air"];
  109.     _isVehicle = if (KINDOF_ARRAY(_curObject,_list)) then {true} else {false};
  110.     _miscItems = ["Land_BottlePlastic_V1_F","Land_TacticalBacon_F","Land_Can_V3_F","Land_CanisterFuel_F","Land_Suitcase_F"];
  111.  
  112.     //It's a vehicle! open the vehicle interaction key!
  113.     if (_isVehicle) then {
  114.         if (!dialog) then {
  115.             if (player distance _curObject < ((boundingBox _curObject select 1) select 0)+2 && (!(player getVariable ["restrained",false])) && (!(player getVariable ["playerSurrender",false])) && !life_isknocked && !life_istazed) then {
  116.                 [_curObject] call life_fnc_vInteractionMenu;
  117.             };
  118.         };
  119.     } else {
  120.         //OK, it wasn't a vehicle so let's see what else it could be?
  121.         if ((typeOf _curObject) in _miscItems) then {
  122.             [_curObject,player,false] remoteExecCall ["TON_fnc_pickupAction",RSERV];
  123.         } else {
  124.             //It wasn't a misc item so is it money?
  125.             if ((typeOf _curObject) isEqualTo "Land_Money_F" && {!(_curObject getVariable ["inUse",false])}) then {
  126.                 [_curObject,player,true] remoteExecCall ["TON_fnc_pickupAction",RSERV];
  127.             };
  128.         };
  129.     };
  130. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement