- Documentation
- Server functions
- respawnVehicle
Function
respawnVehicle
Immediately respawns a vehicle at its respawn point (where it was created, or the point from setVehicleRespawnPosition). All occupants are removed from the vehicle, its speed is zeroed, health goes back to 1000 and door, panel, lamp and wheel damage disappears. Fires the onVehicleRespawn event. Also works for a vehicle that is not a wreck.
Syntax
bool respawnVehicle(vehicle vehicle)Arguments
vehiclevehicle- The vehicle to respawn.
Returns
true on success.
Example
addCommandHandler("odrodzwszystkie", function()
for _, vehicle in ipairs(getElementsByType("vehicle")) do
if not getVehicleController(vehicle) then respawnVehicle(vehicle) end
end
end)
See also
spawnVehicleRespawns a vehicle once at the given spot, likerespawnVehicle: removes occupants, repairs the vehicle and zeroes its speed. The stored respawn point does not change, so later automatic respawns still go back to the old place.setVehicleRespawnPositionSets the place (and optionally the rotation) where the vehicle appears when it respawns: after destruction, after being abandoned and onrespawnVehicle. By default it is where the vehicle was created. The vehicle is not moved right away.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).