mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-08-29 01:08:54 +00:00
feat(es_extended/client/functions): add promise support for ESX.Game.SpawnVehicle
This commit is contained in:
@@ -549,6 +549,7 @@ function ESX.Game.SpawnVehicle(vehicleModel, coords, heading, cb, networked)
|
||||
return error(("Resource ^5%s^1 Tried to spawn vehicle on the client but the position is too far away (Out of onesync range)."):format(executingResource))
|
||||
end
|
||||
|
||||
local promise = not cb and promise.new()
|
||||
CreateThread(function()
|
||||
ESX.Streaming.RequestModel(model)
|
||||
|
||||
@@ -569,10 +570,16 @@ function ESX.Game.SpawnVehicle(vehicleModel, coords, heading, cb, networked)
|
||||
Wait(0)
|
||||
end
|
||||
|
||||
if cb then
|
||||
if promise then
|
||||
promise:resolve(vehicle)
|
||||
elseif cb then
|
||||
cb(vehicle)
|
||||
end
|
||||
end)
|
||||
|
||||
if promise then
|
||||
return Citizen.Await(promise)
|
||||
end
|
||||
end
|
||||
|
||||
---@param vehicle integer The vehicle to spawn
|
||||
|
||||
Reference in New Issue
Block a user