spawnVehicle | Multi Theft Auto: Wiki Skip to content

spawnVehicle

Client-side
Server-side
Shared

Manual Review Required

Please finish this page using the corresponding Old Wiki article. Go to Contribution guidelines for more information.


Spawns a vehicle at any given position and rotation

OOP Syntax Help! I don't understand this!

Syntax

bool spawnVehicle ( vehicle theVehicle, float x, float y, float z, float rx, float ry, float rz )
Required Arguments
  • theVehicle: The vehicle you wish to spawn
  • x: The x position you wish to spawn the vehicle at
  • y: The x position you wish to spawn the vehicle at
  • z: The x position you wish to spawn the vehicle at
  • rx: The x rotation you wish to spawn the vehicle at
  • ry: The y rotation you wish to spawn the vehicle at
  • rz: The z rotation you wish to spawn the vehicle at

Returns

  • bool: value

Returns true if the vehicle spawned successfully, false if the passed argument does not exist or is not a vehicle.

Code Examples

shared

With this feature, we spawn vehicle

function myCommandHandler(thePlayer, command)
local x, y, z = getElementPosition(thePlayer)
local RaceVehicle = createVehicle ( 411, 0, 0, 0 )
local spawnVeh = spawnVehicle ( RaceVehicle, x+3, y+3, z )
if spawnVeh then outputChatBox("Vehicle was spawned", thePlayer) else outputChatBox("Error",thePlayer) end
end
addCommandHandler("spawnvehicle", myCommandHandler)

See Also

Vehicle Functions