Added pcall for checking player identifier

This commit is contained in:
Kr3mu
2025-08-01 11:57:04 +02:00
parent b9d735ceca
commit a5015b8694
3 changed files with 21 additions and 7 deletions
+9 -3
View File
@@ -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
+7 -2
View File
@@ -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)
@@ -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