Vehicle server-spawning functions/callback

This commit is contained in:
Kakarot
2022-07-22 22:59:01 -05:00
parent 8b5f5b2b37
commit 1b2915a75f
2 changed files with 35 additions and 0 deletions
+11
View File
@@ -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)