Jump to content

[Release] Safe Zone Relocate


salival

Recommended Posts

Hi,

Here's a simple safe zone relocation script for vehicles. 

  • Simple relocate only safe zone script.

  • Extremely quick and low overhead since we're only scanning the safe zone array instead of every vehicle.

  • Uses the Epoch DZE_SafeZonePosArray for convenience.

Install instructions and download link: https://github.com/oiad/safeZoneRelocate

Link to comment
Share on other sites

Simple, small and clean useful script. As always, good work! I like the idea. That's better than deleting the vehicles.

I will probably add that the vehicles that are relocated get unlocked so everybody can take them (to punish the owner who parked in the safezone).
But anyways, thanks for that!

Link to comment
Share on other sites

9 hours ago, DAmNRelentless said:

Simple, small and clean useful script. As always, good work! I like the idea. That's better than deleting the vehicles.

I will probably add that the vehicles that are relocated get unlocked so everybody can take them (to punish the owner who parked in the safezone).
But anyways, thanks for that!

Yeah, I don't like forcibly unlocking vehicles since someone might have disconnected from the server legitly i.e internet died or something.

Link to comment
Share on other sites

1 hour ago, salival said:

Yeah, I don't like forcibly unlocking vehicles since someone might have disconnected from the server legitly i.e internet died or something.

Also true but I mean you could do that with a timer so they only get unlocked after 10 or 15 mins of inactivity.

Link to comment
Share on other sites

I Just want to add that this version of salivals relocate script was meant to be much cleaner and optimized for 1061, compared to Halvs version for earlier versions of epoch. I asked salival to release his version.

Now, with these posts, specially with the database question about deleting the key, we are just falling back on the older script...

The old one works, its the one i HAD running on my server. But salivals is cleaner, for that specific reason.

 

Link to comment
Share on other sites

7 hours ago, theduke said:

I Just want to add that this version of salivals relocate script was meant to be much cleaner and optimized for 1061, compared to Halvs version for earlier versions of epoch. I asked salival to release his version.

Now, with these posts, specially with the database question about deleting the key, we are just falling back on the older script...

The old one works, its the one i HAD running on my server. But salivals is cleaner, for that specific reason.

 

Hi guys,

I cleaned up the thread a bit.

I wrote this script to be a SIMPLE relocate script with low overhead. I didn't want to add unlocking (which is stupid and unfair to legitimate players)

There are a lot of other safe zone scripts that will do the unlocking (unfair) deleting (unfair) and you are more than welcome to use them.

Link to comment
Share on other sites

2 minutes ago, DAmNRelentless said:

@salival That's okay but why you deleted the posts with the configurable position? So they get moved to a specific location? There was no unlocking in this code. :D

I would only assume its because there are already scripts like that in the forums. This was meant to do one thing, and it ended up starting to do the same things as the other ones..

Link to comment
Share on other sites

4 minutes ago, DAmNRelentless said:

@salival That's okay but why you deleted the posts with the configurable position? So they get moved to a specific location? There was no unlocking in this code. :D

I am okay with moving vehicles to a specific position, i.e a junkyard, but im not interested in unlocking or deleting since that punishes legitimate players that either a) didn't know better or b) mom told them they had to go do the dishes.

Link to comment
Share on other sites

1 minute ago, salival said:

I am okay with moving vehicles to a specific position, i.e a junkyard, but im not interested in unlocking or deleting since that punishes legitimate players that either a) didn't know better or b) mom told them they had to go do the dishes.

Made my day! :D

Okay then final post: For those guys that want to move the vehicles out of the safezone to a specific location, go to dayz_server\init\safeZoneRelocate.sqf and search this line:

_position = [_safeZonePos,_safeZoneRadius + 50,_maxDist,_objDist,if (_x isKindOf "Ship") then {2} else {0},0,0,[],[_safeZonePos,_safeZonePos]] call BIS_fnc_findSafePos;

And replace it with:

_position = [[YOUR COORDINATES],15,250,10,if (_x isKindOf "Ship") then {2} else {0},0.5,0] call BIS_fnc_findSafePos;

 

Link to comment
Share on other sites

7 minutes ago, DAmNRelentless said:

Made my day! :D

Okay then final post: For those guys that want to move the vehicles out of the safezone to a specific location, go to dayz_server\init\safeZoneRelocate.sqf and search this line:


_position = [_safeZonePos,_safeZoneRadius + 50,_maxDist,_objDist,if (_x isKindOf "Ship") then {2} else {0},0,0,[],[_safeZonePos,_safeZonePos]] call BIS_fnc_findSafePos;

And replace it with:


_position = [[YOUR COORDINATES],15,250,10,if (_x isKindOf "Ship") then {2} else {0},0.5,0] call BIS_fnc_findSafePos;

 

Just bare in mind, you need to test this properly, if BIS_fnc_findSafePos can't find a safe position, it will fail to find a position. I'll do an update to this script to do a "junk yard" style parking lot

Link to comment
Share on other sites

1 minute ago, salival said:

Just bare in mind, you need to test this properly, if BIS_fnc_findSafePos can't find a safe position, it will fail to find a position. I'll do an update to this script to do a "junk yard" style parking lot

