Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove callback #1229

Merged
merged 2 commits into from
Sep 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 11 additions & 28 deletions [core]/es_extended/client/functions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -336,34 +336,17 @@ end

function ESX.Game.SpawnObject(object, coords, cb, networked)
networked = networked == nil and true or networked
if networked then
ESX.TriggerServerCallback('esx:Onesync:SpawnObject', function(NetworkID)
if cb then
local obj = NetworkGetEntityFromNetworkId(NetworkID)
local Tries = 0
while not DoesEntityExist(obj) do
obj = NetworkGetEntityFromNetworkId(NetworkID)
Wait(0)
Tries = Tries + 1
if Tries > 250 then
break
end
end
cb(obj)
end
end, object, coords, 0.0)
else
local model = type(object) == 'number' and object or joaat(object)
local vector = type(coords) == "vector3" and coords or vec(coords.x, coords.y, coords.z)
CreateThread(function()
ESX.Streaming.RequestModel(model)

local obj = CreateObject(model, vector.xyz, networked, false, true)
if cb then
cb(obj)
end
end)
end

local model = type(object) == 'number' and object or joaat(object)
local vector = type(coords) == "vector3" and coords or vec(coords.x, coords.y, coords.z)
CreateThread(function()
ESX.Streaming.RequestModel(model)

local obj = CreateObject(model, vector.xyz, networked, false, true)
if cb then
cb(obj)
end
end)
end

function ESX.Game.SpawnLocalObject(object, coords, cb)
Expand Down
6 changes: 1 addition & 5 deletions [core]/es_extended/server/onesync.lua
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,4 @@ end
---@return number entityId, number distance, vector3 coords
function ESX.OneSync.GetClosestVehicle(coords, modelFilter)
return getClosestEntity(GetAllVehicles(), coords, modelFilter)
end

ESX.RegisterServerCallback("esx:Onesync:SpawnObject", function(_, cb, model, coords, heading)
ESX.OneSync.SpawnObject(model, coords, heading, cb)
end)
end