Plot Management cleanup + improvement

New compile DZE_GetPlotFriends

DZE_PlotManagementAdmins allows admin management of plot poles and
buildables near poles

DZE_MaxPlotFriends allows servers to allow more than 6 friends on a pole
at once
This commit is contained in:
icomrade
2016-05-01 13:20:21 -04:00
parent 9e2728af07
commit 1e65f7a959
8 changed files with 62 additions and 111 deletions

View File

@@ -2,14 +2,14 @@ private ["_pos","_plots","_thePlot","_inList"];
_pos = _this select 0;
if (_pos < 0) exitWith {};
_toAdd = (Humans select _pos);
_plots = nearestObjects [player, ["Plastic_Pole_EP1_DZ"],15];
_plots = nearestObjects [[player] call FNC_getPos, ["Plastic_Pole_EP1_DZ"],15];
_thePlot = _plots select 0;
_friends = _thePlot getVariable ["plotfriends",[]];
_inList = false;
{ if ((_x select 0) == (_toAdd select 0)) exitWith { _inList = true; }; } forEach _friends;
{ if ((_x select 0) == (_toAdd select 0)) exitWith { _inList = true; }; } count _friends;
if (_inList) exitWith { cutText ["Already on the list", "PLAIN DOWN"]; };
if (count _friends == 6) exitWith { cutText ["Only 6 allowed","PLAIN DOWN"]; };
_friends = _friends + [_toAdd ];
if ((count _friends) == DZE_MaxPlotFriends) exitWith { cutText [format["Only %1 friends allowed", DZE_MaxPlotFriends], "PLAIN DOWN"]; };
_friends set [(count _friends), [_toAdd]];;
_thePlot setVariable ["plotfriends", _friends, true];
if (isServer) then {

View File

@@ -1,11 +1,11 @@
private ["_plots","_friendlies","_thePlot"];
lbClear 7002;
_plots = nearestObjects [player, ["Plastic_Pole_EP1_DZ"],15];
_plots = nearestObjects [[player] call FNC_getPos, ["Plastic_Pole_EP1_DZ"],15];
_thePlot = _plots select 0;
_friendlies = _thePlot getVariable ["plotfriends", []];
{
lbAdd [7002, (_x select 1)];
} forEach _friendlies;
} count _friendlies;

View File

@@ -2,16 +2,16 @@ private ["_list","_plots","_thePlot","_friends"];
_pos = _this select 0;
if (_pos < 0) exitWith {};
_plots = nearestObjects [player, ["Plastic_Pole_EP1_DZ"],15];
_plots = nearestObjects [[player] call FNC_getPos, ["Plastic_Pole_EP1_DZ"],15];
_thePlot = _plots select 0;
_friends = _thePlot getVariable ["plotfriends", []];
_toRemove = (_friends select _pos);
_newList = [];
{
if(_x select 0 != _toRemove select 0)then{
_newList = _newList + [_x];
_newList set [(count _newList), [_x]];
};
} forEach _friends;
} count _friends;
_thePlot setVariable ["plotfriends", _newList, true];
if (isServer) then {

View File

@@ -44,29 +44,17 @@ if(_IsNearPlot == 0) then {
};
} else {
if(!_isPole) then {
// plotManagement //
if( DZE_plotManagement ) then {
_friendlies = _nearestPole getVariable ["plotfriends",[]];
_fuid = [];
{
_friendUID = _x select 0;
_fuid = _fuid + [_friendUID];
} forEach _friendlies;
_builder = getPlayerUID player;
// check if friendly to owner
if(dayz_playerUID in _fuid) then {
_allowedUIDs = [_nearestPole, false, true] call dze_getPlotFriends;
if((dayz_playerUID in _allowedUIDs) || (dayz_characterID in _allowedUIDs)) then {
_canBuild = true;
};
} else {
// plotManagement //
_friendlies = player getVariable ["friendlyTo",[]];
// check if friendly to owner
if(_ownerID in _friendlies) then {
_canBuild = true;
};
// plotManagement //
};
// plotManagement //
};
};
};

View File