I am using this already and it works quite fine for me but ofcourse you could at the last optional parameter to define a default position if no safe position was found. If you update this, it would be nice if you do that.

Link to comment
Share on other sites

I have updated the script to reflect the changes wanted regarding a custom vehicle dump / junk yard.

I have tested this with: land vehicles, air and boats and it works as intended, you will need to fiddle with the _customRadius and _maxDist variables to get things optimized if you are going to use a custom position, though. I found it makes a big difference in where the vehicles are spawned.

https://github.com/oiad/safeZoneRelocate/commit/2b7c5a9c03c0646de544e166debba0d195d92ce9

https://github.com/oiad/safeZoneRelocate

 

Link to comment
Share on other sites

  • 6 months later...
  • 4 months later...

As far as anything broke goes i doubt it since i get no errors in server side or client side, also the DZE_SafeZonePosArray is referenced in other places which are working good.

could you humor me and tell me if with the added diag_log format should be displayed regardless of variables true or false ? ive added two 

diag_log format ["[SAFEZONE] Making Sure: %1",_x];

it should display on server log as soon as server starts right ?

/*
	Safe Zone Relocate by salival (https://github.com/oiad)
*/

private ["_customPosition","_customRadius","_maxDist","_maxDamage","_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;
_customRadius = 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 this amount of damage will be deleted

{
	_safeZonePos = _x select 0;
	_safeZoneRadius = _x select 1;
	_nearVehicles = _safeZonePos nearEntities [["Air","LandVehicle","Ship"],_safeZoneRadius];
	diag_log format ["[SAFEZONE] Making Sure: %1",_x];
	{
		diag_log format ["[SAFEZONE] Making Sure: %1",_x];
		if (damage _x > _maxDamage) then {
			deleteVehicle _x;
			[_x getVariable["ObjectID","0"],_x getVariable["ObjectUID","0"],"safeZoneRelocate"] call server_deleteObjDirect;
			diag_log format ["[SAFEZONE] %1 was deleted from the server for being too damaged before relocate: @%2 %3",typeOf _x,mapGridPosition _x,getPosATL _x];
		} else {
			if (_useCustomPosition) then {
				_position = [_customPosition,_customRadius,_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"};

			diag_log format ["[SAFEZONE] %1 was moved out of a safe zone to: @%2 %3",typeOf _x,mapGridPosition _position,_position];
		};
	} forEach _nearVehicles;
} forEach DZE_safeZonePosArray;

 

Link to comment
Share on other sites

12 minutes ago, SmokeyBR said:

As far as anything broke goes i doubt it since i get no errors in server side or client side, also the DZE_SafeZonePosArray is referenced in other places which are working good.

could you humor me and tell me if with the added diag_log format should be displayed regardless of variables true or false ? ive added two 


diag_log format ["[SAFEZONE] Making Sure: %1",_x];

it should display on server log as soon as server starts right ?


/*
	Safe Zone Relocate by salival (https://github.com/oiad)
*/

private ["_customPosition","_customRadius","_maxDist","_maxDamage","_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;
_customRadius = 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 this amount of damage will be deleted

{
	_safeZonePos = _x select 0;
	_safeZoneRadius = _x select 1;
	_nearVehicles = _safeZonePos nearEntities [["Air","LandVehicle","Ship"],_safeZoneRadius];
	diag_log format ["[SAFEZONE] Making Sure: %1",_x];
	{
		diag_log format ["[SAFEZONE] Making Sure: %1",_x];
		if (damage _x > _maxDamage) then {
			deleteVehicle _x;
			[_x getVariable["ObjectID","0"],_x getVariable["ObjectUID","0"],"safeZoneRelocate"] call server_deleteObjDirect;
			diag_log format ["[SAFEZONE] %1 was deleted from the server for being too damaged before relocate: @%2 %3",typeOf _x,mapGridPosition _x,getPosATL _x];
		} else {
			if (_useCustomPosition) then {
				_position = [_customPosition,_customRadius,_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"};

			diag_log format ["[SAFEZONE] %1 was moved out of a safe zone to: @%2 %3",typeOf _x,mapGridPosition _position,_position];
		};
	} forEach _nearVehicles;
} forEach DZE_safeZonePosArray;

 

Yes, that looks fine.

The first one will show the safezone postion, the second one will show the vehicle it's currently checking.

Link to comment
Share on other sites

so heres something weird that i do not understand.

The first "Making Sure" shows up fine the second however does not i even thought of adding another line bellow the second "making sure" with 

	_nearVehicles = _safeZonePos nearEntities [["Air","LandVehicle","Ship"],_safeZoneRadius];
	diag_log format ["[SAFEZONE] Making Sure: %1",_x];
	{
		diag_log format ["[SAFEZONE] Making Sure: %1",_x];
		diag_log format ["[SAFEZONE] Double Sure"];
		if (damage _x > _maxDamage) then {

doubted it wanst displaying because there was no value to display, ideias ?

Link to comment
Share on other sites

OMG so stupid....

It was something wrong with the DZE_SafeZonePosArray  like you said, only it was not broken i copied trader positions from mission.sqm for some reason that i cant recall, and in the process ended up with really high heights > 100, which is why it was not working.

anyways thx.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Discord

×
×
  • Create New...