mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-08-29 01:08:54 +00:00
fix: delay ox_inventory load until character registration completes in non-multicharacter
Delay ox_inventory load until character identity is set (non-multicharacter) Inventory was loading before firstName were assigned to new characters when multicharacter was disabled. Fix/Changes: * Check if multicharacter is disabled (Config.Multichar) * Identify new characters (isNew flag) * Wait for firstName to be registered * Implement 2-minute timeout to prevent infinite loops * Log warning if registration fails to complete in time * Continue loading inventory anyway after timeout Ensures identity data loads before inventory initializes
This commit is contained in:
@@ -354,11 +354,22 @@ function loadESXPlayer(identifier, playerId, isNew)
|
||||
if not Config.CustomInventory then
|
||||
xPlayer.triggerEvent("esx:createMissingPickups", Core.Pickups)
|
||||
elseif setPlayerInventory then
|
||||
if not Config.Multichar and isNew and not xPlayer.get("firstName") and not xPlayer.get("lastName") then
|
||||
while not xPlayer.get("firstName") and not xPlayer.get("lastName") do
|
||||
Wait(3000)
|
||||
end
|
||||
end
|
||||
-- Wait for identity to be set before loading inventory (for non-multichar)
|
||||
if not Config.Multichar and isNew and not xPlayer.get("firstName") then
|
||||
local sleep = 5000
|
||||
local registrationTimeout = 120 * 1000 -- 2 minutes
|
||||
|
||||
while not xPlayer.get("firstName") do
|
||||
registrationTimeout = registrationTimeout - sleep
|
||||
|
||||
if registrationTimeout <= 0 then
|
||||
print(('[^3WARNING^7] Player ^5"%s"^7 Registration Timeout Reached (Loading Inventory Anyway).'):format(xPlayer.getName()))
|
||||
break
|
||||
end
|
||||
|
||||
Wait(sleep)
|
||||
end
|
||||
end
|
||||
setPlayerInventory(playerId, xPlayer, userData.inventory, isNew)
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user