mirror of
https://github.com/qbcore-fivem/qb-core.git
synced 2026-09-04 17:23:31 +00:00
Vehicle server-spawning functions/callback
This commit is contained in:
@@ -244,3 +244,14 @@ QBCore.Functions.CreateCallback('QBCore:HasItem', function(source, cb, items, am
|
||||
end
|
||||
cb(retval)
|
||||
end)
|
||||
|
||||
-- Vehicle server-side spawning callback (netId)
|
||||
-- use the netid on the client with the NetworkGetEntityFromNetworkId native
|
||||
-- convert it to a vehicle via the NetToVeh native
|
||||
QBCore.Functions.CreateCallback('QBCore:Server:SpawnVehicle', function(source, cb, model, coords, warp)
|
||||
if not coords then coords = GetEntityCoords(GetPlayerPed(source)) end
|
||||
local veh = CreateVehicle(model, coords.x, coords.y, coords.z, coords.w, true, true)
|
||||
while not DoesEntityExist(veh) do Wait(0) end
|
||||
if warp then TaskWarpPedIntoVehicle(GetPlayerPed(source), veh, -1) end
|
||||
cb(NetworkGetNetworkIdFromEntity(veh))
|
||||
end)
|
||||
Reference in New Issue
Block a user