- Documentation
- Server functions
- spawnVehicle
Function
spawnVehicle
Respawns a vehicle once at the given spot, like respawnVehicle: 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.
Syntax
bool spawnVehicle(vehicle vehicle, float x, float y, float z [, float rx = 0, float ry = 0, float rz = 0])Arguments
vehiclevehicle- The vehicle to respawn.
xfloat- X coordinate of the new spot.
yfloat- Y coordinate.
zfloat- Z height.
rxfloat, optional = 0- Rotation around the X axis in degrees.
ryfloat, optional = 0- Rotation around the Y axis in degrees.
rzfloat, optional = 0- Heading in degrees.
Returns
true on success.
Example
addCommandHandler("przywolaj", function(player, _, id)
local vehicle = getElementByID(id or "")
if not vehicle or getElementType(vehicle) ~= "vehicle" then return end
local x, y, z = getElementPosition(player)
spawnVehicle(vehicle, x + 4, y, z + 0.5, 0, 0, 0)
end)
See also
respawnVehicleImmediately respawns a vehicle at its respawn point (where it was created, or the point fromsetVehicleRespawnPosition). 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 theonVehicleRespawnevent. Also works for a vehicle that is not a wreck.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.