Pullrequest/door management (#1694)

* Added doorManagement

* Rename FNC_check_owner --> FNC_check_owner_friends

* Fixed typo

* Fixed bug in FNC_check_owner_friends which allowed every user to manage
every plot and door.

* Removed unused DZE_doorManagementHarderPenalty from configVariables.sqf

* Now checking if _playerUID is in _friendlies for both cases.

* DZE_plotforLife should be DZE_permanentPlot

* Fixed case where DZE_permanentPlot is false.

* Forgot to add STR_EPOCH_CANCEL

* Changed translations to suggested string by ebaydayz.

* Renamed EyeScanner to DoorAccess.

* Reworked access rights for door management.

* DZE_doorManagementMustBeClose = true; //Players must be within 10m of
door to be added as a door friend.

* Fixed copy-paste error.

* Replace count with if

* Remove redundant test.

* Also replaced count in door management admins check.

* Change plotManagement and doorManagement to be consistent to
DayZ_UseSteamID (get UID from FNC_GetPlayerUID).

* Use _playerUID and _characterID more consistent.

* Added german translation to
STR_EPOCH_PLOTMANAGEMENT_ADDFRIEND_ALREADYONTHELIST.
This commit is contained in:
Bruce-LXXVI
2016-06-16 00:22:01 +02:00
committed by ebaydayz
parent 035a94646b
commit 5e53a71e88
21 changed files with 680 additions and 65 deletions

View File

@@ -42,15 +42,23 @@ if (DZE_permanentPlot) then {
_playerUID = [_player] call FNC_GetPlayerUID;
_targetOwner = _target getVariable ["ownerPUID","0"];
_owner = (_playerUID == _targetOwner);
// Check if player is a plot friend
if (_playerUID in _friendlies) then {
_friendly = true;
};
} else {
_playerUID = dayz_characterID;
_friendlies = _player getVariable ["friendlyTo",[]];
_targetOwner = _target getVariable ["CharacterID","0"];
_owner = (_targetOwner == dayz_characterID);
// Check if target object owner is a friend of player
if (_targetOwner in _friendlies) then {
_friendly = true;
};
};
if (_targetOwner in _friendlies) then {
_friendly = true;
};
// Check if player is owner of target object
_owner = (_playerUID == _targetOwner);
[_owner, _friendly]

View File

@@ -0,0 +1,145 @@
/*
Check object's ownership and friends (plot and door)
Original concept by RimBlock (github.com/RimBlock)
Extended by Bruce-LXXVI to support different target objects
and allow fine grained access policies
Parameters:
_this select 0: object - player calling this function
_this select 1: object - target to check ownership and friendlies of
Returns:
_return select 0: bool - player is owner of target object
_return select 1: bool - player is friends with owner of target object
_return select 2: bool - player is plot owner
_return select 3: bool - player is plot friend
_return select 4: bool - player is plot management admin
_return select 5: bool - player is target friend
_return select 6: bool - player is target management admin
_return select 7: string - detected target type
2,3,4: always false if no plot nearby
5,6: always false if _target is not a supported target
*/
private [
"_player" // Player, who wants to access the _target
,"_target" // The target object the _player wants to access
,"_isOwner" // return value
,"_isFriendly" // return value
,"_isPlotOwner" // return value
,"_isPlotFriend" // return value
,"_isPlotAdmin" // return value
,"_isTargetFriend" // return value
,"_isTargetAdmin" // return value
,"_targetType" // return value
,"_targetOwnerUID" // UID or characterID of the owner of _target
,"_playerUID" // UID of the _player
,"_characterID" // characterID of the _player
,"_plotcheck" // takes return value of FNC_find_plots
,"_isNearPlot" // player is in plot's reach
,"_nearestPlot" // plot object
,"_plotOwnerUID" // plot owner's UID
,"_plotFriends" // list of plot friends [["UID", "Name"], ..]
,"_targetFriends" // list of target friends [["UID", "Name"], ..]
];
// assign parameters
_player = _this select 0;
_target = _this select 1;
// Initialize return values
_isOwner = false;
_isFriendly = false;
_isPlotOwner = false;
_isPlotFriend = false;
_isPlotAdmin = false;
_isTargetFriend = false;
_isTargetAdmin = false;
_targetType = "";
// determine target type
_targetType = if(typeOf _target in DZE_DoorsLocked) then { "DOOR"; } else { "GENERIC"; };
// determine owner and player id
// and check if player is owner of target object
_playerUID = [_player] call FNC_GetPlayerUID;
_characterID = dayz_characterID;
if(DZE_permanentPlot) then {
_targetOwnerUID = _target getVariable ["ownerPUID","0"];
_isOwner = (_playerUID == _targetOwnerUID);
} else {
_targetOwnerUID = _target getVariable ["characterID","0"];
_isOwner = (_characterID == _targetOwnerUID);
};
// determine _players friends (tagged)
// and check if owner of _target is tagged friendly
_friendlies = _player getVariable ["friendlyTo",[]];
_isFriendly = (_targetOwnerUID in _friendlies);
// find nearest plot
_plotcheck = [_player, false] call FNC_find_plots;
_isNearPlot = ((_plotcheck select 1) > 0);
_nearestPlot = _plotcheck select 2;
if(_isNearPlot) then {
// determine plot owner
// and check if player is owner of plot
if (DZE_permanentPlot) then {
_plotOwnerUID = _nearestPlot getVariable ["ownerPUID","0"];
_isPlotOwner = (_playerUID == _plotOwnerUID);
} else {
_plotOwnerUID = _nearestPlot getVariable ["characterID","0"];
_isPlotOwner = (_characterID == _plotOwnerUID);
};
// determine plot friends
// and check if player is one of them
_isPlotFriend = _isPlotOwner; // Plot owner is always a plot friend
_plotFriends = _nearestPlot getVariable ["plotfriends", []];
{
if( (_x select 0) == _playerUID ) then { _isPlotFriend = true; };
} count _plotFriends;
// determine plot management admins
// and check if player is one of them
if(_playerUID in DZE_PlotManagementAdmins) then { _isPlotAdmin = true; };
};
// Process target type DOOR
if(_targetType == "DOOR") then {
// determine door friends
// and check if player is one of them
_isTargetFriend = _isOwner; // Door owner is always a door friend
_targetFriends = _target getVariable ["doorfriends",[]];
{
if( (_x select 0) == _playerUID ) then { _isTargetFriend = true; };
} count _targetFriends;
// determine door management admins
// and check if player is one of them
if(_playerUID in DZE_DoorManagementAdmins) then { _isTargetAdmin = true; };
};
// RESULT
[ _isOwner
, _isFriendly
, _isPlotOwner
, _isPlotFriend
, _isPlotAdmin
, _isTargetFriend
, _isTargetAdmin
, _targetType
]

View File

@@ -767,6 +767,26 @@ if (!isNull _cursorTarget && !_inVehicle && !_isPZombie && (player distance _cur
s_player_SurrenderedGear = -1;
};
// Allow manage door
if( DZE_doorManagement && (_typeOfCursorTarget in DZE_DoorsLocked) ) then {
// Check player access
_isowner = [player, _cursorTarget] call FNC_check_access;
if( (s_player_manageDoor < 0) && (
((_isowner select 0) && DZE_doorManagementAllowManage_owner) // door owner
|| ((_isowner select 1) && DZE_doorManagementAllowManage_ownerFriendlies) // door owner's friendly tagged
|| ((_isowner select 2) && DZE_doorManagementAllowManage_plotOwner) // plot owner
|| ((_isowner select 3) && DZE_doorManagementAllowManage_plotFriends) // plot friends
|| ((_isowner select 4) && DZE_doorManagementAllowManage_plotAdmins) // plot management admins
|| ((_isowner select 5) && DZE_doorManagementAllowManage_doorFriends) // door friends
|| ((_isowner select 6) && DZE_doorManagementAllowManage_doorAdmins) // door management admins
)) then {
s_player_manageDoor = player addAction [format["<t color='#0059FF'>%1</t>", localize "STR_EPOCH_ACTIONS_MANAGEDOOR"], "\z\addons\dayz_code\actions\doorManagement\initDoorManagement.sqf", _cursorTarget, 5, false];
};
} else {
player removeAction s_player_manageDoor;
s_player_manageDoor = -1;
};
//Allow owner to unlock vault
if ((_typeOfCursorTarget in DZE_LockableStorage) && {_characterID != "0"} && {player distance _cursorTarget < 3} && {!keypadCancel}) then {
if (s_player_unlockvault < 0) then {
@@ -809,7 +829,7 @@ if (!isNull _cursorTarget && !_inVehicle && !_isPZombie && (player distance _cur
s_player_lockvault = -1;
};
//Player Deaths
//Player Deaths
if (_typeOfCursorTarget == "Info_Board_EP1") then {
if (s_player_information < 0) then {
s_player_information = player addAction [localize "STR_EPOCH_ACTIONS_MURDERS", "\z\addons\dayz_code\actions\list_playerDeaths.sqf",[], 7, false, true];
@@ -1170,6 +1190,8 @@ if (!isNull _cursorTarget && !_inVehicle && !_isPZombie && (player distance _cur
s_player_fuelauto = -1;
player removeAction s_player_fuelauto2;
s_player_fuelauto2 = -1;
player removeAction s_player_manageDoor;
s_player_manageDoor = -1;
};
//Dog actions on player self

View File

@@ -2,6 +2,7 @@
DayZ Unlock Door
Usage: [_obj] call player_unlockDoor;
Made for DayZ Epoch please ask permission to use/edit/distrubute email vbawol@veteranbastards.com.
Modified for Zupa's DoorManagement.
*/
private ["_display","_obj","_objectCharacterID"];
@@ -9,6 +10,13 @@ if (!isNil "DZE_DYN_UnlockDoorInprogress") exitWith {localize "str_epoch_player_
DZE_DYN_UnlockDoorInprogress = true;
// find display and check the door opening method
_doorMethod = '';
_displayCombo = findDisplay 41144;
_displayEye = findDisplay 61144;
if(!isNull _displayEye) then {_display = _displayEye; _doorMethod = "Eye";};
if(!isNull _displayCombo) then {_display = _displayCombo; _doorMethod = "Combo";};
if (!isNull dayz_selectedDoor) then {
if (!isNil 'KeyCodeTryTimer') then {
if (diag_tickTime > KeyCodeTryTimer) then {
@@ -16,25 +24,40 @@ if (!isNull dayz_selectedDoor) then {
KeyCodeTryTimer = nil;
};
};
_obj = dayz_selectedDoor; // our target
_notNearestPlayer = _obj call dze_isnearest_player;
if (_notNearestPlayer) then {
// close display since another player is closer
_display = findDisplay 41144;
_display closeDisplay 3000;
localize "STR_EPOCH_ACTIONS_16" call dayz_rollingMessages;
} else {
// get object combination
_objectCharacterID = _obj getVariable ["CharacterID","0"];
if(DZE_doorManagement) then {
// Check player access
_isowner = [player, _obj] call FNC_check_access;
if( ((_isowner select 0) && DZE_doorManagementAllowAccess_owner) // door owner
|| ((_isowner select 1) && DZE_doorManagementAllowAccess_ownerFriendlies) // door owner's friendly tagged
|| ((_isowner select 2) && DZE_doorManagementAllowAccess_plotOwner) // plot owner
|| ((_isowner select 3) && DZE_doorManagementAllowAccess_plotFriends) // plot friends
|| ((_isowner select 4) && DZE_doorManagementAllowAccess_plotAdmins) // plot management admins
|| ((_isowner select 5) && DZE_doorManagementAllowAccess_doorFriends) // door friends
|| ((_isowner select 6) && DZE_doorManagementAllowAccess_doorAdmins) // door management admins
) then {
DZE_Lock_Door = dayz_selectedDoor getVariable['CharacterID','0'];
};
};
// Check combination
if (DZE_Lock_Door == _objectCharacterID) then {
[player,"combo_unlock",0,false] call dayz_zombieSpeak;
// close display
_display = findDisplay 41144;
_display closeDisplay 3000;
// unlock if locked
@@ -44,6 +67,11 @@ if (!isNull dayz_selectedDoor) then {
if (_obj animationPhase "Open_latch" == 0) then {
_obj animate ["Open_latch", 1];
};
if(_doorMethod == "Eye") then {
localize "STR_EPOCH_DOORACCESS_SUCCESS" call dayz_rollingMessages;
};
KeyCodeTry = nil;
} else {
["Working",0,[100,15,10,0]] call dayz_NutritionSystem;
@@ -58,14 +86,17 @@ if (!isNull dayz_selectedDoor) then {
if (KeyCodeTry >= ((round(random 4)) + 4)) then {
if (isNil 'KeyCodeTryTimer') then {KeyCodeTryTimer = diag_tickTime+10;};
localize "str_epoch_player_19" call dayz_rollingMessages;
_display = findDisplay 41144;
_display closeDisplay 3000;
};
if(_doorMethod == "Eye") then {
localize "STR_EPOCH_DOORACCESS_FAILURE" call dayz_rollingMessages;
_display closeDisplay 3000;
};
};
};
} else {
// close display since no target
_display = findDisplay 41144;
_display closeDisplay 3000;
};
DZE_DYN_UnlockDoorInprogress = nil;