Skip to content

Commit

Permalink
Merge branch 'main' into FjamZoo-patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
Manason committed Nov 16, 2023
2 parents be51418 + 3b6b8b2 commit 6c92692
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions modules/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -369,11 +369,13 @@ else
function GetEntityAndNetIdFromBagName(bagName) -- luacheck: ignore
local netId = tonumber(bagName:gsub('entity:', ''), 10)

lib.waitFor(function()
return NetworkDoesEntityExistWithNetworkId(netId)
local idExist = lib.waitFor(function()
local netIdExist = NetworkDoesEntityExistWithNetworkId(netId)

if netIdExist then return netIdExist end
end, ('statebag timed out while awaiting entity creation! (%s)'):format(bagName), 10000)

local entity = NetworkDoesEntityExistWithNetworkId(netId) and NetworkGetEntityFromNetworkId(netId) or 0
local entity = idExist and NetworkGetEntityFromNetworkId(netId) or 0

if entity == 0 then
lib.print.error(('statebag received invalid entity! (%s)'):format(bagName))
Expand Down

0 comments on commit 6c92692

Please sign in to comment.