From 64b5659bbd06f7550da78faeb18cd44a9aca070c Mon Sep 17 00:00:00 2001 From: oiad Date: Tue, 24 Oct 2017 20:19:21 +1300 Subject: [PATCH] Better checks for removing the owner of plots/doors Revert https://github.com/EpochModTeam/DayZ-Epoch/commit/f0e87969968646e0ae6e9acbdf7e3fa31a4dfd35 Partial revert: https://github.com/EpochModTeam/DayZ-Epoch/commit/2f0774d531b950c3ab89ad82b019bd46c0c10ba4#diff-c3aa237d9007054fc3a724116a5d9f1a This is a better check for removing the owner of plots/doors based on conversations on discord. Plot/door owner can remove them selves plot/door friends can't remove plot owner plot/door admins can remove anyone --- .../actions/doorManagement/doorRemoveFriend.sqf | 7 ++++--- .../actions/plotManagement/plotRemoveFriend.sqf | 17 ++++------------- SQF/dayz_code/compile/dze_buildChecks.sqf | 2 +- 3 files changed, 9 insertions(+), 17 deletions(-) diff --git a/SQF/dayz_code/actions/doorManagement/doorRemoveFriend.sqf b/SQF/dayz_code/actions/doorManagement/doorRemoveFriend.sqf index 6734ad34e..586e00e50 100644 --- a/SQF/dayz_code/actions/doorManagement/doorRemoveFriend.sqf +++ b/SQF/dayz_code/actions/doorManagement/doorRemoveFriend.sqf @@ -1,15 +1,16 @@ -private ["_pos","_friends","_toRemove","_newList"]; +private ["_pos","_friends","_toRemove","_newList","_ownerPUID"]; _pos = _this select 0; if (_pos < 0) exitWith {}; _friends = TheDoor getVariable ["doorfriends", []]; +_ownerPUID = TheDoor getVariable ["ownerPUID","0"]; _toRemove = (_friends select _pos); -if ((_toRemove select 0) == ((_friends select 0) select 0) && (!(dayz_playerUID in DZE_doorManagementAdmins) && !(dayz_playerUID == ((_friends select 0) select 0)))) exitWith {systemChat localize "STR_EPOCH_DOORMANAGEMENT_CANT_REMOVE";}; +if ((_toRemove select 0) == _ownerPUID && (!(dayz_playerUID in DZE_doorManagementAdmins) && !(dayz_playerUID == _ownerPUID))) exitWith {systemChat localize "STR_EPOCH_DOORMANAGEMENT_CANT_REMOVE";}; _newList = []; { - if(_x select 0 != _toRemove select 0) then { + if (_x select 0 != _toRemove select 0) then { _newList set [count _newList, _x ]; }; } forEach _friends; diff --git a/SQF/dayz_code/actions/plotManagement/plotRemoveFriend.sqf b/SQF/dayz_code/actions/plotManagement/plotRemoveFriend.sqf index da36cb7c9..a90470265 100644 --- a/SQF/dayz_code/actions/plotManagement/plotRemoveFriend.sqf +++ b/SQF/dayz_code/actions/plotManagement/plotRemoveFriend.sqf @@ -1,31 +1,22 @@ -private ["_pos","_plots","_thePlot","_friends","_toRemove","_newList","_hasPole"]; +private ["_pos","_plots","_thePlot","_friends","_toRemove","_newList","_ownerPUID"]; _pos = _this select 0; if (_pos < 0) exitWith {}; _plots = ([player] call FNC_getPos) nearEntities ["Plastic_Pole_EP1_DZ",15]; _thePlot = _plots select 0; _friends = _thePlot getVariable ["plotfriends", []]; +_ownerPUID = _thePlot getVariable ["ownerPUID","0"]; _toRemove = (_friends select _pos); -_hasPole = false; _newList = []; -if ((_toRemove select 0) == ((_friends select 0) select 0) && (!(dayz_playerUID in DZE_PlotManagementAdmins) && !(dayz_playerUID == ((_friends select 0) select 0)))) exitWith {systemChat localize "STR_EPOCH_PLOTMANAGEMENT_CANT_REMOVE";}; - -if (DZE_limitPlots && {!(dayz_playerUID in DZE_PlotManagementAdmins)}) then { - { - if (_x getVariable["ownerPUID","0"] == dayz_playerUID || (_x getVariable["CharacterID","0"] == dayz_characterID) || ((((_x getVariable ["plotfriends",[]]) select 0) select 0) == dayz_playerUID) && (_x != _thePlot)) exitWith { - _hasPole = true; - }; - } count (entities "Plastic_Pole_EP1_DZ"); -}; - -if (_hasPole) exitWith {systemChat localize "STR_EPOCH_PLAYER_133";}; +if ((_toRemove select 0) == _ownerPUID && (!(dayz_playerUID in DZE_PlotManagementAdmins) && !(dayz_playerUID == _ownerPUID))) exitWith {systemChat localize "STR_EPOCH_PLOTMANAGEMENT_CANT_REMOVE";}; { if (_x select 0 != _toRemove select 0) then { _newList set [(count _newList), _x]; }; } count _friends; + _thePlot setVariable ["plotfriends", _newList, true]; PVDZ_veh_Save = [_thePlot,"gear"]; diff --git a/SQF/dayz_code/compile/dze_buildChecks.sqf b/SQF/dayz_code/compile/dze_buildChecks.sqf index c89c7e420..97008ca7f 100644 --- a/SQF/dayz_code/compile/dze_buildChecks.sqf +++ b/SQF/dayz_code/compile/dze_buildChecks.sqf @@ -45,7 +45,7 @@ if (_isPole) then { _distance = DZE_PlotPole select 1; if (DZE_limitPlots && {!(dayz_playerUID in DZE_PlotManagementAdmins)}) then { { - if (_x getVariable["ownerPUID","0"] == dayz_playerUID || (_x getVariable["CharacterID","0"] == dayz_characterID) || ((((_x getVariable ["plotfriends",[]]) select 0) select 0) == dayz_playerUID)) exitWith { + if (_x getVariable["ownerPUID","0"] == dayz_playerUID || (_x getVariable["CharacterID","0"] == dayz_characterID)) exitWith { _hasPole = true; }; } count (entities "Plastic_Pole_EP1_DZ");