Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "..\..\script_macros.hpp"
- /*
- * File: fn_keyHandler.sqf
- * Author: Bryan "Tonic" Boardwine
- *
- * Description:
- * Main key handler for event 'keyDown'.
- */
- params [
- "_ctrl",
- "_code",
- "_shift",
- "_ctrlKey",
- "_alt"
- ];
- private _speed = speed cursorObject;
- private _handled = false;
- private _interactionKey = if (actionKeys "User10" isEqualTo []) then {219} else {(actionKeys "User10") select 0};
- private _interruptionKeys = [17, 30, 31, 32]; //A,S,W,D
- //Vault handling...
- 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 ["ziptied",false]) || life_isknocked || life_istazed)) exitWith {
- true;
- };
- if (life_action_inUse) exitWith {
- if (!life_interrupted && _code in _interruptionKeys) then {life_interrupted = true};
- _handled;
- };
- //Hotfix for Interaction key not being able to be bound on some operation systems.
- if (!(actionKeys "User10" isEqualTo []) && {(inputAction "User10" > 0)}) exitWith {
- //Interaction key (default is Left Windows, can be mapped via Controls -> Custom -> User Action 10)
- if (!life_action_inUse) then {
- [] spawn {
- private _handle = [] spawn life_fnc_actionKeyHandler;
- waitUntil {scriptDone _handle};
- life_action_inUse = false;
- };
- };
- true;
- };
- if (life_container_active) exitwith {
- //ignore movement actions
- private _allowedMoves = [
- "MoveForward",
- "MoveBack",
- "TurnLeft",
- "TurnRight",
- "MoveFastForward",
- "MoveSlowForward",
- "turbo",
- "TurboToggle",
- "MoveLeft",
- "MoveRight",
- "WalkRunTemp",
- "WalkRunToggle",
- "AdjustUp",
- "AdjustDown",
- "AdjustLeft",
- "AdjustRight",
- "Stand",
- "Crouch",
- "Prone",
- "MoveUp",
- "MoveDown",
- "LeanLeft",
- "LeanLeftToggle",
- "LeanRight",
- "LeanRightToggle"
- ];
- if (({_code in (actionKeys _x)} count _allowedMoves) > 0) exitwith {
- false;
- };
- //handle other keys
- if (_code isEqualTo 57) then {//space key -> place
- life_storagePlacing = 0 spawn life_fnc_placestorage;
- } else { //other keys -> abort
- if (!isNull life_storagePlacing) exitWith {}; //already placing down a box
- if (!isNull life_container_activeObj) then {
- deleteVehicle life_container_activeObj;
- titleText [localize "STR_NOTF_PlaceContainerAbort", "PLAIN"];
- };
- life_container_active = false;
- };
- true;
- };
- /* AAPPS - KEYMAPPER */
- //Interaction key (default is Left Windows, can be mapped via Controls -> Custom -> User Action 10)
- if(_code isEqualTo _interactionKey) exitWith {
- if (!life_action_inUse) then {
- [] spawn {
- private "_handle";
- _handle = [] spawn life_fnc_actionKeyHandler;
- waitUntil {scriptDone _handle};
- life_action_inUse = false;
- };
- };
- true
- };
- private _CommandMode = actionKeys "tacticalView";
- if (_code in _CommandMode) then {
- hint localize "STR_NOTF_CommanderView";
- true
- };
- _sca = [parseNumber _shift,parseNumber _ctrlKey,parseNumber _alt];
- if(dialog) exitWith {false};
- _found = false;
- {
- if(((_x select 1) isEqualTo _code) && {_sca isEqualTo (_x select 2)}) exitWith {
- _code = _x select 0;
- _found = true;
- };
- } forEach keymapper_saved_keys;
- if(!_found) exitWith {false};
- /* END OF AAPPS - KEYMAPPER */
- switch (_code) do {
- //Skin Reload
- case 1: {
- [] call life_fnc_hudUpdate;
- [] call life_fnc_playerSkins;
- };
- //Nitro
- case 2: {
- if (((vehicle player) getVariable["nitro", 0]) > 0) then {
- [] spawn {
- [] call life_fnc_useNitro;
- sleep 2.5;
- };
- };
- };
- //Geste
- case 3: {
- if !(player getVariable ["restrained", false]) then {
- player playActionNow "gestureHi";
- };
- };
- //Redgull
- case 4: {
- if([false,"redgull",1] call life_fnc_handleInv) then{
- [] spawn {
- life_redgull_effect = time;
- ["Du kannst jetzt für 3 Minuten weiter laufen",false,"fast"] call life_fnc_notification_system;
- player enableFatigue false;
- waitUntil {!alive player OR ((time - life_redgull_effect) > (3 * 60))};
- player enableFatigue true;
- };
- } else {
- [] spawn {
- ["Du hast kein RedGull",true,"fast"] call life_fnc_notification_system;
- sleep 2.5;
- };
- };
- };
- //Restrain Cop
- case 5: {
- if (!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 {
- [] call life_fnc_restrainAction;
- };
- };
- //Restrain Civ
- case 6: {
- [] call zipties_fnc_zip_tieAction;
- };
- //Kofferraum
- case 7: {
- if (!dialog && {!life_action_inUse} && {!(player getVariable ["playerSurrender",false])} && {!(player getVariable ["restrained",false])} && {!life_isknocked} && {!life_istazed}) then {
- if (!(isNull objectParent player) && alive vehicle player) then {
- if ((vehicle player) in life_vehicles) then {
- ["life_fnc_openInventory", [vehicle player]] call AD_fnc_ping;
- };
- } else {
- private "_list";
- _list = ((ASLtoATL (getPosASL player)) nearEntities [["Box_IND_Grenades_F","B_supplyCrate_F","Box_NATO_WpsSpecial_F"], 2.5]) select 0;
- if (!(isNil "_list")) then {
- _house = nearestObject [(ASLtoATL (getPosASL _list)), "House"];
- if (_house getVariable ["locked", false]) then {
- [ localize "STR_House_ContainerDeny",true,"fast"] call life_fnc_notification_system;
- } else {
- ["life_fnc_openInventory", [_list]] call AD_fnc_ping;
- };
- } else {
- _list = ["landVehicle","Air","Ship"];
- if (KINDOF_ARRAY(cursorObject,_list) && {player distance cursorObject < 7} && {isNull objectParent player} && {alive cursorObject} && {!life_action_inUse}) then {
- if (cursorObject in life_vehicles || {locked cursorObject isEqualTo 0}) then {
- ["life_fnc_openInventory", [cursorObject]] call AD_fnc_ping;
- };
- };
- };
- };
- };
- };
- //Z Menü
- case 8: {
- if (!dialog && !(player getVariable ["ziptied",false]) && !(player getVariable ["restrained",false]) && {!life_action_inUse}) then {
- [] call life_fnc_p_openMenu;
- [] call life_fnc_hudUpdate;
- [] call life_fnc_playerSkins;
- };
- };
- //Aufschließen / Abschließen
- case 9: {
- private _veh = if (isNull objectParent player) then {
- cursorObject;
- } else {
- vehicle player;
- };
- if (_veh isKindOf "House_F" && {playerSide isEqualTo civilian}) then {
- if (_veh in life_vehicles && {player distance _veh < 20}) then {
- private _door = [_veh] call life_fnc_nearestDoor;
- if (_door isEqualTo 0) exitWith {[ localize "STR_House_Door_NotNear",true,"fast"] call life_fnc_notification_system;};
- private _locked = _veh getVariable [format ["bis_disabled_Door_%1",_door],0];
- if (_locked isEqualTo 0) then {
- _veh setVariable [format ["bis_disabled_Door_%1",_door],1,true];
- _veh animateSource [format ["Door_%1_source", _door], 0];
- systemChat localize "STR_House_Door_Lock";
- } else {
- _veh setVariable [format ["bis_disabled_Door_%1",_door],0,true];
- _veh animateSource [format ["Door_%1_source", _door], 1];
- systemChat localize "STR_House_Door_Unlock";
- };
- };
- } else {
- private _locked = locked _veh;
- if (_veh in life_vehicles && {player distance _veh < 20}) then {
- if (_locked isEqualTo 2) then {
- if (local _veh) then {
- _veh lock 0;
- // BI
- _veh animateDoor ["door_back_R",1];
- _veh animateDoor ["door_back_L",1];
- _veh animateDoor ['door_R',1];
- _veh animateDoor ['door_L',1];
- _veh animateDoor ['Door_L_source',1];
- _veh animateDoor ['Door_rear',1];
- _veh animateDoor ['Door_rear_source',1];
- _veh animateDoor ['Door_1_source',1];
- _veh animateDoor ['Door_2_source',1];
- _veh animateDoor ['Door_3_source',1];
- _veh animateDoor ['Door_LM',1];
- _veh animateDoor ['Door_RM',1];
- _veh animateDoor ['Door_LF',1];
- _veh animateDoor ['Door_RF',1];
- _veh animateDoor ['Door_LB',1];
- _veh animateDoor ['Door_RB',1];
- _veh animateDoor ['DoorL_Front_Open',1];
- _veh animateDoor ['DoorR_Front_Open',1];
- _veh animateDoor ['DoorL_Back_Open',1];
- _veh animateDoor ['DoorR_Back_Open ',1];
- } else {
- [_veh,0] remoteExecCall ["life_fnc_lockVehicle",_veh];
- _veh animateDoor ["door_back_R",1];
- _veh animateDoor ["door_back_L",1];
- _veh animateDoor ['door_R',1];
- _veh animateDoor ['door_L',1];
- _veh animateDoor ['Door_L_source',1];
- _veh animateDoor ['Door_rear',1];
- _veh animateDoor ['Door_rear_source',1];
- _veh animateDoor ['Door_1_source',1];
- _veh animateDoor ['Door_2_source',1];
- _veh animateDoor ['Door_3_source',1];
- _veh animateDoor ['Door_LM',1];
- _veh animateDoor ['Door_RM',1];
- _veh animateDoor ['Door_LF',1];
- _veh animateDoor ['Door_RF',1];
- _veh animateDoor ['Door_LB',1];
- _veh animateDoor ['Door_RB',1];
- _veh animateDoor ['DoorL_Front_Open',1];
- _veh animateDoor ['DoorR_Front_Open',1];
- _veh animateDoor ['DoorL_Back_Open',1];
- _veh animateDoor ['DoorR_Back_Open ',1];
- };
- systemChat localize "STR_MISC_VehUnlock";
- [_veh,"unlockCarSound",50,1] remoteExec ["life_fnc_say3D",RANY];
- } else {
- if (local _veh) then {
- _veh lock 2;
- _veh animateDoor ["door_back_R",0];
- _veh animateDoor ["door_back_L",0];
- _veh animateDoor ['door_R',0];
- _veh animateDoor ['door_L',0];
- _veh animateDoor ['Door_L_source',0];
- _veh animateDoor ['Door_rear',0];
- _veh animateDoor ['Door_rear_source',0];
- _veh animateDoor ['Door_1_source',0];
- _veh animateDoor ['Door_2_source',0];
- _veh animateDoor ['Door_3_source',0];
- _veh animateDoor ['Door_LM',0];
- _veh animateDoor ['Door_RM',0];
- _veh animateDoor ['Door_LF',0];
- _veh animateDoor ['Door_RF',0];
- _veh animateDoor ['Door_LB',0];
- _veh animateDoor ['Door_RB',0];
- _veh animateDoor ['DoorL_Front_Open',0];
- _veh animateDoor ['DoorR_Front_Open',0];
- _veh animateDoor ['DoorL_Back_Open',0];
- _veh animateDoor ['DoorR_Back_Open ',0];
- } else {
- [_veh,2] remoteExecCall ["life_fnc_lockVehicle",_veh];
- _veh animateDoor ["door_back_R",0];
- _veh animateDoor ["door_back_L",0];
- _veh animateDoor ['door_R',0];
- _veh animateDoor ['door_L',0];
- _veh animateDoor ['Door_L_source',0];
- _veh animateDoor ['Door_rear',0];
- _veh animateDoor ['Door_rear_source',0];
- _veh animateDoor ['Door_1_source',0];
- _veh animateDoor ['Door_2_source',0];
- _veh animateDoor ['Door_3_source',0];
- _veh animateDoor ['Door_LM',0];
- _veh animateDoor ['Door_RM',0];
- _veh animateDoor ['Door_LF',0];
- _veh animateDoor ['Door_RF',0];
- _veh animateDoor ['Door_LB',0];
- _veh animateDoor ['Door_RB',0];
- _veh animateDoor ['DoorL_Front_Open',0];
- _veh animateDoor ['DoorR_Front_Open',0];
- _veh animateDoor ['DoorL_Back_Open',0];
- _veh animateDoor ['DoorR_Back_Open ',0];
- };
- systemChat localize "STR_MISC_VehLock";
- [_veh,"lockCarSound",50,1] remoteExec ["life_fnc_say3D",RANY];
- };
- };
- };
- };
- //Gateopener Schranken öffnen
- case 10: {
- [] call life_fnc_GateOpener;
- };
- //Ohrstöpsel
- case 11: {
- [] call life_fnc_earplug;
- };
- //Farming
- case 12: {
- if (playerSide isEqualto CIVILIAN) then {
- if (typeOf vehicle player == "C_Tractor_01_F") then {
- _playerIsInside = player inArea "grain_field";
- if (!((driver vehicle player) == player)) exitwith { ["Du musst der Fahrer sein",true,"fast"] call life_fnc_notification_system; };
- if (!_playerIsInside) exitwith { ["Du musst auf dem Getreide Feld sein!",true,"fast"] call life_fnc_notification_system; };
- if (life_grain) then {
- [] spawn life_fnc_grain;
- life_grain = false;
- } else {
- [] spawn life_fnc_grain;
- life_grain = true;
- };
- [] spawn {
- sleep 2.5;
- };
- };
- };
- };
- //Signalhorn / Sirene
- case 13: {
- if (playerSide in ([west,independent])) then {
- if (vehicle player != player && {!life_siren_active} && {((driver vehicle player) == player)}) then {
- [] spawn {
- life_siren_active = true;
- sleep 4.7;
- life_siren_active = false;
- };
- private _veh = vehicle player;
- if (isNil {_veh getVariable "siren"}) then {_veh setVariable ["siren",false,true];};
- if ((_veh getVariable "siren")) then {
- titleText [localize "STR_MISC_SirensOFF","PLAIN"];
- _veh setVariable ["siren",false,true];
- if !(isNil {(_veh getVariable "sirenJIP")}) then {
- private _jip = _veh getVariable "sirenJIP";
- _veh setVariable ["sirenJIP",nil,true];
- remoteExec ["",_jip]; //remove from JIP queue
- };
- } else {
- titleText [localize "STR_MISC_SirensON","PLAIN"];
- _veh setVariable ["siren",true,true];
- private "_jip";
- if (playerSide isEqualTo west) then {
- _jip = [_veh] remoteExec ["life_fnc_copSiren",RCLIENT,true];
- } else {
- _jip = [_veh] remoteExec ["life_fnc_medicSiren",RCLIENT,true];
- };
- _veh setVariable ["sirenJIP",_jip,true];
- };
- };
- };
- };
- //Niederschlagen
- case 14: {
- if (!isNull cursorObject && cursorObject isKindOf "CAManBase" && isPlayer cursorObject && alive cursorObject && cursorObject distance player < 4 && speed cursorObject < 1) then {
- 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 {
- [cursorObject] spawn life_fnc_knockoutAction;
- };
- };
- };
- //Waffe Holstern
- case 15: {
- if (!(currentWeapon player isEqualTo "")) exitWith {
- life_curWep_h = currentWeapon player;
- player action ["SwitchWeapon", player, player, 100];
- player switchCamera cameraView;
- };
- if (!isNil "life_curWep_h" && {!(life_curWep_h isEqualTo "")}) then {
- if (life_curWep_h in [primaryWeapon player,secondaryWeapon player,handgunWeapon player]) then {
- player selectWeapon life_curWep_h;
- };
- };
- };
- //Blaulicht
- case 16: {
- if (!(isNull objectParent player) && (typeOf vehicle player) in ["C_Quadbike_01_F","C_Hatchback_01_F","C_Hatchback_01_sport_F","C_SUV_01_F","C_Offroad_01_F","C_Offroad_02_unarmed_F","I_E_Offroad_01_comms_F","I_E_Offroad_01_covered_F","B_GEN_Van_02_transport_F","B_GEN_Van_02_vehicle_F","C_Van_02_medevac_F","C_IDAP_Van_02_medevac_F","C_Van_02_vehicle_F","C_Van_02_transport_F","B_MRAP_01_F","O_T_LSV_02_unarmed_black_F","B_LSV_01_unarmed_black_F","O_T_LSV_02_unarmed_F","B_Truck_01_flatbed_F","I_Truck_02_fuel_F","C_Van_01_fuel_F","O_Truck_03_repair_F","I_LT_01_scout_F","O_APC_Wheeled_02_rcws_v2_F","B_APC_Wheeled_01_cannon_F"]) then {
- _debuga = vehicle player getVariable "lights";
- if (!isNil {vehicle player getVariable "lights"}) then {
- if (playerSide isEqualTo west) then {
- [vehicle player] call life_fnc_sirenLights;
- } else {
- [vehicle player] call life_fnc_medicSirenLights;
- };
- _handled = true;
- };
- };
- };
- //Geschwindigkeitsmessung
- case 17: {
- [] call life_fnc_radar;
- };
- //Absperrungen
- case 18: {
- if ((isNull(findDisplay 20000)) && (playerSide in ([west,independent]))) then {
- 0 spawn life_fnc_placeablesMenu;
- _handled = true;
- };
- _handled = true;
- };
- //Ergeben
- case 19: {
- if (player getVariable ["playerSurrender",false]) then {
- player setVariable ["playerSurrender",false,true];
- } else {
- [] spawn life_fnc_surrender;
- };
- _handled = true;
- };
- //Absperrung platzieren
- case 20: {
- if (life_barrier_active) then {
- 0 spawn life_fnc_placeablesPlaceComplete;
- };
- };
- //Springen
- case 21: {
- if (isNil "jumpActionTime") then {jumpActionTime = 0;};
- if (!(animationState player isEqualTo "AovrPercMrunSrasWrflDf") && {isTouchingGround player} && {stance player isEqualTo "STAND"} && {speed player > 2} && {!life_is_arrested} && {((velocity player) select 2) < 2.5} && {time - jumpActionTime > 2}) then {
- if (life_barrier_active) then { [true] call life_fnc_placeableCancel; };
- jumpActionTime = time; //Update the time.
- [player] remoteExec ["life_fnc_jumpFnc",RANY]; //Global execution
- _handled = true;
- };
- };
- //Ausweis
- case 22: {
- if(!(life_idcard_data isEqualto [])) then {
- if(!isnull cursorTarget) then {
- if(alive cursorTarget) then {
- if(cursorTarget isKindOf "Man") then {
- [life_idcard_data,getplayeruid player] remoteExecCall ["life_fnc_show_idcard",cursorTarget];
- [ format[localize "STR_capps_cur_error_success",name cursorTarget],true,"fast"] call life_fnc_notification_system;
- } else {
- [life_idcard_data,getplayeruid player] spawn life_fnc_show_idcard;
- [ localize "STR_capps_cur_error_no_target",true,"fast"] call life_fnc_notification_system;
- };
- } else {
- [life_idcard_data,getplayeruid player] spawn life_fnc_show_idcard;
- [ localize "STR_capps_cur_error_not_alive",true,"fast"] call life_fnc_notification_system;
- };
- } else {
- [life_idcard_data,getplayeruid player] spawn life_fnc_show_idcard;
- [ localize "STR_capps_cur_error_no_target",true,"fast"] call life_fnc_notification_system;
- };
- } else {
- [ localize "STR_capps_cur_error_no_idcard",true,"fast"] call life_fnc_notification_system;
- };
- };
- //Dienstausweis
- case 23: {
- if(!(playerSide isEqualto CIVILIAN)) then {
- if(!(life_idcard_data isEqualto [])) then {
- if(!isnull cursorTarget) then {
- if(alive cursorTarget) then {
- if(cursorTarget isKindOf "Man") then {
- [life_idcard_data,getplayeruid player,playerSide,(call life_coplevel) + (call life_mediclevel)] remoteExecCall ["life_fnc_show_idcard",cursorTarget];
- [ format[localize "STR_capps_cur_error_success_card",name cursorTarget],true,"fast"] call life_fnc_notification_system;
- } else {
- [life_idcard_data,getplayeruid player,playerSide,(call life_coplevel) + (call life_mediclevel)] spawn life_fnc_show_idcard;
- [ localize "STR_capps_cur_error_no_target",true,"fast"] call life_fnc_notification_system;
- };
- } else {
- [life_idcard_data,getplayeruid player,playerSide,(call life_coplevel) + (call life_mediclevel)] spawn life_fnc_show_idcard;
- [ localize "STR_capps_cur_error_not_alive",true,"fast"] call life_fnc_notification_system;
- };
- } else {
- [life_idcard_data,getplayeruid player,playerSide,(call life_coplevel) + (call life_mediclevel)] spawn life_fnc_show_idcard;
- [ localize "STR_capps_cur_error_no_target",true,"fast"] call life_fnc_notification_system;
- };
- } else {
- [ localize "STR_capps_cur_error_no_idcard",true,"fast"] call life_fnc_notification_system;
- };
- };
- };
- //Absperrung entfernen
- case 24: {
- if ((typeOf cursorTarget) in life_definePlaceables) then {
- deleteVehicle cursorTarget;
- [ "Die Absperrung wurde entfernt",false,"fast"] call life_fnc_notification_system;
- };
- };
- };
- _handled;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement