Auto Delete Wrecked Vehicles Script (HOW ?)

has anyone else expirenced the helis or cars just dispearing?

I think if its just damaged, it deletes it thinking its wrecked.
 
Be default they would need the damage of 1. You can have a pretty damaged car even on fire sometimes and it not be 1. Unless if you have something like remove parts script and someone removes the engine (most scripts have been fixed for that tho)
 
Ah yeah you have a good point, vehicles will explode is the engine part is at 0.9 or above, so i guess that when the engine explodes the husks damage is still set to what it used to be, or atleast very close to 1.0...

Perhaps adding it so that if ( _dmg >= 0.9 ) instead of > 1.0 would be better.

Hey AlienX, I am using a new method for spawning vehicles in the server which is using the editor and dayz_server.pbo which auto respawns vehicles at every restart on my server (pvp only server so useful) but having a small problem, exploded vehicles don't delete anymore after explosion. Now i'm guessing it's cause it's not HIVE spawned and server side spawn instead. I am pretty sure there is a way to do this but dunno how been trying to figure it out. Your help is more than appreciated brother :)

i'm using this method to spawn cars: HERE
Here is my custom vehicle spawn script found inside dayz_server.pbo

cars.sqf
Code:
if (isServer) then {
 
_vehicle_0 = objNull;
if (true) then
{
  _this = createVehicle ["SUV_TK_CIV_EP1", [8458.8281, 1089.4734, -1.1444092e-005], [], 0, "CAN_COLLIDE"];
  _vehicle_0 = _this;
  _this setDir -9.4094629;
  _this setPos [8458.8281, 1089.4734, -1.1444092e-005];
};
 
_vehicle_2 = objNull;
if (true) then
{
  _this = createVehicle ["SUV_TK_CIV_EP1", [8463.1719, 1090.2358, 4.5776367e-005], [], 0, "CAN_COLLIDE"];
  _vehicle_2 = _this;
  _this setDir -9.4094629;
  _this setPos [8463.1719, 1090.2358, 4.5776367e-005];
};
 
_vehicle_4 = objNull;
if (true) then
{
  _this = createVehicle ["SUV_TK_CIV_EP1", [8467.2373, 1090.8937, 3.0517578e-005], [], 0, "CAN_COLLIDE"];
  _vehicle_4 = _this;
  _this setDir -9.4094629;
  _this setPos [8467.2373, 1090.8937, 3.0517578e-005];
};
 
_vehicle_6 = objNull;
if (true) then
{
  _this = createVehicle ["SUV_TK_CIV_EP1", [8471.4307, 1091.6425, 1.1444092e-005], [], 0, "CAN_COLLIDE"];
  _vehicle_6 = _this;
  _this setDir -9.4094629;
  _this setPos [8471.4307, 1091.6425, 1.1444092e-005];
};
 
_vehicle_8 = objNull;
if (true) then
{
  _this = createVehicle ["SUV_TK_CIV_EP1", [8475.6064, 1092.3893, 7.6293945e-006], [], 0, "CAN_COLLIDE"];
  _vehicle_8 = _this;
  _this setDir -9.4094629;
  _this setPos [8475.6064, 1092.3893, 7.6293945e-006];
};
 
_vehicle_10 = objNull;
if (true) then
{
  _this = createVehicle ["SUV_TK_CIV_EP1", [8479.5146, 1092.7472], [], 0, "CAN_COLLIDE"];
  _vehicle_10 = _this;
  _this setDir -9.4094629;
  _this setPos [8479.5146, 1092.7472];
};
 
_vehicle_12 = objNull;
if (true) then
{
  _this = createVehicle ["SUV_TK_CIV_EP1", [8483.4336, 1092.9009, 7.6293945e-006], [], 0, "CAN_COLLIDE"];
  _vehicle_12 = _this;
  _this setDir -9.4094629;
  _this setPos [8483.4336, 1092.9009, 7.6293945e-006];
};
 
_vehicle_14 = objNull;
if (true) then
{
  _this = createVehicle ["SUV_TK_CIV_EP1", [8487.1934, 1093.0371, -7.6293945e-006], [], 0, "CAN_COLLIDE"];
  _vehicle_14 = _this;
  _this setDir -9.4094629;
  _this setPos [8487.1934, 1093.0371, -7.6293945e-006];
};
 
_vehicle_16 = objNull;
if (true) then
{
  _this = createVehicle ["SUV_TK_CIV_EP1", [8491.2969, 1092.98, -2.6702881e-005], [], 0, "CAN_COLLIDE"];
  _vehicle_16 = _this;
  _this setDir -9.4094629;
  _this setPos [8491.2969, 1092.98, -2.6702881e-005];
};
 
_vehicle_18 = objNull;
if (true) then
{
  _this = createVehicle ["SUV_TK_CIV_EP1", [8495.6953, 1093.3019, -2.2888184e-005], [], 0, "CAN_COLLIDE"];
  _vehicle_18 = _this;
  _this setDir -9.4094629;
  _this setPos [8495.6953, 1093.3019, -2.2888184e-005];
};
 
_vehicle_20 = objNull;
if (true) then
{
  _this = createVehicle ["SUV_TK_CIV_EP1", [8499.9365, 1093.6034, 1.5258789e-005], [], 0, "CAN_COLLIDE"];
  _vehicle_20 = _this;
  _this setDir -9.4094629;
  _this setPos [8499.9365, 1093.6034, 1.5258789e-005];
};
 
_vehicle_22 = objNull;
if (true) then
{
  _this = createVehicle ["SUV_TK_CIV_EP1", [8504.0117, 1094.0244, -5.7220459e-005], [], 0, "CAN_COLLIDE"];
  _vehicle_22 = _this;
  _this setDir -9.4094629;
  _this setPos [8504.0117, 1094.0244, -5.7220459e-005];
};
 
_vehicle_24 = objNull;
if (true) then
{
  _this = createVehicle ["SUV_TK_CIV_EP1", [8508.0518, 1094.7218, 1.5258789e-005], [], 0, "CAN_COLLIDE"];
  _vehicle_24 = _this;
  _this setDir -9.4094629;
  _this setPos [8508.0518, 1094.7218, 1.5258789e-005];
};
 
_vehicle_26 = objNull;
if (true) then
{
  _this = createVehicle ["SUV_TK_CIV_EP1", [8512.2412, 1095.2993, -3.8146973e-006], [], 0, "CAN_COLLIDE"];
  _vehicle_26 = _this;
  _this setDir -9.4094629;
  _this setPos [8512.2412, 1095.2993, -3.8146973e-006];
};
 
_vehicle_28 = objNull;
if (true) then
{
  _this = createVehicle ["SUV_TK_CIV_EP1", [8516.4258, 1096.0171, 1.5258789e-005], [], 0, "CAN_COLLIDE"];
  _vehicle_28 = _this;
  _this setDir -9.4094629;
  _this setPos [8516.4258, 1096.0171, 1.5258789e-005];
};
 
_vehicle_30 = objNull;
if (true) then
{
  _this = createVehicle ["SUV_TK_CIV_EP1", [8520.5596, 1096.7286, -3.8146973e-006], [], 0, "CAN_COLLIDE"];
  _vehicle_30 = _this;
  _this setDir -9.4094629;
  _this setPos [8520.5596, 1096.7286, -3.8146973e-006];
};
 
_vehicle_32 = objNull;
if (true) then
{
  _this = createVehicle ["SUV_TK_CIV_EP1", [8524.7061, 1097.5837, -2.2888184e-005], [], 0, "CAN_COLLIDE"];
  _vehicle_32 = _this;
  _this setDir -9.4094629;
  _this setPos [8524.7061, 1097.5837, -2.2888184e-005];
};
 
_vehicle_34 = objNull;
if (true) then
{
  _this = createVehicle ["SUV_TK_CIV_EP1", [8528.7813, 1098.2867, 1.1444092e-005], [], 0, "CAN_COLLIDE"];
  _vehicle_34 = _this;
  _this setDir -9.4094629;
  _this setPos [8528.7813, 1098.2867, 1.1444092e-005];
};
 
_vehicle_36 = objNull;
if (true) then
{
  _this = createVehicle ["SUV_TK_CIV_EP1", [8532.6719, 1098.9656, -1.9073486e-005], [], 0, "CAN_COLLIDE"];
  _vehicle_36 = _this;
  _this setDir -9.4094629;
  _this setPos [8532.6719, 1098.9656, -1.9073486e-005];
};
 
_vehicle_38 = objNull;
if (true) then
{
  _this = createVehicle ["SUV_TK_CIV_EP1", [8536.3027, 1099.897, -3.8146973e-006], [], 0, "CAN_COLLIDE"];
  _vehicle_38 = _this;
  _this setDir -14.391428;
  _this setPos [8536.3027, 1099.897, -3.8146973e-006];
};
};
 
