Jump to content
Halvhjearne

Delete vehicles parked in safezones on restart

Recommended Posts

A guy on opendayz.net gave me this brilliant idea for a script, big thanks to titan!

 

IMPORTANT:

This can delete vehicles completely from the database!

beware that if not set correctly you can end up deleteing vehicles un-intended, wich is mainly the reason why i made a log of vehicle type,pos,cargo and so on when it is triggered

 

HOWEVER i can not stress this enough, backup, backup, backup ... before you use this!!!

 

after that warning, heres what i did ...

 

in server_monitor.sqf find this:

                    // total each vehicle
                    serverVehicleCounter set [count serverVehicleCounter,_type];
                };

add the line like this:

                    serverVehicleCounter set [count serverVehicleCounter,_type];
                };
                [_object] execVM "\z\addons\dayz_server\compile\Server_DeleteObjInsafezone.sqf";

now make a text file and call it server_deleteObjInsafezone.sqf and add this code:

/*
	VEHICLE CLEANUP ZONE
	Script by HALV
*/
_obj = _this select 0;

if (!isServer) exitWith {diag_log "Server_DeleteObjInsafezone.sqf - ERROR: NOT SERVER?"};

//\\\\\\\\\\\\\\\\\\\\ Setup Area ////////////////////\\

//vehicle types to Check for
_delVeh = ["Air","Landvehicle","Ship","Tank"];

//Action to take when vehicle is detected in a [VEHICLE CLEANUP ZONE]
//0 Delete vehicles ingame but keep in database. NOTE: This will stack vehicles in database if not cleaned propper
//1 Tp vehicles outside [VEHICLE CLEANUP ZONE] ("radius" + 50 meter to 4x "radius" from VEHICLE CLEANUP ZONE pos eg: if radius is 100 vehicles are moved 150-400 meter away)
//2 Tp vehicles to a position within 125m of _safespot (remember to set a position below)
//3 will delete vehicles completly from database
_Action = 1;

//if _Action = 2 then enter the position you desire here (default is by grozovoy pass around 022010)
_safespot = [2283.19,14255,0];
//how large radius to spread them in this area in meters (default 125m)
_radius = 125;

//damaged above this amoun, vehicle is deleted (set to 1 to only delete completely destroyed vehicles)
_dam = 0.90;

//if true will delete vehicles matching array below by default
_delbikmot = true;
//if above is true will delete these by default
_defdelar = ["Bicycle","Motorcycle","CSJ_GyroC","CSJ_GyroCover","CSJ_GyroP"];//,"ATV_Base_EP1"

//set to true, to unlock vehicles by default when TP'ed
_unlock = true;

//log text, this is what you want to look for in the logs, if you need to know something about a moved vehicle
_txt = "[VEHICLE CLEANUP ZONE]";

//Update vehicles to the hive, and make sure they are not moved each restart?
_updateHIVE = true;

