Server Lib
spawnVehicle
Creates a vehicle on the server-side and returns its net ID. If this is a player owned vehicle, and the persistence convar is enabled, the spawned vehicle will be persisted.
qbx.spawnVehicle(params)
- params:
table
- model:
integer
- A vehicle modle hash.
- spawnSource:
integer | vector3 | vector4
- The handle of an entity or coords to spawn the vehicle at.
- warp?:
boolean | integer
- An optional ped ID to warp into the vehicle after it spawns.
- If
spawnSource
is a ped ID, you can passtrue
to warp the ped specified there instead.
- props?:
table
- Refer to ox_lib's Vehicle Properties (opens in a new tab).
- bucket?
integer
- An optional routing bucket to move the spawned entity to.
- model:
Returns:
- netId:
integer
- entity:
integer
-- spawns the vehicle at `myVectorCoords` and warps `myPed` inside
qbx.spawnVehicle({
model = `asbo`,
spawnSource = myVectorCoords,
warp = myPed,
})
-- spawns the vehicle at `myPed` and warps the same ped inside
qbx.spawnVehicle({
model = `asbo`,
spawnSource = myPed,
warp = true, -- causes `myPed` to be warped into the vehicle
})