Jump to content
  • 0

Script to remove vehicles at traders?


MGT

Question

Trying to script something to remove dumped vehicles left at trader cities at server restart or at set times. Am trying to use the !canbuild event as a location trigger. Anyone else working on something like this?

The situation of dumped vehicles at traders has become worse since now only the driver/owner can sell the vehicle.

Link to comment
Share on other sites

Recommended Posts

  • 0

omg, I want something like this soooo bad.

 

My thinking was that you could write a SQL query that will check within a set worldspace range and delete the vehicles in the DB?

 

I don't even know if that's possible.

 

Other option would be to use a sensor to trigger an .sqf script?

 

Just spit balling ideas at this point.

Link to comment
Share on other sites

  • 0

I was thinking in the line of using the daytime command (if it exists in dayz too) and implement it with yours (@maca134) safezone script. 

Basicly meaning that at a certain time of the day, with the daytime command the script becomes active and deletes all vehicles parked inside the zone. Acting just like a safezone works.

So the script is initialized but lays dormant till that time.

Dunno if that would work, just a theory. 
 

daytime > 19

http://www.kylania.com/ex/?p=97


Just a snippet:
 

if daytime > 19 = true { // should it really be ">" and not "="? (24h)

SafeZoneEnable = {
	hintSilent "Do not park you cars here, traffic wardens are watching.";
	player setDamage = 1; // cant remember the vehicle damage function :)
	};
	
};forEach _safezones; //Seemd important so I used it.

As you can see, I am terrible at scripting and have no real talent in it so I'll just leave this here as theoretical scenario.


If my ideas are completely out of bounds, disregard them :) 

Link to comment
Share on other sites

  • 0

Lol maca that was a good laugh :P

Anyway you can do that in SQL but a simple arma script would be easy to code and more versatile i think.

 

A script to delete vehicles then set to damaged status 1 within the canbuild=false area that could be called at server startup only would be the best method.

The situation has got worse since no one else can sell the vehicles that are left in the spawn area. Then its compounded by players thinking its going to be ok to buy a new vehicle, the pile gets bigger ;)

Link to comment
Share on other sites

  • 0

another way this could be done is to modify the self actions script when the player locks the vehicle. Check if the vehicle is within a set distance from an array of positions and if it is set a timer to auto unlock and inform the player of how much time he has. That way a player can still lock the vehicle in the trader zone, do what he wants and if he doesnt return to the vehicle and move it, it will get unlocked automatically.

 

This wouldnt really clean the vehicles at trader zones but would probably stop people from leaving vehicles they want there. Vehicles that people dont want that are left in the trader zone will then get unlocked and are free for anyone else to use/sell. This would probably be easier to implement and wouldnt really cause as much of an issue. You could also set it so as on server start the locations are checked again for locked vehicles and then just unlock them all too.

Link to comment
Share on other sites

  • 0

You can also just download PrivateHiveTools and delete the vehicle from the live map.

 

We do this already using a tool, but 4 servers with high player numbers mean a lot of vehicles left at traders like they're a parking lot.

Link to comment
Share on other sites

  • 0

Ideally I would like to see a script where it teleports or deletes the vehicle after a set period of time (configurable by server owner) like 15minutes after spawned, if it's still in the sensor area it's teleported or removed from the server.

 

If it's teleported it could go to an impound lot :D

Link to comment
Share on other sites

  • 0

ok i had 5 minutes time to script a little function for you guys, I hope this is what you want:

private ["_clearAreas","_radius","_vehicles","_objectID","_objectUID"];

_clearAreas = [zonestary, zonebash, zoneklen]; // use sensor names or positions like [x,y,z]
_radius = 100;

{
	_vehicles = _x nearObjects ["AllVehicles", _radius];
	{
		_objectID = _x getVariable ["ObjectID", "0"];
		_objectUID = _x getVariable ["ObjectUID", "0"];
		[_objectID, _objectUID, "CLEAR_AREA"] call server_deleteObj;
		deleteVehicle _x;
		diag_log format ["CLEAR_AREA: removed vehicle %1 (%2) at position %3", typeOf _x, _objectID, position _x];
	} forEach _vehicles;
} forEach _clearAreas;

this will delete all vehicles near stary, bash and klen trade zone within a 100m radius. with delete i mean from the database and the game, so be careful. I've also added a log statement.

the variable _clearAreas defines the center positions of the areas you want to clean. YES, you can use sensor names from the mission.sqm for my script or just your own position in the format [x,y,z] as always (markers or other objects should also work if you want to use that).

 

my advice to call that script would be on the server in the file "dayz_server\system\server_monitor.sqf" after the spawn_vehicles loop (around line 292), if you want to remove all vehicles after each server restart.

