- Documentation
- Server functions
- blowVehicle
Function
blowVehicle
Destroys a vehicle: health drops to 0, the engine stops, the vehicle becomes a wreck (isVehicleBlown = true) and the onVehicleExplode event fires. By default every player also sees an explosion. If respawning is enabled for the vehicle (toggleVehicleRespawn, off by default), the wreck returns to its spawn point after the time set with setVehicleRespawnDelay (10 s by default); without respawning the wreck disappears after the time from setVehicleWreckDelay (20 s by default). Blowing up an already destroyed vehicle does nothing.
Syntax
bool blowVehicle(vehicle vehicle [, bool explode = true])Arguments
vehiclevehicle- The vehicle to destroy.
explodebool, optional = truetrue= with a visible explosion;false= the vehicle quietly becomes a wreck with no explosion.
Returns
true on success, false when the vehicle is already a wreck.
Example
addCommandHandler("wysadz", function(player)
local vehicle = getPedOccupiedVehicle(player)
if vehicle then blowVehicle(vehicle) end
end)
See also
isVehicleBlownChecks whether a vehicle is a wreck, i.e. it was destroyed (blowVehicleor an explosion in the game) and has not been repaired or respawned yet. A wreck cannot be driven.fixVehicleRepairs a vehicle to factory condition: 1000 health, and every door, body panel, lamp and wheel returns to undamaged; a wreck stops being a wreck. It also cancels a scheduled wreck respawn. For one second after the repair the server ignores damage reports from the game so the old damage does not come back. Colour, tuning and plate stay as they were.setVehicleRespawnDelaySets how many milliseconds after destruction a vehicle's wreck respawns at its respawn point. The default is 10000 ms (10 s). Only works with respawning enabled (toggleVehicleRespawn). The new time applies to later explosions; for a wreck already waiting useresetVehicleExplosionTime.toggleVehicleRespawnEnables or disables automatic respawning of a vehicle. Off by default: a scripted vehicle does not come back by itself. When enabled, a wreck returns repaired to the respawn point after the time fromsetVehicleRespawnDelay, and an abandoned vehicle after the time fromsetVehicleIdleRespawnDelay. Disabling it cancels a wreck respawn already waiting in the queue; a wreck without respawning disappears after the time fromsetVehicleWreckDelay(20 s by default).setVehicleWreckDelaySets how many milliseconds after the explosion a vehicle wreck disappears from the map (the element is destroyed, withonElementDestroycalled; players inside fall out). The default is 20000 ms (20 s); 0 = the wreck stays forever. Passingrootchanges the default for all vehicles without their own setting. Does not apply to vehicles with respawning enabled (toggleVehicleRespawn) — those come back repaired at their respawn point.fixVehiclebefore the time runs out stops the removal. A change for a wreck already waiting restarts the countdown.