//VEHICLE CLEANUP ZONE's/areas switch choosing the map name for cleanup location purposes
if(isNil "HALV_VEHICLE_CLEANUPZONES")then{
	diag_log format["%1: selecting world to cleanup ...",_txt];
	_WorldName = toLower format ["%1", worldName];
	switch (_WorldName)do {
//NAPF
		case "napf":{
//			diag_log format["%2: Cleanup zones for napf selected! (check: %1)",_WorldName,_txt]; //logging if right worldname was selected, if uncommented
			HALV_VEHICLE_CLEANUPZONES = [
			//position					//radius	//cityname/text
			[[8246.3184,15485.867,0],	125,		"Trader City Lenzburg"],
			[[15506.952,13229.368,0],	125,		"Trader city Emmen"],
			[[12399.751,5074.5273,0],	125,		"Trader City Schratten"],
			[[10398.626,8279.4619,0],	125,		"Bandit Vendor"],
			[[5149.9814,4864.1191,0],	125,		"Hero Vendor"],
			[[2122.7954,7807.9878,0],	100,		"West Wholesaler"],
			[[5379.0342,16103.187,0],	100,		"North Wholesaler"],
			[[6772.8877,16983.27,0],	100,		"Nordic Boats"],
			[[16839.973,5264.0566,0],	100,		"Pauls Boats"],
			[[15128.379,16421.879,0],	100,		"AWOLs Airfield"]
			];
		};
//chernarus
		case "chernarus":{
//			diag_log format["%2: Cleanup zones for chernarus selected! (check: %1)",_WorldName,_txt]; //logging if right worldname was selected, if uncommented
			HALV_VEHICLE_CLEANUPZONES = [
			//position					radius		cityname/text
			[[6325.6772,7807.7412,0],	125,		"Trader City Stary"],
			[[4063.4226,11664.19,0],	125,		"Trader City Bash"],
			[[11447.472,11364.504,0],	125,		"Trader City Klen"],
			[[1606.6443,7803.5156,0],	125,		"Bandit Camp"],
			[[12944.227,12766.889,0],	125,		"Hero Camp"],
			[[13441.16,5429.3013,0],	100,		"Wholesaler East"],
			[[4510.7773,10774.518,0],	100,		"Aircraft Dealer"],
			[[7989.3354,2900.9946,0],	100,		"Boat Dealer South"],
			[[13532.614,6355.9497,0],	100,		"Boat Dealer East"],
			[[4361.4937,2259.9526,0],	100,		"Wholesaler South"]
			];
		};
//tavi
		case "tavi":{
//			diag_log format["%2: Cleanup zones for tavi selected! (check: %1)",_WorldName,_txt]; //logging if right worldname was selected, if uncommented
			HALV_VEHICLE_CLEANUPZONES = [
			//position					//radius	//cityname/text
			[[11698.81,15210.121,0],	75,			"Trader City Lyepestok"],
			[[15309.663,9278.4912,0],	75,			"Trader City Sabina"],
			[[5538.7354,8762.2695,0],	75,			"Trader City Bilgrad"],
			[[7376.6084,4296.5879,0],	75,			"Trader City Branibor"],
			[[10948.426,654.90265,0],	75,			"Bandit Vendor"],
			[[15587.822,16394.049,0],	75,			"Hero Vendor"],
			[[16555.732,10159.68,0],	75,			"Aircraft Dealer"],
			[[6815.0776,8534.1504,0],	75,			"Aircraft Dealer 2"],
			[[4066.3528,7265.0024,0],	75,			"Misc. Vendor"],
			[[17497.631,7159.0879,0],	75,			"Misc. Vendor 2"],
			[[17332.115,12930.239,0],	75,			"Boat Dealer"],
			[[10570.494,16772.477,0],	75,			"Boat Dealer 2"],
			[[10698.463,5983.665,0],	75,			"Boat Dealer 3"],
			[[5419.2437,9503.5479,0],	75,			"Boat Dealer 4"],
			[[13342.758,8611.9932,0],	75,			"Wholesaler"],
			[[9859.4209,7471.5684,0],	75,			"Wholesaler"] // <-- no comma for last entry
			];
		};
/*
//myworldname
		case "myworldnameinlowercase":{
//			diag_log format["%2: Cleanup zones for myworldnameinlowercase selected! (check: %1)",_WorldName,_txt]; //logging if right worldname was selected, if uncommented
			HALV_VEHICLE_CLEANUPZONES = [
			//position					//radius	//cityname/text
			[[7839.60,8414.73,381.33],	150,		"my custom zone marker"],
			[[7839.60,8414.73,381.33],	75,			"my custom location"] // <-- no comma for last entry
			];
		};
*/
//default
		default{
			diag_log format["%2: Cleanup zones for %1 not availible ...",_WorldName,_txt]; //logging if right worldname was selected, if uncommented
			HALV_VEHICLE_CLEANUPZONES = [
			//position	//radius	//cityname/text
			[[0,0,0],	1,			"DEBUG"]
			];
		};
	};
};
//\\\\\\\\\\\\\\\\\\\\  End Setup Area ////////////////////\\

/////////////// dont touch anything below this line unless you know what you are doing \\\\\\\\\\\\\\\

