Walkero0

Door 4 Fix AltisLife

Feb 25th, 2018
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 17.10 KB | None | 0 0
  1. #include "..\..\script_macros.hpp"
  2. /*
  3. * File: fn_keyHandler.sqf
  4. * Author: Bryan "Tonic" Boardwine
  5. *
  6. * Description:
  7. * Main key handler for event 'keyDown'
  8. */
  9. private ["_handled","_shift","_alt","_code","_ctrl","_alt","_ctrlKey","_veh","_locked","_interactionKey","_mapKey","_interruptionKeys"];
  10. _ctrl = _this select 0;
  11. _code = _this select 1;
  12. _shift = _this select 2;
  13. _ctrlKey = _this select 3;
  14. _alt = _this select 4;
  15. _speed = speed cursorObject;
  16. _handled = false;
  17.  
  18. _interactionKey = if (count (actionKeys "User10") isEqualTo 0) then {219} else {(actionKeys "User10") select 0};
  19. _mapKey = (actionKeys "ShowMap" select 0);
  20. //hint str _code;
  21. _interruptionKeys = [17,30,31,32]; //A,S,W,D
  22.  
  23. //Vault handling...
  24. if ((_code in (actionKeys "GetOver") || _code in (actionKeys "salute") || _code in (actionKeys "SitDown") || _code in (actionKeys "Throw") || _code in (actionKeys "GetIn") || _code in (actionKeys "GetOut") || _code in (actionKeys "Fire") || _code in (actionKeys "ReloadMagazine") || _code in [16,18]) && ((player getVariable ["restrained",false]) || (player getVariable ["playerSurrender",false]) || life_isknocked || life_istazed)) exitWith {
  25. true;
  26. };
  27.  
  28. if (life_action_inUse) exitWith {
  29. if (!life_interrupted && _code in _interruptionKeys) then {life_interrupted = true;};
  30. _handled;
  31. };
  32.  
  33. //Hotfix for Interaction key not being able to be bound on some operation systems.
  34. if (!(count (actionKeys "User10") isEqualTo 0) && {(inputAction "User10" > 0)}) exitWith {
  35. //Interaction key (default is Left Windows, can be mapped via Controls -> Custom -> User Action 10)
  36. if (!life_action_inUse) then {
  37. [] spawn {
  38. private "_handle";
  39. _handle = [] spawn life_fnc_actionKeyHandler;
  40. waitUntil {scriptDone _handle};
  41. life_action_inUse = false;
  42. };
  43. };
  44. true;
  45. };
  46.  
  47. if (life_container_active) then {
  48. switch (_code) do {
  49. //space key
  50. case 57: {
  51. [] spawn life_fnc_placestorage;
  52. };
  53. };
  54. true;
  55. };
  56.  
  57. switch (_code) do {
  58. //Space key for Jumping
  59. case 57: {
  60. if (isNil "jumpActionTime") then {jumpActionTime = 0;};
  61. if (_shift && {!(animationState player isEqualTo "AovrPercMrunSrasWrflDf")} && {isTouchingGround player} && {stance player isEqualTo "STAND"} && {speed player > 2} && {!life_is_arrested} && {((velocity player) select 2) < 2.5} && {time - jumpActionTime > 1.5}) then {
  62. jumpActionTime = time; //Update the time.
  63. [player] remoteExec ["life_fnc_jumpFnc",RANY]; //Global execution
  64. _handled = true;
  65. };
  66. };
  67.  
  68. //Surrender (Shift + B)
  69. case 48: {
  70. if (_shift) then {
  71. if (player getVariable ["playerSurrender",false]) then {
  72. player setVariable ["playerSurrender",false,true];
  73. } else {
  74. [] spawn life_fnc_surrender;
  75. };
  76. _handled = true;
  77. };
  78. };
  79.  
  80. //Map Key
  81. case _mapKey: {
  82. switch (playerSide) do {
  83. case west: {if (!visibleMap) then {[] spawn life_fnc_copMarkers;}};
  84. case independent: {if (!visibleMap) then {[] spawn life_fnc_medicMarkers;}};
  85. case civilian: {if (!visibleMap) then {[] spawn life_fnc_civMarkers;}};
  86. };
  87. };
  88.  
  89. //Holster / recall weapon. (Shift + H)
  90. case 35: {
  91. if (_shift && !_ctrlKey && !(currentWeapon player isEqualTo "")) then {
  92. life_curWep_h = currentWeapon player;
  93. player action ["SwitchWeapon", player, player, 100];
  94. player switchCamera cameraView;
  95. };
  96.  
  97. if (!_shift && _ctrlKey && !isNil "life_curWep_h" && {!(life_curWep_h isEqualTo "")}) then {
  98. if (life_curWep_h in [primaryWeapon player,secondaryWeapon player,handgunWeapon player]) then {
  99. player selectWeapon life_curWep_h;
  100. };
  101. };
  102. };
  103.  
  104. //Interaction key (default is Left Windows, can be mapped via Controls -> Custom -> User Action 10)
  105. case _interactionKey: {
  106. if (!life_action_inUse) then {
  107. [] spawn {
  108. private "_handle";
  109. _handle = [] spawn life_fnc_actionKeyHandler;
  110. waitUntil {scriptDone _handle};
  111. life_action_inUse = false;
  112. };
  113. };
  114. };
  115.  
  116. //Restraining (Shift + R)
  117. case 19: {
  118. if (_shift) then {_handled = true;};
  119. if (_shift && playerSide isEqualTo west && {!isNull cursorObject} && {cursorObject isKindOf "Man"} && {(isPlayer cursorObject)} && {(side cursorObject in [civilian,independent])} && {alive cursorObject} && {cursorObject distance player < 3.5} && {!(cursorObject getVariable "Escorting")} && {!(cursorObject getVariable "restrained")} && {speed cursorObject < 1}) then {
  120. [] call life_fnc_restrainAction;
  121. };
  122. };
  123.  
  124. //Knock out, this is experimental and yeah... (Shift + G)
  125. case 34: {
  126. if (_shift) then {_handled = true;};
  127. if (_shift && playerSide isEqualTo civilian && !isNull cursorObject && cursorObject isKindOf "Man" && isPlayer cursorObject && alive cursorObject && cursorObject distance player < 4 && speed cursorObject < 1) then {
  128. if ((animationState cursorObject) != "Incapacitated" && (currentWeapon player == primaryWeapon player || currentWeapon player == handgunWeapon player) && currentWeapon player != "" && !life_knockout && !(player getVariable ["restrained",false]) && !life_istazed && !life_isknocked) then {
  129. [cursorObject] spawn life_fnc_knockoutAction;
  130. };
  131. };
  132. };
  133.  
  134. //T Key (Trunk)
  135. case 20: {
  136. if (!_alt && !_ctrlKey && !dialog && {!life_action_inUse}) then {
  137. if (vehicle player != player && alive vehicle player) then {
  138. if ((vehicle player) in life_vehicles) then {
  139. [vehicle player] spawn life_fnc_openInventory;
  140. };
  141. } else {
  142. private "_list";
  143. _list = ((ASLtoATL (getPosASL player)) nearEntities [["Box_IND_Grenades_F","B_supplyCrate_F"], 2.5]) select 0;
  144. if (!(isNil "_list")) then {
  145. _house = nearestObject [(ASLtoATL (getPosASL _list)), "House"];
  146. if (_house getVariable ["locked", false]) then {
  147. hint localize "STR_House_ContainerDeny";
  148. } else {
  149. [_list] spawn life_fnc_openInventory;
  150. };
  151. } else {
  152. _list = ["landVehicle","Air","Ship"];
  153. if (KINDOF_ARRAY(cursorObject,_list) && {player distance cursorObject < 7} && {isNull objectParent player} && {alive cursorObject} && {!life_action_inUse}) then {
  154. if (cursorObject in life_vehicles) then {
  155. [cursorObject] spawn life_fnc_openInventory;
  156. };
  157. };
  158. };
  159. };
  160. };
  161. };
  162.  
  163. //L Key?
  164. case 38: {
  165. //If cop run checks for turning lights on.
  166. if (_shift && playerSide in [west,independent]) then {
  167. if (vehicle player != player && (typeOf vehicle player) in ["C_Offroad_01_F","B_MRAP_01_F","C_SUV_01_F","C_Hatchback_01_sport_F","B_Heli_Light_01_F","B_Heli_Transport_01_F"]) then {
  168. if (!isNil {vehicle player getVariable "lights"}) then {
  169. if (playerSide isEqualTo west) then {
  170. [vehicle player] call life_fnc_sirenLights;
  171. } else {
  172. [vehicle player] call life_fnc_medicSirenLights;
  173. };
  174. _handled = true;
  175. };
  176. };
  177. };
  178.  
  179. if (!_alt && !_ctrlKey) then { [] call life_fnc_radar; };
  180. };
  181.  
  182. //Y Player Menu
  183. case 21: {
  184. if (!_alt && !_ctrlKey && !dialog && !(player getVariable ["restrained",false]) && {!life_action_inUse}) then {
  185. if (!_shift) then {
  186. [] call life_fnc_p_openMenu;
  187. } else {
  188. [] call life_fnc_altisPhone;
  189. };
  190. };
  191. };
  192.  
  193. //F Key
  194. case 33: {
  195. if (playerSide in [west,independent] && {vehicle player != player} && {!life_siren_active} && {((driver vehicle player) == player)}) then {
  196. [] spawn {
  197. life_siren_active = true;
  198. sleep 4.7;
  199. life_siren_active = false;
  200. };
  201.  
  202. _veh = vehicle player;
  203. if (isNil {_veh getVariable "siren"}) then {_veh setVariable ["siren",false,true];};
  204. if ((_veh getVariable "siren")) then {
  205. titleText [localize "STR_MISC_SirensOFF","PLAIN"];
  206. _veh setVariable ["siren",false,true];
  207. } else {
  208. titleText [localize "STR_MISC_SirensON","PLAIN"];
  209. _veh setVariable ["siren",true,true];
  210. if (playerSide isEqualTo west) then {
  211. [_veh] remoteExec ["life_fnc_copSiren",RCLIENT];
  212. } else {
  213. [_veh] remoteExec ["life_fnc_medicSiren",RCLIENT];
  214. };
  215. };
  216. };
  217. };
  218.  
  219. //O Key
  220. case 24: {
  221. if (_shift) then {
  222. if (soundVolume != 1) then {
  223. 1 fadeSound 1;
  224. systemChat localize "STR_MISC_soundnormal";
  225. } else {
  226. 1 fadeSound 0.1;
  227. systemChat localize "STR_MISC_soundfade";
  228. };
  229. };
  230. };
  231.  
  232. //U Key
  233. case 22: {
  234. if (!_alt && !_ctrlKey) then {
  235. if (isNull objectParent player) then {
  236. _veh = cursorObject;
  237. } else {
  238. _veh = vehicle player;
  239. };
  240.  
  241. if (_veh isKindOf "House_F" && {playerSide isEqualTo civilian}) then {
  242. if (_veh in life_vehicles && player distance _veh < 8) then {
  243. _door = [_veh] call life_fnc_nearestDoor;
  244. if (_door isEqualTo 0) exitWith {hint localize "STR_House_Door_NotNear"};
  245. _locked = _veh getVariable [format["bis_disabled_Door_%1",_door],0];
  246.  
  247. if (_locked isEqualTo 0) then {
  248. _veh setVariable [format["bis_disabled_Door_%1",_door],1,true];
  249. _veh animate [format["door_%1_rot",_door],0];
  250. systemChat localize "STR_House_Door_Lock";
  251. } else {
  252. _veh setVariable [format["bis_disabled_Door_%1",_door],0,true];
  253. _veh animate [format["door_%1_rot",_door],1];
  254. systemChat localize "STR_House_Door_Unlock";
  255. };
  256. };
  257. } else {
  258. _locked = locked _veh;
  259. if (_veh in life_vehicles && player distance _veh < 8) then {
  260. if (_locked isEqualTo 2) then {
  261. if (local _veh) then {
  262. _veh lock 0;
  263.  
  264. // BI
  265. _veh animateDoor ["door_back_R",1];
  266. _veh animateDoor ["door_back_R",1];
  267. _veh animateDoor ["door_back_L",1];
  268. _veh animateDoor ['door_R',1];
  269. _veh animateDoor ['door_L',1];
  270. _veh animateDoor ['Door_L_source',1];
  271. _veh animateDoor ['Door_rear',1];
  272. _veh animateDoor ['Door_rear_source',1];
  273. _veh animateDoor ['Door_1_source',1];
  274. _veh animateDoor ['Door_2_source',1];
  275. _veh animateDoor ['Door_3_source',1];
  276. _veh animateDoor ['Door_4_source',1];
  277. _veh animateDoor ['Door_LM',1];
  278. _veh animateDoor ['Door_RM',1];
  279. _veh animateDoor ['Door_LF',1];
  280. _veh animateDoor ['Door_RF',1];
  281. _veh animateDoor ['Door_LB',1];
  282. _veh animateDoor ['Door_RB',1];
  283. _veh animateDoor ['DoorL_Front_Open',1];
  284. _veh animateDoor ['DoorR_Front_Open',1];
  285. _veh animateDoor ['DoorL_Back_Open',1];
  286. _veh animateDoor ['DoorR_Back_Open ',1];
  287. } else {
  288. [_veh,0] remoteExecCall ["life_fnc_lockVehicle",_veh];
  289.  
  290. _veh animateDoor ["door_back_R",1];
  291. _veh animateDoor ["door_back_L",1];
  292. _veh animateDoor ['door_R',1];
  293. _veh animateDoor ['door_L',1];
  294. _veh animateDoor ['Door_L_source',1];
  295. _veh animateDoor ['Door_rear',1];
  296. _veh animateDoor ['Door_rear_source',1];
  297. _veh animateDoor ['Door_1_source',1];
  298. _veh animateDoor ['Door_2_source',1];
  299. _veh animateDoor ['Door_3_source',1];
  300. _veh animateDoor ['Door_4_source',1];
  301. _veh animateDoor ['Door_LM',1];
  302. _veh animateDoor ['Door_RM',1];
  303. _veh animateDoor ['Door_LF',1];
  304. _veh animateDoor ['Door_RF',1];
  305. _veh animateDoor ['Door_LB',1];
  306. _veh animateDoor ['Door_RB',1];
  307. _veh animateDoor ['DoorL_Front_Open',1];
  308. _veh animateDoor ['DoorR_Front_Open',1];
  309. _veh animateDoor ['DoorL_Back_Open',1];
  310. _veh animateDoor ['DoorR_Back_Open ',1];
  311. };
  312. systemChat localize "STR_MISC_VehUnlock";
  313. [_veh,"UnlockCarSound"] remoteExec ["life_fnc_say3D",RANY];
  314. } else {
  315. if (local _veh) then {
  316. _veh lock 2;
  317.  
  318. _veh animateDoor ["door_back_R",0];
  319. _veh animateDoor ["door_back_L",0];
  320. _veh animateDoor ['door_R',0];
  321. _veh animateDoor ['door_L',0];
  322. _veh animateDoor ['Door_L_source',0];
  323. _veh animateDoor ['Door_rear',0];
  324. _veh animateDoor ['Door_rear_source',0];
  325. _veh animateDoor ['Door_1_source',0];
  326. _veh animateDoor ['Door_2_source',0];
  327. _veh animateDoor ['Door_3_source',0];
  328. _veh animateDoor ['Door_4_source',0];
  329. _veh animateDoor ['Door_LM',0];
  330. _veh animateDoor ['Door_RM',0];
  331. _veh animateDoor ['Door_LF',0];
  332. _veh animateDoor ['Door_RF',0];
  333. _veh animateDoor ['Door_LB',0];
  334. _veh animateDoor ['Door_RB',0];
  335. _veh animateDoor ['DoorL_Front_Open',0];
  336. _veh animateDoor ['DoorR_Front_Open',0];
  337. _veh animateDoor ['DoorL_Back_Open',0];
  338. _veh animateDoor ['DoorR_Back_Open ',0];
  339. } else {
  340. [_veh,2] remoteExecCall ["life_fnc_lockVehicle",_veh];
  341.  
  342. _veh animateDoor ["door_back_R",0];
  343. _veh animateDoor ["door_back_L",0];
  344. _veh animateDoor ['door_R',0];
  345. _veh animateDoor ['door_L',0];
  346. _veh animateDoor ['Door_L_source',0];
  347. _veh animateDoor ['Door_rear',0];
  348. _veh animateDoor ['Door_rear_source',0];
  349. _veh animateDoor ['Door_1_source',0];
  350. _veh animateDoor ['Door_2_source',0];
  351. _veh animateDoor ['Door_3_source',0];
  352. _veh animateDoor ['Door_4_source',0];
  353. _veh animateDoor ['Door_LM',0];
  354. _veh animateDoor ['Door_RM',0];
  355. _veh animateDoor ['Door_LF',0];
  356. _veh animateDoor ['Door_RF',0];
  357. _veh animateDoor ['Door_LB',0];
  358. _veh animateDoor ['Door_RB',0];
  359. _veh animateDoor ['DoorL_Front_Open',0];
  360. _veh animateDoor ['DoorR_Front_Open',0];
  361. _veh animateDoor ['DoorL_Back_Open',0];
  362. _veh animateDoor ['DoorR_Back_Open ',0];
  363. };
  364. systemChat localize "STR_MISC_VehLock";
  365. [_veh,"LockCarSound"] remoteExec ["life_fnc_say3D",RANY];
  366. };
  367. };
  368. };
  369. };
  370. };
  371. };
  372.  
  373. _handled;
Advertisement
Add Comment
Please, Sign In to add comment