you can save the file as clear_area.sqf in the dayz_server.pbo and then call it like this:

execVM "\z\addons\dayz_server\clear_area.sqf";
Link to comment
Share on other sites

  • 0

 

ok i had 5 minutes time to script a little function for you guys, I hope this is what you want:

snip

this will delete all vehicles near stary, bash and klen trade zone within a 100m radius. with delete i mean from the database and the game, so be careful. I've also added a log statement.

the variable _clearAreas defines the center positions of the areas you want to clean. YES, you can use sensor names from the mission.sqm for my script or just your own position in the format [x,y,z] as always (markers or other objects should also work if you want to use that).

 

my advice to call that script would be on the server in the file "dayz_server\system\server_monitor.sqf" after the spawn_vehicles loop (around line 292), if you want to remove all vehicles after each server restart.

you can save the file as clear_area.sqf in the dayz_server.pbo and then call it like this:

execVM "\z\addons\dayz_server\clear_area.sqf";

 

It removed the traders ;)

 

lel

21:38:24 "DELETE: CLEAR_AREA Deleted by ID: 229516"
21:38:24 "CLEAR_AREA: removed vehicle Mi17_DZE (229516) at position [6293.05,7814.94,-0.54895]"
21:38:24 "DELETE: CLEAR_AREA Deleted by UID: 0"
21:38:24 "CLEAR_AREA: removed vehicle GUE_Woodlander2 (0) at position [6321.04,7781.03,0]"
21:38:24 "DELETE: CLEAR_AREA Deleted by UID: 0"
21:38:24 "CLEAR_AREA: removed vehicle Woodlander3 (0) at position [6317.99,7789.33,0]"
21:38:24 "DELETE: CLEAR_AREA Deleted by UID: 0"
21:38:24 "CLEAR_AREA: removed vehicle Dr_Hladik_EP1 (0) at position [6314.1,7791.53,0]"
21:38:24 "DELETE: CLEAR_AREA Deleted by UID: 0"
21:38:24 "CLEAR_AREA: removed vehicle Pilot_EP1 (0) at position [6317.05,7797.92,-0.276825]"
21:38:24 "DELETE: CLEAR_AREA Deleted by UID: 0"
21:38:24 "CLEAR_AREA: removed vehicle TK_CIV_Takistani04_EP1 (0) at position [6321,7794.45,-0.276764]"
21:38:24 "DELETE: CLEAR_AREA Deleted by UID: 0"
21:38:24 "CLEAR_AREA: removed vehicle Rita_Ensler_EP1 (0) at position [6310.78,7794.51,0]"
21:38:24 "DELETE: CLEAR_AREA Deleted by UID: 0"
21:38:24 "CLEAR_AREA: removed vehicle RU_Profiteer4 (0) at position [6300.31,7800.59,0]"
21:38:24 "DELETE: CLEAR_AREA Deleted by UID: 0"
21:38:24 "CLEAR_AREA: removed vehicle Worker3 (0) at position [4041.62,11668.9,0]"
21:38:24 "DELETE: CLEAR_AREA Deleted by ID: 229517"
21:38:24 "CLEAR_AREA: removed vehicle hilux1_civil_3_open_DZE4 (229517) at position [4065.52,11667.7,0.0141907]"
21:38:24 "DELETE: CLEAR_AREA Deleted by UID: 0"
21:38:24 "CLEAR_AREA: removed vehicle Doctor (0) at position [4059.44,11660.4,0]"
21:38:24 "DELETE: CLEAR_AREA Deleted by UID: 0"
21:38:24 "CLEAR_AREA: removed vehicle TK_GUE_Soldier_5_EP1 (0) at position [4054.22,11664.7,0]"
21:38:24 "DELETE: CLEAR_AREA Deleted by UID: 0"
21:38:24 "CLEAR_AREA: removed vehicle CIV_EuroMan02_EP1 (0) at position [4058.05,11678.7,0]"
21:38:24 "DELETE: CLEAR_AREA Deleted by UID: 0"
21:38:24 "CLEAR_AREA: removed vehicle CIV_EuroMan01_EP1 (0) at position [4064.07,11680.1,0]"
21:38:24 "DELETE: CLEAR_AREA Deleted by UID: 0"
21:38:24 "CLEAR_AREA: removed vehicle RU_WorkWoman5 (0) at position [4071.99,11676.7,0]"
21:38:24 "DELETE: CLEAR_AREA Deleted by UID: 0"
21:38:24 "CLEAR_AREA: removed vehicle Profiteer4 (0) at position [11449.5,11341,0]"
21:38:24 "DELETE: CLEAR_AREA Deleted by UID: 0"
21:38:24 "CLEAR_AREA: removed vehicle RU_Citizen3 (0) at position [11462.3,11366,0]"
21:38:24 "DELETE: CLEAR_AREA Deleted by UID: 0"
21:38:24 "CLEAR_AREA: removed vehicle Rocker4 (0) at position [11465.5,11354.5,0]"
21:38:24 "DELETE: CLEAR_AREA Deleted by UID: 0"
21:38:24 "CLEAR_AREA: removed vehicle Woodlander1 (0) at position [11471.2,11361.2,0]"
21:38:24 "DELETE: CLEAR_AREA Deleted by UID: 0"
21:38:24 "CLEAR_AREA: removed vehicle RU_WorkWoman1 (0) at position [11463.9,11351.7,0]"
21:38:24 "DELETE: CLEAR_AREA Deleted by UID: 0"
21:38:24 "CLEAR_AREA: removed vehicle Dr_Annie_Baker_EP1 (0) at position [11472,11370.6,0]"
21:38:24 "DELETE: CLEAR_AREA Deleted by ID: 229515"
21:38:24 "CLEAR_AREA: removed vehicle Mi17_DZE (229515) at position [12917,12763.8,-0.497299]"
21:38:24 "DELETE: CLEAR_AREA Deleted by UID: 0"
21:38:24 "CLEAR_AREA: removed vehicle RU_Functionary1 (0) at position [12946.3,12766.6,0]"
21:38:24 "DELETE: CLEAR_AREA Deleted by UID: 0"
21:38:24 "CLEAR_AREA: removed vehicle GUE_Soldier_MG (0) at position [1623.17,7797.79,0]"
21:38:24 "DELETE: CLEAR_AREA Deleted by UID: 0"
21:38:24 "CLEAR_AREA: removed vehicle Worker2 (0) at position [12061.6,12636.3,0]"
Link to comment
Share on other sites

  • 0

