fix(es_extended/server/main): add fallback check if player is exist

This commit is contained in:
Tabby Dev
2025-05-21 13:48:26 +08:00
parent 86e9735b81
commit 0ece059c19
+15 -11
View File
@@ -119,19 +119,23 @@ if not Config.Multichar then
return deferrals.done("[ESX] There was an error loading your character!\nError code: identifier-missing\n\nThe cause of this error is not known, your identifier could not be found. Please come back later or report this problem to the server administration team.")
end
local xIdentifier = ESX.GetPlayerFromIdentifier(identifier)
local xPlayer = ESX.GetPlayerFromIdentifier(identifier)
if not playerId and xIdentifier then
local xId = xIdentifier.playerId
if xPlayer then
local xPlayerId = xPlayer.playerId
if ESX.Players[xId] then
ESX.Players[xId] = nil
Core.playersByIdentifier[identifier] = nil
print(("[ESX] Cleaning old ESX.Players entry for %s (ped invalid)"):format(identifier))
else
return deferrals.done(
("[ESX] There was an error loading your character!\nError code: identifier-active\n\nThis error is caused by a player on this server who has the same identifier as you have. Make sure you are not playing on the same account.\n\nYour identifier: %s"):format(identifier)
)
if ESX.Players[xPlayerId] then
local xPlayerExist = DoesPlayerExist(xPlayerId --[[@as string]])
if xPlayerExist ~= 0 then
ESX.Players[xPlayerId] = nil
Core.playersByIdentifier[identifier] = nil
deferrals.update(("[ESX] Cleaning old Player entry for [%s] (player invalid)"):format(identifier))
else
return deferrals.done(
("[ESX] There was an error loading your character!\nError code: identifier-active\n\nThis error is caused by a player on this server who has the same identifier as you have. Make sure you are not playing on the same account.\n\nYour identifier: %s"):format(identifier)
)
end
end
end