You might be able to put a setVehicleInit with something like this:
Code:
[] spawn { waitUntil { !(alive _this) }; sleep 5; deleteVehicle _this; };

This would go inside of your vehicles that you spawn, like:
Code:
_vehicle_4 = objNull;
if (true) then
{
  _this = createVehicle ["SUV_TK_CIV_EP1", [8467.2373, 1090.8937, 3.0517578e-005], [], 0, "CAN_COLLIDE"];
  _vehicle_4 = _this;
  _this setDir -9.4094629;
  _this setPos [8467.2373, 1090.8937, 3.0517578e-005];
  _this setVehicleInit "[] spawn { waitUntil { !(alive _this) }; sleep 5; deleteVehicle _this; };";
};
 
processInitCommands;

The above is totally untested, just fyi :)
 
You might be able to put a setVehicleInit with something like this:
Code:
[] spawn { waitUntil { !(alive _this) }; sleep 5; deleteVehicle _this; };

This would go inside of your vehicles that you spawn, like:
Code:
_vehicle_4 = objNull;
if (true) then
{
  _this = createVehicle ["SUV_TK_CIV_EP1", [8467.2373, 1090.8937, 3.0517578e-005], [], 0, "CAN_COLLIDE"];
  _vehicle_4 = _this;
  _this setDir -9.4094629;
  _this setPos [8467.2373, 1090.8937, 3.0517578e-005];
  _this setVehicleInit "[] spawn { waitUntil { !(alive _this) }; sleep 5; deleteVehicle _this; };";
};
 