_possiblematch = false;
{if(_obj isKindOf _x)then{_possiblematch=true;};}forEach _delVeh;
if(_possiblematch)then{
	{
	_Spos = _x select 0;
	_Rad = _x select 1;
	_name = _x select 2;
	_radats = _Rad+50;
	_radx4 = _Rad+_Rad+_Rad+_Rad;
		if(_obj distance _Spos < _Rad)then{
			_defdel		= false;
			_typeOf		= typeOf _obj;
			_pos		= getpos _obj;
			_mags		= getmagazinecargo _obj;
			_weaps		= getweaponcargo _obj;
			_packs		= getbackpackcargo _obj;
			_objID		= _obj getVariable["ObjectID","0"];
			_objUID		= _obj getVariable["ObjectUID","0"];
			_objname	= (gettext (configFile >> 'CfgVehicles' >> _typeOf >> 'displayName'));
			diag_log format["%1: %2 (%3) by %4 @%5 %6 [ID:%7,UID:%8] Cargo: [%9,%10,%11]",_txt,_typeOf,_objname,_name,mapgridposition _pos,_pos,_objID,_objUID,_weaps,_mags,_packs];
			if(_delbikmot)then{{if(_obj isKindOf _x)then{_defdel = true};}forEach _defdelar;};
			if(_defdel)then{_Action=3;diag_log format["%2: %1 is Model to delete by default!",_typeOf,_txt];};
			if(getDammage _obj > _dam)then{_Action=3;diag_log format["%2: %1 too damaged",_typeOf,_txt];};
			if(_unlock and !_defdel and (locked _obj))then{_obj setVehicleLock "UNLOCKED";_obj setVariable ["R3F_LOG_disabled",false,true];diag_log format["%2: %1 Un-Locked",_typeOf,_txt];};
			switch(_Action)do{
				case 0:{deleteVehicle _obj;diag_log format["%2: %1 Deleted, but remains in DB (Dont forget to clean this up)",_typeOf,_txt];};
				case 1:{
					_newPos = [_Spos, _radats, _radx4, 10, 0, 2000, 0] call BIS_fnc_findSafePos;
					_obj setpos _newPos;
					//update to HIVE?
					if(_updateHIVE)then{
					private["_position","_worldspace","_fuel","_key"];
						_position = getPosATL _obj;
						_worldspace = [
							round(direction _obj),
							_position
						]; 
						_fuel = fuel _obj;
						_key = format["CHILD:305:%1:%2:%3:",_objID,_worldspace,_fuel];
						diag_log ("HIVE: WRITE: "+ str(_key));
						_key call server_hiveWrite;
					};
					diag_log format["%6: %5 TP from %1 %2 to %3 %4",_pos,mapgridposition _pos,_newPos,mapgridposition _newPos,_typeOf,_txt];
				};
				case 2:{
					_newPos = [_safespot, 0, _radius, 10, 0, 2000, 0] call BIS_fnc_findSafePos;
					_obj setpos _newPos;
					//update to HIVE?
					if(_updateHIVE)then{
					private["_position","_worldspace","_fuel","_key"];
						_position = getPosATL _obj;
						_worldspace = [
							round(direction _obj),
							_position
						];
						_fuel = fuel _obj;
						_key = format["CHILD:305:%1:%2:%3:",_objID,_worldspace,_fuel];
						diag_log ("HIVE: WRITE: "+ str(_key));
						_key call server_hiveWrite;
					};
					diag_log format["%6: %5 TP from %1 %2 to %3 %4",_pos,mapgridposition _pos,_newPos,mapgridposition _newPos,_typeOf,_txt];
				};
				default{_msg = format["%2: %1",_typeOf,_txt];deleteVehicle _obj;[_objID,_objUID,_msg] call server_deleteObj;};
			};
		};
	}forEach HALV_VEHICLE_CLEANUPZONES;
};

script can do quite a few options now:

 

Delete (not from database, will still require cleanup or it will clonk up db at some point)

Delete (als from database)

TP outside safezone
TP to "safe" location
 

you can edit what to delete, areas, distance to areas

can be set to always delete certain vehicles (like bikes/motorcycle/ATV) by default

can be set to delete damaged vehicles by default

can be set to unlock vehicles when moved

 

will work out of the box on chernarus, napf and taviana

 

i tried to comment for easy edit

 

after your edits, put this file in the complie folder of your server pbo and restart server.

 

all vehicles in safezones when server restarts are now only a small notice in the rpt file with info on city name, where it came from, type, current position and cargo [weapons,mags,bags].

 

 

enjoy ;)

Share this post


Link to post
Share on other sites

So if I wanted to put a specific point for the teleport, i would just change the following from:

_newPos = [_pos, 200, 400, 10, 0, 2000, 0] call BIS_fnc_findSafePos;

to:

_newPos = [[8189.45,9045.18,0.001], 10, 200, 10, 0, 2000, 0] call BIS_fnc_findSafePos;

where the [8189.45,9045.18,0.001] is the coordinates for the new position, where we send the following info to BIS_fnc_findSafePos:

 

