mirror of
https://github.com/EpochModTeam/DayZ-Epoch.git
synced 2025-12-14 12:12:34 +03:00
Add toggleable Safe Zone Relocate by salival
This commit is contained in:
@@ -23,6 +23,9 @@ if (isServer) then {
|
||||
|
||||
// ZSC
|
||||
Z_globalBankingTraders = false; // Enable banking NPCs at trader cities.
|
||||
|
||||
// Safe Zone Relocating
|
||||
DZE_SafeZone_Relocate = false; //Enables relocating of vehicles left in Safe Zones over a server restart.
|
||||
};
|
||||
|
||||
// Client
|
||||
|
||||
39
SQF/dayz_server/system/safeZoneRelocate.sqf
Normal file
39
SQF/dayz_server/system/safeZoneRelocate.sqf
Normal file
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
Safe Zone Relocate by salival (https://github.com/oiad)
|
||||
*/
|
||||
|
||||
private ["_customPosition","_minDist","_maxDist","_maxDamage","_message","_nearVehicles","_objDist","_position","_safeZonePos","_safeZoneRadius","_useCustomPosition","_unlock"];
|
||||
|
||||
_useCustomPosition = false; // Enable a custom position to move vehicles to (i.e a junk yard)
|
||||
_customPosition = [6942.64,15121.6,0]; // Position for vehicles to be moved to if _useCustomPosition = true;
|
||||
_minDist = 5; // Minimum distance from the custom position to move vehicles to
|
||||
_maxDist = 1000; // Maximum distance from the safe zone position to find a safe position or custom position for relocation, setting this too low can make vehicles spawn very close to other vehicles.
|
||||
_objDist = 15; // Minimum distance from the safe position for relocation to the center of the nearest object. Specifying quite a large distance here will slow the function and might often fail to find a suitable position.
|
||||
_unlock = false; // Unlock vehicle when moved from the safe zone?
|
||||
_maxDamage = 0.75; // Vehicles above or equal to this amount of damage will be deleted
|
||||
|
||||
{
|
||||
_safeZonePos = _x select 0;
|
||||
_safeZoneRadius = _x select 1;
|
||||
_nearVehicles = _safeZonePos nearEntities [["Air","LandVehicle","Ship"],_safeZoneRadius];
|
||||
{
|
||||
if (damage _x >= _maxDamage) then {
|
||||
_message = format ["[SAFEZONE] %1 was deleted from the server for being too damaged before relocate: @%2 %3",typeOf _x,mapGridPosition _x,getPosATL _x];
|
||||
diag_log _message;
|
||||
[_x getVariable["ObjectID","0"],_x getVariable["ObjectUID","0"],_x] call server_deleteObjDirect;
|
||||
deleteVehicle _x;
|
||||
} else {
|
||||
if (_useCustomPosition) then {
|
||||
_position = [_customPosition,_minDist,_maxDist,_objDist,1,0,0,[]] call BIS_fnc_findSafePos;
|
||||
} else {
|
||||
_position = [_safeZonePos,(_safeZoneRadius + 50),_maxDist,_objDist,if (_x isKindOf "Ship") then {2} else {0},0,0,[],[_safeZonePos,_safeZonePos]] call BIS_fnc_findSafePos;
|
||||
};
|
||||
_x setPos _position;
|
||||
[_x,"position"] call server_updateObject;
|
||||
if (_unlock && {locked _x}) then {_x setVehicleLock "UNLOCKED"};
|
||||
|
||||
_message = format ["[SAFEZONE] %1 was moved out of a safe zone to: @%2 %3",typeOf _x,mapGridPosition _position,_position];
|
||||
diag_log _message;
|
||||
};
|
||||
} forEach _nearVehicles;
|
||||
} forEach DZE_safeZonePosArray;
|
||||
@@ -466,4 +466,7 @@ if (_hiveLoaded) then {
|
||||
//Update gear last after all dynamic vehicles are created to save random loot to database (low priority)
|
||||
{[_x,"gear"] call server_updateObject} count _vehiclesToUpdate;
|
||||
};
|
||||
if (DZE_SafeZone_Relocate) then {
|
||||
execVM "\z\addons\dayz_server\system\safeZoneRelocate.sqf";
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user