processInitCommands;

The above is totally untested, just fyi :)


You're the best man, gonna test now and get back to you ;)
 
great thanks now how do you do corpses with a delay :p
Doing corpses is not as simple as doing the vehicles, as the corpses are cleaned up anyways with the server fsm file.

While i did (in the past) make a better corpse cleanup system (it deletes a corpse after 20 minutes of them being killed), i no longer have this code :(


also people, this might be better code for your server_updateObject.sqf file:
Code:
_object_damage = {
    private["_hitpoints","_array","_hit","_selection","_key","_damage"];
    _hitpoints = _object call vehicle_getHitpoints;
    _damage = damage _object;
    _array = [];
    {
        _hit = [_object,_x] call object_getHit;
        _selection = getText (configFile >> "CfgVehicles" >> (typeOf _object) >> "HitPoints" >> _x >> "name");
        if (_hit > 0) then {_array set [count _array,[_selection,_hit]]};
        _object setHit ["_selection", _hit]
    } forEach _hitpoints;
    _key = format["CHILD:306:%1:%2:%3:",_objectID,_array,_damage];
    diag_log ("HIVE: WRITE: "+ str(_key));
    _key call server_hiveWrite;
    _object setVariable ["needUpdate",false,true];
    if ( !(alive _object) ) then { _object spawn { sleep 5; deleteVehicle _this; }; };
 };

Untested this way, but it might be better at ensuring vehicles always delete ONLY when they die.
 
You might be able to put a setVehicleInit with something like this:
Code:
[] spawn { waitUntil { !(alive _this) }; sleep 5; deleteVehicle _this; };

This would go inside of your vehicles that you spawn, like:
Code:
_vehicle_4 = objNull;
if (true) then
{
  _this = createVehicle ["SUV_TK_CIV_EP1", [8467.2373, 1090.8937, 3.0517578e-005], [], 0, "CAN_COLLIDE"];
  _vehicle_4 = _this;
  _this setDir -9.4094629;
  _this setPos [8467.2373, 1090.8937, 3.0517578e-005];
  _this setVehicleInit "[] spawn { waitUntil { !(alive _this) }; sleep 5; deleteVehicle _this; };";
};
 
processInitCommands;

The above is totally untested, just fyi :)

Tested and does not seem to work. It doesnt do anything wrong to the vehicle but yeah it's a no go :p any other ideas... I think this may be also testable in the editor
 
Any script errors in the client's RPT?

And yeah, this would be testable in the editor.

No errors in RPT... I then tried in the Editor and same thing... I am trying different variations of your code (tweeking it), but non seems to work. I am pretty sure it's possible, but now only to find it haha. Hey thanks again for all your help AlienX, you're a really awesome guy for helping so much man. If you test or find another way please let me know, i'll do my best on my end as well
 
Humm, it's odd dude - it should work.

What about spawning in one single vehicle in ur editor, and adding this to init:
Code:
[] spawn { while {true} do { hintSilent ( format [ 'Vehicle\n%1\n\nAlive\n%2', _this, alive _this ] ); sleep 1; }; };

This should *in theory* create a hint box when the vehicle spawns, giving its current alive status - shoot the car until it blows up to see if the engine still thinks it's alive or not.
 
I don't believe that vehicles have an alive table, so !(alive _this) I don't believe will work. You need to use something like this instead.
Code:
_this setVehicleInit "[] spawn { waitUntil { ((getDamage _this) == 1)  }; sleep 5; deleteVehicle _this; };";