[8189.45,9045.18,0.001] = target position,

with a minimum distance of 10,

maximum distance of 200,

with a distance of 10 from nearest object,

and it cant be in water (as 0),

and the terrain can be as steep as 2000

with all of this being shoremode (as 0).

 

Correct?

 

Share this post


Link to post
Share on other sites

 

i never saw that before, some guy on opendayz had made a script to be executed clientside, so i made my own version, and i still like my version better overall ... thanks for showing me tho, it gave me some good ideas, as to how i can check and delete the destroyed ones, instead of moving/deleting them and also you showed me how i could possibly move it up before it gets created instead of spending resouces of creating if its deleted or moved again anyway.

 

however i think server impact diffrence will be minimal on either, since its only ran once when server starts, but it should still be done right tho.

Share this post


Link to post
Share on other sites

added update, with option to set to delete damaged vehicles by default, option to delete certain vehicles by default (like bikes/moto/atv), changed safezone tp to tp around safezone and not vehicle pos, removed some minor irrelevant errors and added city name in log of where vehicle was to begin with.

 

 

i thought about your version too macca, but decided that for now i will just leave mine like this, since impact is minimal either way

Share this post


Link to post
Share on other sites

Hi Halvhjearne,

 

Thanks for sharing this.

 

I have this working well with option 2 (teleport to a static location), but am having trouble amending it to unlock the vehicles when it does so.  I have tried added ownerID = "0"; from Macca's version to Case statement 2 but this didn't work.  I also tried using _obj setvariable ("ownerID", 0, true), but still no joy.

 

Do you have any ideas where I might be going wrong?

 

Thanks.

Share this post


Link to post
Share on other sites

nice one mate, will give it a go and report back here.

 

by the way, is there a reference of methods/variables that I can look-up somewhere, or is it just a case of hacking through the code and working it out?

Share this post


Link to post
Share on other sites
Napf Trader Areas
_safezones = [
[8246.3184,15485.867,0], //Lenz
[15506.952,13229.368,0], //Emmen
[12399.751,5074.5273,0], //Schratten
[10398.626,8279.4619,0], //Bandit
[5149.9814,4864.1191,0], //Hero
[2122.7954,7807.9878,0], //Wholesale1
[5379.0342,16103.187,0], //Wholesaler
[6772.8877,16983.27,0], //boat1
[16839.973,5264.0566,0], //boat2
[15128.379,16421.879,0] //awol
];

Share this post


Link to post
Share on other sites

this script is removing vehicles from peoples bases for me. for example someone has a base at altar and their vehicles keep getting deleted. vehicles to safezones work it's just that in some other places vehicles are getting removed. thanks in advance =D

Share this post


Link to post
Share on other sites

for the _safespot=[2283.19,14255,0];

 

my admin debug shows my location that I want vehicles to be teleported to is

4257.15,7579.67.360822

 

would I just get rid of the last numbers  .360822   thats hight ??? dont need that  sooo I should have

for the _safespot=[4257.15,7579.67,0];

 

am I correct  in my guess ??

Share this post


Link to post
Share on other sites

my RPT file dumbed this a couple times

Error in expression <lar"];
_obj = _this select 0;
_typeOf = typeOf _obj;

