mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-08-29 04:01:22 +00:00
Merge pull request #1691 from Kr3mu/license_deffer
feat(esx_core) Added pcall for checking player identifier as new ESX.GetIdentifier retruns error when identifier isn't found.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user