- Documentation
- Server functions
- toggleVehicleRespawn
Function
toggleVehicleRespawn
Enables 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 from setVehicleRespawnDelay, and an abandoned vehicle after the time from setVehicleIdleRespawnDelay. Disabling it cancels a wreck respawn already waiting in the queue; a wreck without respawning disappears after the time from setVehicleWreckDelay (20 s by default).
Syntax
bool toggleVehicleRespawn(vehicle vehicle, bool enabled)Arguments
vehiclevehicle- The vehicle.
enabledbooltrue= respawn automatically,false= do not respawn.
Returns
true on success.
Example
local vehicle = createVehicle(560, 2495, -1665, 13.2)
toggleVehicleRespawn(vehicle, true)
setVehicleIdleRespawnDelay(vehicle, 5 * 60000)
See also
isVehicleRespawnableChecks whether a vehicle has automatic respawning enabled (toggleVehicleRespawn).falseby default: the wreck of such a vehicle does not come back but disappears after the time fromsetVehicleWreckDelay.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.setVehicleIdleRespawnDelaySets after how many milliseconds an abandoned vehicle returns to its respawn point by itself. "Abandoned" means nobody is inside and it stands more than 0.5 m from the respawn point. The counter resets when someone gets in. The default is 60000 ms; 0 turns returning of abandoned vehicles off. The countdown runs for vehicles whose respawning was configured with any function from this group (e.g. this one) or which have been a wreck; a freshly created, unconfigured vehicle does not return by itself.