From a5015b8694483434c184a791899b2938617ad0f8 Mon Sep 17 00:00:00 2001 From: Kr3mu Date: Fri, 1 Aug 2025 11:57:04 +0200 Subject: [PATCH] Added pcall for checking player identifier --- [core]/es_extended/server/main.lua | 12 +++++++++--- [core]/esx_identity/server/main.lua | 9 +++++++-- .../esx_multicharacter/server/modules/functions.lua | 7 +++++-- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/[core]/es_extended/server/main.lua b/[core]/es_extended/server/main.lua index 1c927adc..417a016b 100644 --- a/[core]/es_extended/server/main.lua +++ b/[core]/es_extended/server/main.lua @@ -140,7 +140,10 @@ if not Config.Multichar then local playerId = source deferrals.defer() Wait(0) -- Required - local identifier = ESX.GetIdentifier(playerId) + local identifier + local correctLicense, _ = pcall(function () + identifier = ESX.GetIdentifier(playerId) + end) -- luacheck: ignore if not SetEntityOrphanMode then @@ -155,11 +158,14 @@ 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 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.") + if not identifier or not correctLicense then + if GetResourceState("esx_identity") ~= "started" 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 end local xPlayer = ESX.GetPlayerFromIdentifier(identifier) + if not xPlayer then return deferrals.done() end diff --git a/[core]/esx_identity/server/main.lua b/[core]/esx_identity/server/main.lua index 24273531..140a009e 100644 --- a/[core]/esx_identity/server/main.lua +++ b/[core]/esx_identity/server/main.lua @@ -166,10 +166,15 @@ end if not multichar then AddEventHandler("playerConnecting", function(_, _, deferrals) deferrals.defer() - local _, identifier = source, ESX.GetIdentifier(source) + local _, identifier = source, nil + + local correctLicense, _ = pcall(function() + identifier = ESX.GetIdentifier(source) + end) + Wait(40) - if not identifier then + if not identifier or not correctLicense then return deferrals.done(TranslateCap("no_identifier")) end MySQL.single("SELECT firstname, lastname, dateofbirth, sex, height FROM users WHERE identifier = ?", { identifier }, function(result) diff --git a/[core]/esx_multicharacter/server/modules/functions.lua b/[core]/esx_multicharacter/server/modules/functions.lua index 4e0b260f..3567d2f2 100644 --- a/[core]/esx_multicharacter/server/modules/functions.lua +++ b/[core]/esx_multicharacter/server/modules/functions.lua @@ -16,7 +16,10 @@ end function Server:OnConnecting(source, deferrals) deferrals.defer() Wait(0) -- Required - local identifier = ESX.GetIdentifier(source) + local identifier + local correctLicense, _ = pcall(function() + identifier = ESX.GetIdentifier(source) + end) -- luacheck: ignore if not SetEntityOrphanMode then @@ -35,7 +38,7 @@ function Server:OnConnecting(source, deferrals) deferrals.done("[ESX Multicharacter] OxMySQL Was Unable To Connect to your database. Please make sure it is turned on and correctly configured in your server.cfg") end - if not identifier then return deferrals.done(("[ESX Multicharacter] Unable to retrieve player identifier.\nIdentifier type: %s"):format(Server.identifierType)) end + if not identifier or not correctLicense then return deferrals.done(("[ESX Multicharacter] Unable to retrieve player identifier.\nIdentifier type: %s"):format(Server.identifierType)) end if ESX.GetConfig().EnableDebug or not ESX.Players[identifier] then ESX.Players[identifier] = source