I think I may have the syntax wrong though. getDammage returns the vehicle damage from 0-1. 1 would be destroyed.
 
I don't believe that vehicles have an alive table, so !(alive _this) I don't believe will work. You need to use something like this instead.
Code:
_this setVehicleInit "[] spawn { waitUntil { ((getDamage _this) == 1)  }; sleep 5; deleteVehicle _this; };";

I think I may have the syntax wrong though. getDammage returns the vehicle damage from 0-1. 1 would be destroyed.

Still does not seem to work :/ vehicle just stays there exploded. Hmmm.
 
Arma be stupid lol.

Thanks for clearing that up Vampire.

Hehe happens, however the code still does nothing

Code:
_this setVehicleInit "[] spawn { waitUntil { ((getDamage _this) == 1) }; sleep 5; deleteVehicle _this; };";[/FONT]

Reading it seems more proper and should work, can any of you get this to work while in editor? very odd indeed
 
I made a typo. It's getDammage with two mms. If that doesn't work it's how its being used.

If you want the wrecks to be deleted after they catch fire and burn, try this instead.
No reason to add extra code when there is already a server file that does this stuff for you.

Open
server.pbo > compile > server_updateObject.sqf

Add this to your private variables at the top:
Code:
_isBuilding

Then under this code block:
Code:
if (!_parachuteWest and !(locked _object)) then {
    if (_objectID == "0" && _uid == "0") then
    {
        _object_position = getPosATL _object;
        _isNotOk = true;
    };
};

Add this code if you use Epoch:
Code:
_isBuilding = (typeOf _object == "Building")
if (((getDammage _object) == 1) && !_isbuildable && !_isBuilding) then {
    deleteVehicle _object;
};

or this code if you use normal dayz:
Code:
_isBuilding = (typeOf _object == "Building")
if (((getDammage _object) == 1) && !_isBuilding) then {
    deleteVehicle _object;
};

When a player gets within a certain distance of an object this script runs making a check to see how the object needs to behave, and if it's a valid object. If it is invalid it deletes the object. To prevent it possible deleting custom buildings entered in from the database I added an _isBuilding check. Epoch also has to check if it's a player built object or else shot down walls would drop no rubble.

The code isn't tested but it should work fine. Burning vehicles should get updated fast enough. May need a person leaving and returning within a certain distance, or maybe just looking at it. Not sure exactly how often it updates, but I believe it is everytime the player is within a certain distance and looks at it.
 
Re-reading it I see you are trying to delete specifically damaged spawned vehicles.

In that case my last post modified after you add this to your vehicles:
Code:
_this setVariable ["myCars",1,true];
for example, and then
Code:
if (((getDammage _object) == 1) && (_object getVariable [""myCars"",0] == 1)) then {
    deleteVehicle _object;
};
 
Re-reading it I see you are trying to delete specifically damaged spawned vehicles.

In that case my last post modified after you add this to your vehicles:
Code:
_this setVariable ["myCars",1,true];

so if my sqf file is called "cars.sqf" do I change myCars to just cars?
 
No you have to add it to these as an example:
Code:
_vehicle_4 = objNull;
if (true) then
{
  _this = createVehicle ["SUV_TK_CIV_EP1", [8467.2373, 1090.8937, 3.0517578e-005], [], 0, "CAN_COLLIDE"];
  _vehicle_4 = _this;
  _this setDir -9.4094629;
  _this setPos [8467.2373, 1090.8937, 3.0517578e-005];
  _this setVariable ["myCars",1,true];
};
 
No you have to add it to these as an example:
Code:
_vehicle_4 = objNull;
if (true) then
{
  _this = createVehicle ["SUV_TK_CIV_EP1", [8467.2373, 1090.8937, 3.0517578e-005], [], 0, "CAN_COLLIDE"];
  _vehicle_4 = _this;
  _this setDir -9.4094629;
  _this setPos [8467.2373, 1090.8937, 3.0517578e-005];
  _this setVariable ["myCars",1,true];
};

Ah I see and got that right, but where exactly do I put this?
Code:
if (((getDammage _object) == 1) && (_object getVariable [""myCars"",0] == 1)) then {
    deleteVehicle _object;
};

Also I cannot find this block of code at all in my server_updateObject.sqf

Code:
if (!_parachuteWest and !(locked _object)) then {
    if (_objectID == "0" && _uid == "0") then
    {
        _object_position = getPosATL _object;
        _isNotOk = true;
    };
};

I am sorry man but now I am getting confused here haha.

Here is my server_updateObject.sqf (HERE)

Maybe you can look at it since it's not an epoch file. Thanks a bunch man for the help :)
 
Back
Top