ServersYour serverFor creatorsForumFAQDocumentationSecurity
Download the launcher
  1. Documentation
  2. Server functions
  3. spawnVehicle

Function

spawnVehicle

ServerVehiclesIdentical to MTA:SA

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