@@ -0,0 +1,28 @@
private ["_findNearestPoles","_AdminAccess","_IsNearPlot","_pole","_friendUID","_owner","_allowed","_friends","_fuid","_FindNearestPole"];
_pole = _this select 0;
_FindNearestPole = _this select 1;
_AdminAccess = _this select 2;
_IsNearPlot = 0;
_allowed = [];
if (_FindNearestPole) then {
_findNearestPoles = nearestObjects[[player] call FNC_getPos, ["Plastic_Pole_EP1_DZ"], DZE_PlotPole select 0];
_IsNearPlot = count (_findNearestPoles);
_pole = _findNearestPoles select 0;
};
if(!_FindNearestPole || {_IsNearPlot > 0}) then {
_owner = if(DZE_plotforLife) then { _pole getVariable ["ownerPUID","0"]; } else { _pole getVariable ["characterID","0"]; };
_allowed = [_owner];
_friends = _pole getVariable ["plotfriends", []];
_fuid = [];
{
_friendUID = _x select 0;
_fuid set [(count _fuid), _friendUID];
} count _friends;
if (_AdminAccess) then {
_allowed set [1, DZE_PlotManagementAdmins];
_allowed set [2, _fuid];
} else {
_allowed set [1, _fuid];
};
};
_allowed;

View File