Hey im not trying to steal thunder but a better way to go would be to catch it when vehicles spawn in on server start like this in the server_monitor.sqf ~ line 99

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

6bVoj.png

 

It will unlock vehicles that have no damage and delete anything with 0.1 or more damage. Its abit nicer if someone buys a vehicle just before a restart.

 

Once the vehicle is out of the safezone and the server restarts, it will be lockable again.

 

Technically it removes/unlocks ALL object but you cant build in trader cities so...

Link to comment
Share on other sites

  • 0

Hey im not trying to steal thunder but a better way to go would be to catch it when vehicles spawn in on server start like this in the server_monitor.sqf ~ line 99

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

6bVoj.png

 

It will unlock vehicles that have no damage and delete anything with 0.1 or more damage. Its abit nicer if someone buys a vehicle just before a restart.

 

Once the vehicle is out of the safezone and the server restarts, it will be lockable again.

 

Technically it removes/unlocks ALL object but you cant build in trader cities so...

This works nice Maca

Link to comment
Share on other sites

  • 0

Yeah use macas script, i just wanted to make it easy to use, so my script can be executed whenever you want not just at server restart..

Anyway weird that it is removing traders lol, i have tested it with land vehicles that worked fine and than just replaced that with AllVehicles,seem like traders count as vehicles and not Man ...

Link to comment
Share on other sites

  • 0

Yeah use macas script, i just wanted to make it easy to use, so my script can be executed whenever you want not just at server restart..

Anyway weird that it is removing traders lol, i have tested it with land vehicles that worked fine and than just replaced that with AllVehicles,seem like traders count as vehicles and not Man ...

 

I think the difference is the damage check on Maca's solution.

Link to comment
Share on other sites

  • 0

Hey im not trying to steal thunder but a better way to go would be to catch it when vehicles spawn in on server start like this in the server_monitor.sqf ~ line 99

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

6bVoj.png

 

It will unlock vehicles that have no damage and delete anything with 0.1 or more damage. Its abit nicer if someone buys a vehicle just before a restart.

 

Once the vehicle is out of the safezone and the server restarts, it will be lockable again.

 

Technically it removes/unlocks ALL object but you cant build in trader cities so...

OMG.. simple piece of code, put to great effect. hope i am as good as this someday...

Link to comment
Share on other sites

  • 0

I just get an error using this;

 

