Skip to content

Commit

Permalink
Merge pull request #1229 from Arctos2win/dev
Browse files Browse the repository at this point in the history
remove callback
  • Loading branch information
Arctos2win authored Sep 27, 2023
2 parents f904136 + 00c0e84 commit 4dac6a0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 33 deletions.
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

0 comments on commit 4dac6a0

Please sign in to comment.