diff --git a/[core]/es_extended/server/main.lua b/[core]/es_extended/server/main.lua index e593608c..d0bbfed5 100644 --- a/[core]/es_extended/server/main.lua +++ b/[core]/es_extended/server/main.lua @@ -119,9 +119,24 @@ 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 - TriggerEvent('esx:playerCrashed', identifier, function() - deferrals.update(("[ESX] Cleaning old Player entry for [%s] (player invalid)"):format(identifier)) - end) + local xPlayer = ESX.GetPlayerFromIdentifier(identifier) + + if xPlayer and ESX.Players[xPlayer.playerId] then + local xPlayerId = xPlayer.playerId + local isExist = DoesPlayerExist(xPlayerId --[[@as string]]) + + if isExist ~= 0 then + deferrals.update(("[ESX] Cleaning old Player entry for [%s] (player invalid)"):format(identifier)) + TriggerEvent('esx:playerDropped', xPlayerId) + ESX.Players[xPlayerId] = nil + Core.playersByIdentifier[identifier] = nil + GlobalState['playerCount'] = GlobalState['playerCount'] - 1 + 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 return deferrals.done() end)