Placing the code like this:

	// # NOW SPAWN OBJECTS #
	_totalvehicles = 0;
	{
		_idKey = 		_x select 1;
		_type =			_x select 2;
		_ownerID = 		_x select 3;

		_worldspace = 	_x select 4;
		_intentory =	_x select 5;
		_hitPoints =	_x select 6;
		_fuel =			_x select 7;
		_damage = 		_x select 8;
		
		_dir = 0;
		_pos = [0,0,0];
		{
    if ((_pos distance _x) < 75) then {
        if (_damage > 0.1) then {
            _damage = 1;
            [_idKey,false,"SERVER"] call server_deleteObj;
            diag_log format["DELETING SAFEZONE VEHICLE: %1", [_idKey, _type]];
        };
        _ownerID = "0";
    };
} forEach [zonestary, zonebash, zoneklen];
		_wsDone = false;
		if (count _worldspace >= 2) then
		{
			_dir = _worldspace select 0;
			if (count (_worldspace select 1) == 3) then {
				_pos = _worldspace select 1;
				_wsDone = true;
			}
		};

getting this error:

16:42:01 Error in expression <_worldspace select 1;
_wsDone = true;
}
{
if ((_pos distance _x) < 100) then {
i>
16:42:01   Error position: <{
if ((_pos distance _x) < 100) then {
i>
16:42:01   Error Missing ;
16:42:01 File z\addons\dayz_server\system\server_monitor.sqf, line 109
16:42:01 Error in expression <_worldspace select 1;
_wsDone = true;
}
{
if ((_pos distance _x) < 100) then {
i>
16:42:01   Error position: <{
if ((_pos distance _x) < 100) then {
i>
16:42:01   Error Missing ;
16:42:01 File z\addons\dayz_server\system\server_monitor.sqf, line 109
Link to comment
Share on other sites

  • 0

 

I just get an error using this;

 

Placing the code like this:

	// # NOW SPAWN OBJECTS #
	_totalvehicles = 0;
	{
		_idKey = 		_x select 1;
		_type =			_x select 2;
		_ownerID = 		_x select 3;

		_worldspace = 	_x select 4;
		_intentory =	_x select 5;
		_hitPoints =	_x select 6;
		_fuel =			_x select 7;
		_damage = 		_x select 8;
		
		_dir = 0;
		_pos = [0,0,0];
		{
    if ((_pos distance _x) < 75) then {
        if (_damage > 0.1) then {
            _damage = 1;
            [_idKey,false,"SERVER"] call server_deleteObj;
            diag_log format["DELETING SAFEZONE VEHICLE: %1", [_idKey, _type]];
        };
        _ownerID = "0";
    };
} forEach [zonestary, zonebash, zoneklen];
		_wsDone = false;
		if (count _worldspace >= 2) then
		{
			_dir = _worldspace select 0;
			if (count (_worldspace select 1) == 3) then {
				_pos = _worldspace select 1;
				_wsDone = true;
			}
		};

getting this error:

16:42:01 Error in expression <_worldspace select 1;
_wsDone = true;
}
{
if ((_pos distance _x) < 100) then {
i>
16:42:01   Error position: <{
if ((_pos distance _x) < 100) then {
i>
16:42:01   Error Missing ;
16:42:01 File z\addons\dayz_server\system\server_monitor.sqf, line 109
16:42:01 Error in expression <_worldspace select 1;
_wsDone = true;
}
{
if ((_pos distance _x) < 100) then {
i>
16:42:01   Error position: <{
if ((_pos distance _x) < 100) then {
i>
16:42:01   Error Missing ;
16:42:01 File z\addons\dayz_server\system\server_monitor.sqf, line 109

You are missing '};' at the bottom.

Link to comment
Share on other sites

  • 0

Ok i am still unsuccessful getting this working, the server starts up fine but doesn't delete any vehicles

 

 

// # NOW SPAWN OBJECTS #

_totalvehicles = 0;
{
_idKey = _x select 1;
_type = _x select 2;
_ownerID = _x select 3;
 
_worldspace = _x select 4;
_intentory = _x select 5;
_hitPoints = _x select 6;
_fuel = _x select 7;
_damage = _x select 8;
 
_dir = 0;
_pos = [0,0,0];
{
    if ((_pos distance _x) < 75) then {
        if (_damage > 0.1) then {
            _damage = 1;
            [_idKey,false,"SERVER"] call server_deleteObj;
            diag_log format["DELETING SAFEZONE VEHICLE: %1", [_idKey, _type]];
        };
        _ownerID = "0";
    };
} forEach [zonestary, zonebash, zoneklen];
_wsDone = false;
if (count _worldspace >= 2) then
{
_dir = _worldspace select 0;
if (count (_worldspace select 1) == 3) then {
_pos = _worldspace select 1;
_wsDone = true;
};
};
 
if (!_wsDone) then {
if (count _worldspace >= 1) then { _dir = _worldspace select 0; };
_pos = [getMarkerPos "center",0,4000,10,0,2000,0] call BIS_fnc_findSafePos;
if (count _pos < 3) then { _pos = [_pos select 0,_pos select 1,0]; };
diag_log ("MOVED OBJ: " + str(_idKey) + " of class " + _type + " to pos: " + str(_pos));
};

 

 

Any help is appreciated

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
  • Advertisement
  • Discord

×
×
  • Create New...