Add toggleable Garage Door Opener by salival

This commit is contained in:
A Man
2021-08-18 13:51:05 +02:00
parent 343128bb0c
commit b3871aa321
4 changed files with 101 additions and 2 deletions

View File

@@ -0,0 +1,70 @@
/*
Garage door opener script by salival (https://github.com/oiad)
*/
if (dayz_actionInProgress) exitWith {localize "str_player_actionslimit" call dayz_rollingMessages;};
dayz_actionInProgress = true;
private ["_door","_typeof","_state"];
_door = _this select 3;
_typeof = typeof _door;
_state = 5;
if (isNull _door) exitWith {dayz_actionInProgress = false; systemChat localize "str_cursorTargetNotFound";};
{DZE_myVehicle removeAction _x} count s_player_gdoor_opener;s_player_gdoor_opener = [];
s_player_gdoor_opener_ctrl = 1;
call {
if (_typeof in ["WoodenGate_1_DZ","WoodenGate_2_DZ","WoodenGate_3_DZ","WoodenGate_4_DZ"]) exitwith {
if (_door animationPhase "DoorR" == 0) then {
systemChat localize "STR_CL_GDO_DOOR_OPEN";
_door animate ["DoorR",1];
_door animate ["DoorL",1];
} else {
systemChat localize "STR_CL_GDO_DOOR_CLOSE";
_door animate ["DoorR",0];
_door animate ["DoorL",0];
_state = 4;
};
};
if (_typeof in ["CinderGarageOpenTopLocked_DZ","Land_DZE_WoodOpenTopGarageLocked"]) exitwith {
if (_door animationPhase "doorl" == 0) then {
systemChat localize "STR_CL_GDO_DOOR_OPEN";
_door animate ["doorR",1];
_door animate ["doorl",1];
} else {
systemChat localize "STR_CL_GDO_DOOR_CLOSE";
_door animate ["doorR",0];
_door animate ["doorl",0];
_state = 4;
};
};
if (_typeof in ["CinderGateLocked_DZ","Land_DZE_WoodGateLocked"]) exitwith {
if (_door animationPhase "Open_door" == 0) then {
systemChat localize "STR_CL_GDO_DOOR_OPEN";
_door animate ["Open_door",1];
_door animate ["Open_doorR",1];
} else {
systemChat localize "STR_CL_GDO_DOOR_CLOSE";
_door animate ["Open_door",0];
_door animate ["Open_doorR",0];
_state = 4;
};
};
if (_door animationPhase "Open_door" == 0) then {
systemChat localize "STR_CL_GDO_DOOR_OPEN";
_door animate ["Open_door",1];
} else {
systemChat localize "STR_CL_GDO_DOOR_CLOSE";
_door animate ["Open_door",0];
_state = 4;
};
};
PVDZE_handleSafeGear = [player,_door,_state,"DoorOpener"];
publicVariableServer "PVDZE_handleSafeGear";
s_player_gdoor_opener_ctrl = -1;
dayz_actionInProgress = false;

View File

@@ -128,9 +128,28 @@ if (_inVehicle) then {
{DZE_myVehicle removeAction _x} count s_player_lockUnlockInside;s_player_lockUnlockInside = []; {DZE_myVehicle removeAction _x} count s_player_lockUnlockInside;s_player_lockUnlockInside = [];
s_player_lockUnlockInside_ctrl = -1; s_player_lockUnlockInside_ctrl = -1;
}; };
//Allows to open garage doors from the vehicle, but may negatively impact performance
if (DZE_GarageDoor_Opener) then {
local _doors = nearestObjects [DZE_myVehicle, DZE_GarageDoors, DZE_GarageDoor_Radius];
if (count _doors > 0 && {driver DZE_myVehicle == player}) then {
local _hasAccess = [player,_doors select 0] call FNC_check_access;
if (s_player_gdoor_opener_ctrl < 0 && ((_hasAccess select 0) || (_hasAccess select 2) || (_hasAccess select 3) || (_hasAccess select 4))) then {
local _door = DZE_myVehicle addAction [format["<t color='#0059FF'>%1</t>",localize "STR_CL_GDO_GARAGE"],"\z\addons\dayz_code\actions\garageDoorOpener.sqf",_doors select 0, 1, false, true];
s_player_gdoor_opener set [count s_player_gdoor_opener,_door];
s_player_gdoor_opener_ctrl = 1;
};
} else {
{DZE_myVehicle removeAction _x} count s_player_gdoor_opener;s_player_gdoor_opener = [];
s_player_gdoor_opener_ctrl = -1;
};
};
} else { } else {
{DZE_myVehicle removeAction _x} count s_player_lockUnlockInside;s_player_lockUnlockInside = []; {DZE_myVehicle removeAction _x} count s_player_lockUnlockInside;s_player_lockUnlockInside = [];
s_player_lockUnlockInside_ctrl = -1; s_player_lockUnlockInside_ctrl = -1;
{DZE_myVehicle removeAction _x} count s_player_gdoor_opener;s_player_gdoor_opener = [];
s_player_gdoor_opener_ctrl = -1;
}; };
if (DZE_HeliLift) then { if (DZE_HeliLift) then {
@@ -1075,7 +1094,7 @@ if (!isNull _cursorTarget && {!_inVehicle && !_isPZombie && _canDo && player dis
player removeAction s_player_checkWallet; player removeAction s_player_checkWallet;
s_player_checkWallet = -1; s_player_checkWallet = -1;
player removeAction s_player_clothes; player removeAction s_player_clothes;
s_player_clothes = -1; s_player_clothes = -1;
}; };
//Dog actions on player self //Dog actions on player self

View File

@@ -205,7 +205,15 @@ if (!isDedicated) then {
DZE_CLICK_ACTIONS = DZE_CLICK_ACTIONS + [ DZE_CLICK_ACTIONS = DZE_CLICK_ACTIONS + [
["ItemGPS",localize "STR_CL_LV_LOCATE_VEHICLES","[] spawn locateVehicle;","true"] ["ItemGPS",localize "STR_CL_LV_LOCATE_VEHICLES","[] spawn locateVehicle;","true"]
]; ];
}; };
// Garage Door Opener
DZE_GarageDoor_Opener = false; // Enables the option to open Garage Doors from the inside of a vehicle.
if (DZE_GarageDoor_Opener) then {
DZE_GarageDoors = ["CinderWallDoorLocked_DZ","Land_DZE_GarageWoodDoorLocked","Land_DZE_LargeWoodDoorLocked","WoodenGate_1_DZ","WoodenGate_2_DZ","WoodenGate_3_DZ","WoodenGate_4_DZ","Land_DZE_WoodGateLocked","CinderGateLocked_DZ","Land_DZE_WoodOpenTopGarageLocked","CinderGarageOpenTopLocked_DZ"]; // Array of Garage Doors that can be opened.
DZE_GarageDoor_Radius = 30; // Radius from where the Garage Doors can be opened. Higher values may negatively impact the performance
};
// Service Points for Refuel, Repair and Rearm // Service Points for Refuel, Repair and Rearm
DZE_Service_Points = false; DZE_Service_Points = false;

View File

@@ -208,6 +208,8 @@ if (!isDedicated) then {
s_bank_dialog3 = -1; s_bank_dialog3 = -1;
s_player_checkWallet = -1; s_player_checkWallet = -1;
s_player_clothes = -1; s_player_clothes = -1;
s_player_gdoor_opener = [];
s_player_gdoor_opener_ctrl = -1;
}; };
call dayz_resetSelfActions; call dayz_resetSelfActions;