From 3603962413ad75eafaf1ac44cac6d92811fc2f53 Mon Sep 17 00:00:00 2001 From: Tabby Dev <88893827+Tabby-Labs@users.noreply.github.com> Date: Tue, 20 May 2025 14:13:13 +0800 Subject: [PATCH 1/3] fix(es_extended/server/main): remove old player from memory (non multichar) --- [core]/es_extended/server/main.lua | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/[core]/es_extended/server/main.lua b/[core]/es_extended/server/main.lua index 993e99ec..b54450bb 100644 --- a/[core]/es_extended/server/main.lua +++ b/[core]/es_extended/server/main.lua @@ -50,7 +50,7 @@ local function onPlayerJoined(playerId) return DropPlayer(playerId, "there was an error loading your character!\nError code: identifier-missing-ingame\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 - if not playerId and ESX.GetPlayerFromIdentifier(identifier) then + if ESX.GetPlayerFromIdentifier(identifier) then DropPlayer( playerId, ("there was an error loading your character!\nError code: identifier-active-ingame\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 Rockstar account.\n\nYour Rockstar identifier: %s"):format( @@ -115,17 +115,27 @@ if not Config.Multichar then return deferrals.done("[ESX] OxMySQL Was Unable To Connect to your database. Please make sure it is turned on and correctly configured in your server.cfg") end - if identifier then - if not playerId and ESX.GetPlayerFromIdentifier(identifier) then + if not identifier 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) + + if not playerId and xIdentifier then + local xId = xIdentifier.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) ) - else - return deferrals.done() end - else - 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 + + return deferrals.done() end) end From 86e9735b81eb4e12936e8d2aec7dd86fe032407b Mon Sep 17 00:00:00 2001 From: Tabby Dev <88893827+Tabby-Labs@users.noreply.github.com> Date: Tue, 20 May 2025 16:01:16 +0800 Subject: [PATCH 2/3] fix(esx_multicharacter/server/modules/functions): remove old player from memory after crashing --- .../esx_multicharacter/server/modules/functions.lua | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/[core]/esx_multicharacter/server/modules/functions.lua b/[core]/esx_multicharacter/server/modules/functions.lua index 6c816571..ccf113d3 100644 --- a/[core]/esx_multicharacter/server/modules/functions.lua +++ b/[core]/esx_multicharacter/server/modules/functions.lua @@ -47,8 +47,16 @@ function Server:OnConnecting(source, deferrals) if identifier then if not ESX.GetConfig().EnableDebug then - if not source and ESX.Players[identifier] then - deferrals.done(("[ESX Multicharacter] A player is already connected to the server with this identifier.\nYour identifier: %s:%s"):format(Server.identifierType, identifier)) + if ESX.Players[identifier] then + local identifierExist = ESX.GetPlayerFromIdentifier(identifier) + + if not identifierExist then -- no player found + ESX.Players[identifier] = nil + print(('[ESX Multicharacter] no player found for identifier (%s), removing from ESX.Players'):format(identifier)) + deferrals.done() + else -- player found + deferrals.done(("[ESX Multicharacter] A player is already connected to the server with this identifier.\nYour identifier: %s:%s"):format(Server.identifierType, identifier)) + end else deferrals.done() end From 0ece059c1934b377e050cd760ef9437b8467bd9f Mon Sep 17 00:00:00 2001 From: Tabby Dev <88893827+Tabby-Labs@users.noreply.github.com> Date: Wed, 21 May 2025 13:48:26 +0800 Subject: [PATCH 3/3] fix(es_extended/server/main): add fallback check if player is exist --- [core]/es_extended/server/main.lua | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/[core]/es_extended/server/main.lua b/[core]/es_extended/server/main.lua index b54450bb..a276dafc 100644 --- a/[core]/es_extended/server/main.lua +++ b/[core]/es_extended/server/main.lua @@ -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