ScriptsAboutBlogToolsKnowledge BaseReviewsFAQBasketDocsSupport
QBCoreclient

QBCore.Functions.SpawnVehicle

QBCore client documentation with a FiveM Lua example.

Summary

Spawns a vehicle client-side in QBCore, handling model loading and networking for you, then returns the vehicle via callback. A convenience wrapper around the raw vehicle natives.

Returns

void (vehicle handle via callback).

Parameters

modelstringThe vehicle model name.
cbfunctionCallback receiving the spawned vehicle handle.
coordsvector4Optional spawn coords (defaults to player).
isNetworkedbooleanWhether the vehicle is networked.

Example

QBCore.Functions.SpawnVehicle('adder', function(veh)
  SetVehicleNumberPlateText(veh, 'TEST')
  TaskWarpPedIntoVehicle(PlayerPedId(), veh, -1)
end, coords, true)

Common pitfalls

  • The model must be valid (IsModelInCdimage) or it returns early.
  • It handles RequestModel/HasModelLoaded internally, so you don't have to.
  • For server-authoritative spawning on serious servers, prefer a server-side flow.

Related functions

Related guides

Need protected areas on your map?

Viper Safe-Zone draws polygon safe zones in-game — no hand-edited coordinates — with weapon, combat and vehicle-speed rules per zone.

See Viper Safe-Zone →