Convert DZE_SafeZoneNoBuildItems to handle nested arrays for custom d… (#1934)

* Convert DZE_SafeZoneNoBuildItems to handle nested arrays for custom distances per items.

This makes the DZE_SafeZoneNoBuildItems be able to handle nested arrays,
This allows you to set custom distances per item instead of having it
all the default distance.

E.g DZE_SafeZoneNoBuildItems =
["VaultStorageLocked","LockboxStorageLocked",["Plastic_Pole_EP1_DZ",1300]];

* Fix forgotten exitWith syntax.

* Removed unneeded check.
This commit is contained in:
oiad
2017-04-09 10:45:29 +12:00
committed by ebayShopper
parent 89292b3f37
commit 992ab199dd
2 changed files with 26 additions and 5 deletions

View File

@@ -12,6 +12,25 @@ if (!canbuild) exitWith {dayz_actionInProgress = false; format[localize "STR_EPO
if (isNumber (configFile >> "CfgVehicles" >> _classname >> "requireplot")) then {
_requireplot = getNumber(configFile >> "CfgVehicles" >> _classname >> "requireplot");
};
_checkClass = {
private ["_checkOK","_distance"];
_checkOK = false;
_distance = DZE_SafeZoneNoBuildDistance;
{
if (typeName _x == "ARRAY") then {
if (_x select 0 == _classname) then {_checkOK = true; _distance = _x select 1;};
} else {
if (_x == _className) then {_checkOK = true};
};
if (_checkOK) exitWith {};
} count DZE_SafeZoneNoBuildItems;
[_checkOK,_distance]
};
_isPole = (_classname == "Plastic_Pole_EP1_DZ");
_isLandFireDZ = (_classname == "Land_Fire_DZ");
@@ -85,13 +104,15 @@ if ((count (nearestObjects [_center,_buildables,_distance])) >= DZE_BuildingLimi
_text = getText (configFile >> 'CfgMagazines' >> _item >> 'displayName');
if (((count DZE_SafeZoneNoBuildItems) > 0) && {_classname in DZE_SafeZoneNoBuildItems}) then {
_buildCheck = call _checkClass;
if (_buildCheck select 0) then {
{
if ((player distance (_x select 0)) < DZE_SafeZoneNoBuildDistance) exitWith { _canBuild = false; };
} forEach DZE_safeZonePosArray;
if ((player distance (_x select 0)) < _buildCheck select 1) exitWith {_canBuild = false;};
} count DZE_safeZonePosArray;
};
if !(_canBuild) exitWith { dayz_actionInProgress = false; format [localize "STR_EPOCH_PLAYER_166",_text,DZE_SafeZoneNoBuildDistance] call dayz_rollingMessages; [false, _isPole]; };
if !(_canBuild) exitWith {dayz_actionInProgress = false; format [localize "STR_EPOCH_PLAYER_166",_text,_buildCheck select 1] call dayz_rollingMessages; [false, _isPole];};
if ((count DZE_NoBuildNear) > 0) then {
_near = (nearestObjects [_pos,DZE_NoBuildNear,DZE_NoBuildNearDistance]);