@@ -413,72 +413,22 @@ if (!isNull _cursorTarget && !_inVehicle && !_isPZombie && (player distance _cur
};
};
//Allow owners to delete modulars
if (_isModular && (dayz_characterID == _ownerID)) then {
if (DZE_plotManagement) then {
if(_isModular || _isModularDoor) then {
if(_hasToolbox && "ItemCrowbar" in _itemsPlayer) then {
_player_deleteBuild = true;
};
};
// plotManagement //
if(_isModular && DZE_plotManagement) then {
if(_hasToolbox && "ItemCrowbar" in _itemsPlayer) then {
_findNearestPoles = nearestObjects[player, ["Plastic_Pole_EP1_DZ"], DZE_PlotPole select 0];
_IsNearPlot = count (_findNearestPoles);
_fuid = [];
_allowed = [];
if(_IsNearPlot > 0) then {
_thePlot = _findNearestPoles select 0;
_owner = if(DZE_plotforLife)
then { _thePlot getVariable ["ownerPUID","010"] }
else { _thePlot getVariable ["characterID","0"] };
_friends = _thePlot getVariable ["plotfriends", []];
{
_friendUID = _x select 0;
_fuid = _fuid + [_friendUID];
} forEach _friends;
_allowed = [_owner];
_allowed = [_owner] + _fuid;
if( (dayz_playerUID in _allowed) || (dayz_characterID in _allowed) ) then {
_allowedUIDs = [objNull, true, true] call dze_getPlotFriends;
if( (dayz_playerUID in _allowedUIDs) || (dayz_characterID in _allowedUIDs) ) then {
_player_deleteBuild = true;
};
};
};
};
// plotManagement //
//Allow owners to delete modular doors without locks
if (_isModularDoor && (dayz_characterID == _ownerID)) then {
} else {
if ((_isModularDoor || _isModular) && (dayz_characterID == _ownerID)) then {
if (_hasToolbox && "ItemCrowbar" in _itemsPlayer) then {
_player_deleteBuild = true;
};
};
// plotManagement //
if(_isModularDoor && DZE_plotManagement) then {
if(_hasToolbox && "ItemCrowbar" in _itemsPlayer) then {
_findNearestPoles = nearestObjects[player, ["Plastic_Pole_EP1_DZ"], DZE_PlotPole select 0];
_IsNearPlot = count (_findNearestPoles);
_fuid = [];
_allowed = [];
if(_IsNearPlot > 0)then{
_thePlot = _findNearestPoles select 0;
_owner = if(DZE_plotforLife)
then { _thePlot getVariable ["ownerPUID","010"] }
else { _thePlot getVariable ["characterID","0"] };
_friends = _thePlot getVariable ["plotfriends", []];
{
_friendUID = _x select 0;
_fuid = _fuid + [_friendUID];
} forEach _friends;
_allowed = [_owner];
_allowed = [_owner] + _fuid;
if( (dayz_playerUID in _allowed) || (dayz_characterID in _allowed) ) then {
_player_deleteBuild = true;
};
};
};
};
// plotManagement //
if (_isVehicle) then {
if ((_ownerID != "0") && {!_isMan} && {!_isBicycle}) then {
@@ -683,41 +633,23 @@ if (!isNull _cursorTarget && !_inVehicle && !_isPZombie && (player distance _cur
s_player_breakinhouse = -1;
};
if ((_cursorTarget isKindOf "Plastic_Pole_EP1_DZ") && {_canDo} && {speed player <= 1}) then {
// plotManagement //
// add Scroll-Menu to Plotpole
if( DZE_plotManagement && (s_player_plotManagement < 0) ) then {
_adminList = ["0152"]; //TODO: Add admins here if you admins to able to manage all plotpoles
_owner = if(DZE_plotforLife)
then { _cursorTarget getVariable ["ownerPUID","0"] }
else { _cursorTarget getVariable ["characterID","0"] };
_friends = _cursorTarget getVariable ["plotfriends", []];
_fuid = [];
{
_friendUID = _x select 0;
_fuid = _fuid + [_friendUID];
} forEach _friends;
_allowed = [_owner];
_allowed = [_owner] + _adminList + _fuid;
if( (dayz_playerUID in _allowed) || (dayz_characterID in _allowed) ) then {
if ((_cursorTarget isKindOf "Plastic_Pole_EP1_DZ") && {_canDo && speed player <= 1}) then {
if( DZE_plotManagement) then {
if (s_player_plotManagement < 0) then {
_allowedUIDs = [_cursorTarget, false, true] call dze_getPlotFriends;
if( (dayz_playerUID in _allowedUIDs) || (dayz_characterID in _allowedUIDs) ) then {
s_player_plotManagement = player addAction ["<t color='#0059FF'>Manage Plot</t>", "\z\addons\dayz_code\actions\plotManagement\initPlotManagement.sqf", [], 5, false];
};
};
// plotManagement //
if(!DZE_plotManagement) then {
} else {
if (s_player_maintain_area < 0) then {
s_player_maintain_area = player addAction [format["<t color='#ff0000'>%1</t>",localize "STR_EPOCH_ACTIONS_MAINTAREA"], "\z\addons\dayz_code\actions\maintain_area.sqf", "maintain", 5, false];
s_player_maintain_area_preview = player addAction [format["<t color='#ff0000'>%1</t>",localize "STR_EPOCH_ACTIONS_MAINTPREV"], "\z\addons\dayz_code\actions\maintain_area.sqf", "preview", 5, false];
};
};
} else {
// plotManagement //
player removeAction s_player_plotManagement;
s_player_plotManagement = -1;
// plotManagement //
player removeAction s_player_maintain_area;
s_player_maintain_area = -1;
player removeAction s_player_maintain_area_preview;

View File

@@ -46,8 +46,8 @@ DZE_SafeZonePosArray = []; //Prevent players in safeZones from being killed if t
DZE_GemOccurance = [["ItemTopaz",10], ["ItemObsidian",8], ["ItemSapphire",6], ["ItemAmethyst",4], ["ItemEmerald",3], ["ItemCitrine",2], ["ItemRuby",1]];; //Sets how rare each gem in the order shown when mining (whole numbers only)
/****** Advanced Trading Variables ***********/
DZE_GemWorthArray = [["ItemTopaz",15000], ["ItemObsidian",20000], ["ItemSapphire",25000], ["ItemAmethyst",30000], ["ItemEmerald",35000], ["ItemCitrine",40000], ["ItemRuby",45000]]; //array of gem prices, works only in advanced trading
DZE_advancedTrading = true; //Use advanced trading system. WARNING: set to false if you use database traders, you should use config-traders anyway!
DZE_GemWorthArray = [["ItemTopaz",15000], ["ItemObsidian",20000], ["ItemSapphire",25000], ["ItemAmethyst",30000], ["ItemEmerald",35000], ["ItemCitrine",40000], ["ItemRuby",45000]]; //array of gem prices, works only in advanced trading
Z_AT_FolderLocation = '\z\addons\dayz_code\actions\AdvancedTrading';
Z_VehicleDistance = 40; // Distance that a vehicle needs to be to see it's content or to sell it.
Z_SingleCurrency = false; // Does your server use a single currency system.
@@ -59,6 +59,8 @@ Z_MoneyVariable = "cashMoney"; // If using a Single currency system, change this
/////////// plotManagement Variables ///////////
// see also: https://github.com/DevZupa/PlotManagement
DZE_plotManagement = true;
DZE_PlotManagementAdmins = []; //Array of admin PlayerUIDs enclosed in quotations, UIDs in this list are able to access every pole's management menu and delete or build any buildable with a pole nearby
DZE_MaxPlotFriends = 6; //Maximum number of friends allowed on a plot pole. (default 6)
// see also: https://github.com/RimBlock/Epoch/tree/master/A%20Plot%20for%20Life
DZE_plotforLife = false; // NOT IMPLEMENTED. Set always to false - value is used by plotManagement
////////////////////////////////////////////////

View File

@@ -147,6 +147,7 @@ if (!isDedicated) then {
dog_findTargetAgent = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\dog_findTargetAgent.sqf";
dze_isnearest_player = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\dze_isNearestPlayer.sqf";
dze_buildChecks = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\dze_buildChecks.sqf";
dze_getPlotFriends = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\dze_getPlotFriends.sqf";
dze_requiredItemsCheck = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\dze_requiredItemsCheck.sqf";
dze_surrender_off = {player setVariable ["DZE_Surrendered",false,true]; DZE_Surrender = false;};
epoch_tempKeys = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\epoch_tempKeys.sqf";