Advertisement
Guest User

Untitled

a guest
Jul 30th, 2015
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.98 KB | None | 0 0
  1. #include <macro.h>
  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["_curTarget","_isWater"];
  11. _curTarget = cursorTarget;
  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. //Check if the player is near an ATM.
  17. if((call life_fnc_nearATM) && {!dialog}) exitWith {
  18. [] call life_fnc_atmMenu;
  19. };
  20.  
  21. if(isNull _curTarget) exitWith {
  22. if(_isWater) then {
  23. private "_fish";
  24. _fish = (nearestObjects[visiblePosition player,["Fish_Base_F"],3]) select 0;
  25. if(!isNil "_fish") then {
  26. [_fish] call life_fnc_catchFish;
  27. };
  28. } else {
  29. if(playerSide == civilian && !life_action_gathering) then {
  30. _handle = [] spawn life_fnc_gather;
  31. waitUntil {scriptDone _handle};
  32. life_action_gathering = false;
  33. };
  34. };
  35. };
  36.  
  37.  
  38. if(!alive _curTarget && _curTarget isKindOf "Animal" && !(EQUAL((typeOf _curTarget),"Turtle_F"))) exitWith {
  39. [_curTarget] call life_fnc_gutAnimal;
  40. };
  41.  
  42. if(_curTarget isKindOf "House_F" && {player distance _curTarget < 12} OR ((nearestObject [[16019.5,16952.9,0],"Land_Dome_Big_F"]) == _curTarget OR (nearestObject [[16019.5,16952.9,0],"Land_Research_house_V1_F"]) == _curTarget)) exitWith {
  43. [_curTarget] call life_fnc_houseMenu;
  44. };
  45.  
  46. if(dialog) exitWith {}; //Don't bother when a dialog is open.
  47. if(vehicle player != player) exitWith {}; //He's in a vehicle, cancel!
  48. life_action_inUse = true;
  49.  
  50. //Temp fail safe.
  51. [] spawn {
  52. sleep 60;
  53. life_action_inUse = false;
  54. };
  55.  
  56. //Check if it's a dead body.
  57. if(_curTarget isKindOf "Man" && {!alive _curTarget} && {playerSide in [west,independent]}) exitWith {
  58. //Hotfix code by ins0
  59. if(((playerSide == blufor && {(EQUAL(LIFE_SETTINGS(getNumber,"revive_cops"),1))}) || playerSide == independent) && {"Medikit" in (items player)}) then {
  60. [_curTarget] call life_fnc_revivePlayer;
  61. };
  62. };
  63.  
  64.  
  65. //If target is a player then check if we can use the cop menu.
  66. if(isPlayer _curTarget && _curTarget isKindOf "Man") then {
  67. if((_curTarget GVAR ["restrained",false]) && !dialog && playerSide == west) then {
  68. [_curTarget] call life_fnc_copInteractionMenu;
  69. };
  70. } else {
  71. //OK, it wasn't a player so what is it?
  72. private["_isVehicle","_miscItems","_money","_list"];
  73.  
  74. _list = ["landVehicle","Ship","Air"];
  75. _isVehicle = if(KINDOF_ARRAY(_curTarget,_list)) then {true} else {false};
  76. _miscItems = ["Land_BottlePlastic_V1_F","Land_TacticalBacon_F","Land_Can_V3_F","Land_CanisterFuel_F","Land_Suitcase_F"];
  77. _animalTypes = ["Salema_F","Ornate_random_F","Mackerel_F","Tuna_F","Mullet_F","CatShark_F","Turtle_F"];
  78. _money = "Land_Money_F";
  79.  
  80. //It's a vehicle! open the vehicle interaction key!
  81. if(_isVehicle) then {
  82. if(!dialog) then {
  83. if(player distance _curTarget < SEL(SEL(boundingBox _curTarget,1),0)+2) then {
  84. [_curTarget] call life_fnc_vInteractionMenu;
  85. };
  86. };
  87. } else {
  88. //Is it a animal type?
  89. if((typeOf _curTarget) in _animalTypes) then {
  90. if(EQUAL((typeOf _curTarget),"Turtle_F") && !alive _curTarget) then {
  91. private "_handle";
  92. _handle = [_curTarget] spawn life_fnc_catchTurtle;
  93. waitUntil {scriptDone _handle};
  94. } else {
  95. private "_handle";
  96. _handle = [_curTarget] spawn life_fnc_catchFish;
  97. waitUntil {scriptDone _handle};
  98. };
  99. } else {
  100. //OK, it wasn't a vehicle so let's see what else it could be?
  101. if((typeOf _curTarget) in _miscItems) then {
  102. [[_curTarget,player,false],"TON_fnc_pickupAction",false,false,true] call life_fnc_MP;
  103. } else {
  104. //It wasn't a misc item so is it money?
  105. if(EQUAL((typeOf _curTarget),_money) && {!(_curTarget GVAR ["inUse",false])}) then {
  106. [[_curTarget,player,true],"TON_fnc_pickupAction",false,false,true] call life_fnc_MP;
  107. };
  108. };
  109. };
  110. };
  111. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement