mirror of
https://github.com/qbcore-fivem/qb-core.git
synced 2026-08-29 01:08:57 +00:00
Second vehicle spawn callback
This commit is contained in:
@@ -245,6 +245,7 @@ QBCore.Functions.CreateCallback('QBCore:HasItem', function(source, cb, items, am
|
||||
cb(retval)
|
||||
end)
|
||||
|
||||
-- Use this for player vehicle spawning
|
||||
-- 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
|
||||
@@ -256,3 +257,17 @@ QBCore.Functions.CreateCallback('QBCore:Server:SpawnVehicle', function(source, c
|
||||
if warp then TaskWarpPedIntoVehicle(GetPlayerPed(source), veh, -1) end
|
||||
cb(NetworkGetNetworkIdFromEntity(veh))
|
||||
end)
|
||||
|
||||
-- Use this for long distance vehicle spawning
|
||||
-- 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:CreateVehicle', function(source, cb, model, coords, warp)
|
||||
model = type(model) == 'string' and GetHashKey(model) or model
|
||||
if not coords then coords = GetEntityCoords(GetPlayerPed(source)) end
|
||||
local CreateAutomobile = GetHashKey("CREATE_AUTOMOBILE")
|
||||
local veh = Citizen.InvokeNative(CreateAutomobile, model, coords, 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