Talk:deleteVehicle

From Bohemia Interactive Community
Jump to navigation Jump to search

If you deleteVehicle a vehicle that has been tagged as a respawnVehicle, the game will crash when it tries to garbage collect the vehicle it thinks is still there. --Doolittle 01:50, 16 July 2007 (CEST)

I have been able to run the 'deleteVehicle' command on a vehicle marked as 'respawnable' without issue. This command has not caused any CTD's for me when deleting either the 'alive' or 'dead' version of the given vehicle. Please explain your methodology precisely. --Sy 03:38, 16 July 2007 (CEST)

Arma 2: Deleting a unit local to the server (only) on the server seems to cause inconsistencies with clients (testing on a hosted server). Sometimes the units will get deleted properly for everyone and sometimes a "ghost" would remain on the clients but not the server - that is, they will still appear in game and on the map (in "regular" difficulty) but not do anything, and bullets will go through them. Can anyone explain why this is happening and why the inconsistency? This only happened to me with a tank crew that was first spawning a script (via execVM), that deletes them if a certain condition is met, and then was ordered to moveInX and assaingX to the vehicle (where X is commander, gunner and driver for each of the crewmen). Can upload the mission that causes this if needed.

Yes please upload the mission.
--ViperMaul 10:11, 9 August 2009 (CEST)

I found out the cause, by the way, just forgot about this post to update it. This seems to happen when you delete the vehicle without deleting the crew first. Not sure if it's still the case in 1.05, though, as it was a long time ago.

On another note, from the multiplayer side of things, it seems anyone can delete any vehicle regardless of locality. Can anyone confirm?

Deleting Crew

(I have moved the discussion from main page here, so we can figure out what exactly is happening in the different versions, before we post it on the main page.) --Kronzky 15:11, 21 July 2010 (CEST)


If you run deleteVehicle for every playable soldier, the AI units will be removed. deleteVehicle unit1 will result in some very strange, and unwelcome, things happening. A safer way to delete unit1 if it is, or might be, inside a vehicle is:

unassignVehicle unit1 unit1 setPos [0,0,0] deleteVehicle unit1

This is because you cannot call deleteVehicle on a unit (soldier) who's currently inside a Vehicle.

The line below works just fine for units that have been deleted.

if (alive unit1) then {hint"He is alive"} else {hint"Oh no he's not"} August 3, 2006 - 14:30, hardrock


It doesn't matter whether it's the default crew (e.g. {driver car1}), or a unit that has been placed into a vehicle (e.g. {unit1 moveInCargo car1; deleteVehicle unit1}). In either case the unit will stay alive and visible in its position.
To circumvent this limitation, eject the unit first, before deleting it.
January 14, 2009 - 12:35, Kronzky


In Arma 2 deleting units in vehicles work. Trigger with the code below will remove APC, crew and the group that is moveincargo'd. {deletevehicle _x} foreach crew (thislist select 0); deletevehicle (thislist select 0); August 6, 2009 - 11:30, Shuko


Deleting a vehicle that has units in it can (but not always will) cause some weird bugs, for example "locking" the unit in freelook mode making it unable to turn or use the action menu, or leave "ghosts" of vehicle crew members if those were deleted after the vehicle deletion (deleting the crew before the vehicle works, as in the above example).
April 6, 2010, galzohar

deleteVehicle doesn't delete the attached variable

This could be a general consideration about global variables referring to created or added objects. delete... or remove... are making the objects null but the global "empty" variables aren't nil until you decide it. In order to avoid multiple creations while using Event Handlers (sometimes it happens) or loops, you can write: if (isnil "something") then {something = "object" createVehicle....}; then, when needed: deleteVehicle something; something = nil.
April 27, 2016, Pierre MGI

No longer relevant

At some point this was relevant but now the listed objects self clean:

EXAMPLE3: Objects such as

  • test_EmptyObjectForBubbles
  • test_EmptyObjectForFireBig
  • test_EmptyObjectForSmoke

create additional emitters that needs to be deleted first before deleting the object itself: ///--- function to delete test object (MP compatible) fnc_deleteTestObj = { _this addMPEventHandler ["MPKilled", { _this = _this select 0; { deleteVehicle _x; } forEach (_this getVariable ["effects", []]); if (isServer) then { deleteVehicle _this; }; }]; _this setDamage 1; }; ///--- example [] spawn { _fire = "test_EmptyObjectForFireBig" createVehicle position player; sleep 5; _fire call fnc_deleteTestObj; };