mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-09-04 16:23:21 +00:00
Merge pull request #1794 from ASTROWwwW/fix/esx-server-guards
fix(es_extended): guard getMoney and player load against missing data
This commit is contained in:
@@ -114,7 +114,8 @@ function CreateExtendedPlayer(playerId, identifier, ssn, group, accounts, invent
|
||||
end
|
||||
|
||||
function self.getMoney()
|
||||
return self.getAccount("money").money
|
||||
local account = self.getAccount("money")
|
||||
return account and account.money or 0
|
||||
end
|
||||
|
||||
function self.addMoney(money, reason)
|
||||
|
||||
@@ -200,6 +200,11 @@ function loadESXPlayer(identifier, playerId, isNew)
|
||||
|
||||
local result = MySQL.prepare.await(loadPlayer, { identifier })
|
||||
|
||||
if not result then
|
||||
print(("[^1ERROR^7] esx_core could not load data for identifier ^5%s^7"):format(identifier))
|
||||
return DropPlayer(playerId --[[@as string]], "There was an error loading your character!\nError code: data-load-failed\n\nYour character data could not be retrieved. Please reconnect, and contact the server administration team if this keeps happening.")
|
||||
end
|
||||
|
||||
-- Accounts
|
||||
local accounts = result.accounts
|
||||
accounts = (accounts and accounts ~= "") and json.decode(accounts) or {}
|
||||
|
||||
Reference in New Issue
Block a user