mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-08-29 01:08:54 +00:00
refactor(es_extended/client/functions): validate cb fun
This commit is contained in:
@@ -530,10 +530,14 @@ end
|
||||
---@param vehicleModel integer | string The vehicle to spawn
|
||||
---@param coords table | vector3 The coords to spawn the vehicle at
|
||||
---@param heading number The heading of the vehicle
|
||||
---@param cb? function The callback function
|
||||
---@param cb? fun(vehicle: number) The callback function
|
||||
---@param networked? boolean Whether the vehicle should be networked
|
||||
---@return number? vehicle
|
||||
function ESX.Game.SpawnVehicle(vehicleModel, coords, heading, cb, networked)
|
||||
if cb and not ESX.IsFunctionReference(cb) then
|
||||
error("Invalid callback function")
|
||||
end
|
||||
|
||||
local model = type(vehicleModel) == "number" and vehicleModel or joaat(vehicleModel)
|
||||
local vector = type(coords) == "vector3" and coords or vec(coords.x, coords.y, coords.z)
|
||||
local isNetworked = networked == nil or networked
|
||||
|
||||
@@ -123,9 +123,9 @@ function ESX.OneSync.SpawnVehicle(model, coords, heading, properties, cb)
|
||||
local networkId = NetworkGetNetworkIdFromEntity(createdVehicle)
|
||||
Entity(createdVehicle).state:set("VehicleProperties", vehicleProperties, true)
|
||||
if promise then
|
||||
return promise:resolve(networkId)
|
||||
promise:resolve(networkId)
|
||||
elseif cb then
|
||||
return cb(networkId)
|
||||
cb(networkId)
|
||||
end
|
||||
end)
|
||||
end)
|
||||
|
||||
Reference in New Issue
Block a user