mirror of
https://github.com/qbcore-fivem/qb-core.git
synced 2026-08-29 04:01:24 +00:00
cb to return, pass source for coords fallback
This commit is contained in:
@@ -169,26 +169,26 @@ end
|
||||
|
||||
-- Server side vehicle creation with optional callback
|
||||
-- the CreateVehicle RPC still uses the client for creation so players must be near
|
||||
function QBCore.Functions.SpawnVehicle(model, cb, coords, warp)
|
||||
function QBCore.Functions.SpawnVehicle(source, model, coords, warp)
|
||||
model = type(model) == 'string' and GetHashKey(model) or model
|
||||
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
|
||||
if cb then cb(veh) end
|
||||
return veh
|
||||
end
|
||||
|
||||
-- Server side vehicle creation with optional callback
|
||||
-- the CreateAutomobile native is still experimental but doesn't use client for creation
|
||||
-- doesn't work for all vehicles!
|
||||
function QBCore.Functions.CreateVehicle(model, cb, coords, warp)
|
||||
function QBCore.Functions.CreateVehicle(source, 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
|
||||
if cb then cb(veh) end
|
||||
return veh
|
||||
end
|
||||
|
||||
-- Paychecks (standalone - don't touch)
|
||||
|
||||
Reference in New Issue
Block a user