_delVeh = ["Air","Landvehi>
2014/03/27, 22:58:32 Error position: <typeOf _obj;

_delVeh = ["Air","Landvehi>
2014/03/27, 22:58:32 Error typeof: Type String, expected Object
2014/03/27, 22:58:32 File z\addons\dayz_server\compile\server_deleteObj.sqf, line 4

Share this post


Link to post
Share on other sites

Yes, use Maca's script in server_monitor.sqf and remove the damage call

{
    if ((_pos distance _x) < 75) then {    
           
        _ownerID = "0";
    };
} forEach [zonestary, zonebash, zoneklen];

You would need to define the safezones in mission.sqm

 

Or you could run it with only the most damaged vehicles removed

{
    if ((_pos distance _x) < 75) then {
        if (_damage > 0.9) then {
            _damage = 1;
            [_idKey,false,"SERVER"] call server_deleteObj;
            diag_log format["DELETING SAFEZONE VEHICLE: %1", [_idKey, _type]];
        };
        _ownerID = "0";
    };
} forEach [zonestary, zonebash, zoneklen];

Share this post


Link to post
Share on other sites

I would really like  the option to just unlock vehicles left in traderzones.

I tried maca's but it didnt work for me.

 

the reason is all vehicles are currently tp to a location then left unlocked

 

so now a player takes the vehicle drives around then  the following restart its locked again and  just going to sit there forever.. adding  more and more to db

 

could you add this option to your script ??? please

Share this post


Link to post
Share on other sites

will this work for the locations?
 

_safezones = [
	[[4763.8818,7484.0034],100, "AirVehiclesF"], 
	[[5232.6299,8228.4785],75, "WholesalerNorth"],
	[[9056.7129,4073.5034],75, "HeroVehicles"],
	[[1891.7347,3611.1328],75, "NeutralAirVehicles"],
	[[3349.3503,2311.5425],75, "Boats"],
	[[8687.3086,3137.5818],75, "NeutralTraders"],
	[[4422.4429,1629.3304],75, "NeutralTraderCity2"],
	[[7224.3823,727.15576],75, "WholesaleSouth"],
	[[4338.8359,6317.54],75, "PlanicaTraders"],
	[[2247.085,9473.3262],75, "IslandVehiclePartsVendors"],
	[[3804.6707,7656.6055],75, "Boat2"]
];

Share this post


Link to post
Share on other sites

I would really like  the option to just unlock vehicles left in traderzones.

I tried maca's but it didnt work for me.

 

the reason is all vehicles are currently tp to a location then left unlocked

 

so now a player takes the vehicle drives around then  the following restart its locked again and  just going to sit there forever.. adding  more and more to db

 

could you add this option to your script ??? please

I'm also dealing with this issue, is there any fix for this? id like them to stay unlocked after a following restart.

Share this post


Link to post
Share on other sites

Nice one Halv. This is a good idea. If I get bored enough, I might make an "impound lot" somewhere and have the vehicles teleport there. Maybe someone could even figure out how to set an NPC at the impound lot and perhaps charge players to get their vehicles back, that would be hilarious!

Share this post


Link to post
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


  • Similar Content

    • By Irradiated Beef
      Howdy folks, sorry to ask what should be an obvious and easy thing, but my searches over the last two days haven't found me a current answer.
      Apparently in the older versions of Epoch, you would add vehicles by editing the allowedvehicleslist,  however that seems to have changed in later versions, as the list is no longer there. I found some documents that state it's in the mission.pbo, some that state it's in the epochconfig.hpp (there's a reference to it but no actual list), and some that state it should be somewhere else in the epoch_server_settings, but I've come up completely blank.
      Does anyone happen to know where this is in the current (Epoch 1.0) release? 
      Considering most documentation I'm finding is several years old, I can only assume I'm looking in the wrong places. :( 
    • By Dank Professor
      Connection Info: 199.60.101.242:2302
      Addons: @EPOCH
      Steam Group Page: http://steamcommunity.com/groups/ApricotCrew
      Discord: https://discord.gg/tHVsxqU
      Team Speak Server: 216.105.171.14:10158
      Web (under construction): http://apricotcrew.com/

      Group Description:  Apricot Crew—a gaming community built on mutual respect
      Are you tired of TS servers full of dictators, crazy rules, and painful disruptions to your gaming experience? Look no further, you finally found a place to call "home." Apricot Crew is a community of like minded gamers. If you respect us, we'll respect you.
      For the love of the game, have fun!
       
      P.S.  We started this server as a bunch of friends who wanted a dedicated place to play Epoch.  Come try it so we can have more people on at once...
    • By loki_bagel
      look man, its fun and all, but, its not fun when theres nobody on
      regular-ish airdrops with some pretty good stuff
      admins usually on 
      noob friendly
       
       
    • By Thug
      [SOLVED]
      All below has to do with a spawned in truck being used as a loot crate.
      this setHit [""wheel_2_3_steering"", 1];
      I know that the 2 points to the right side of the vehicle. 3 points to the middle tire.
      The 1, if let at 1 removes the tire. I'm i right so far?  If so, if I lower the 1 to  lets say  0.50 it will leave the tire on and have 50% damage?
    • By harcosgoogle
      Hi!
       
      Repair and Salvage Script 1.0.6.1?
       
       
  • Advertisement
  • Donation Box

    Please donate to support the community.
    We appreciate all donations!
  • Advertisement
  • Supporters
  • Latest Donations

  • Advertisement
  • Discord

×