diff --git a/[esx]/es_extended/server/classes/player.lua b/[esx]/es_extended/server/classes/player.lua index 32ad4e12..071cce15 100644 --- a/[esx]/es_extended/server/classes/player.lua +++ b/[esx]/es_extended/server/classes/player.lua @@ -109,7 +109,7 @@ function CreateExtendedPlayer(playerId, identifier, group, accounts, inventory, function self.getAccount(account) for i=1, #self.accounts do if self.accounts[i].name == account then - return self.accounts[i], i + return self.accounts[i] end end end @@ -177,11 +177,11 @@ function CreateExtendedPlayer(playerId, identifier, group, accounts, inventory, return end if money >= 0 then - local account, index = self.getAccount(accountName) + local account = self.getAccount(accountName) if account then money = account.round and ESX.Math.Round(money) or money - self.accounts[index].money = money + self.accounts[account.index].money = money self.triggerEvent('esx:setAccountMoney', account) else @@ -198,10 +198,10 @@ function CreateExtendedPlayer(playerId, identifier, group, accounts, inventory, return end if money > 0 then - local account, index = self.getAccount(accountName) + local account = self.getAccount(accountName) if account then money = account.round and ESX.Math.Round(money) or money - self.accounts[index].money += money + self.accounts[account.index].money += money self.triggerEvent('esx:setAccountMoney', account) else @@ -218,11 +218,11 @@ function CreateExtendedPlayer(playerId, identifier, group, accounts, inventory, return end if money > 0 then - local account, index = self.getAccount(accountName) + local account = self.getAccount(accountName) if account then money = account.round and ESX.Math.Round(money) or money - self.accounts[index].money -= money + self.accounts[account.index].money -= money self.triggerEvent('esx:setAccountMoney', account) else diff --git a/[esx]/es_extended/server/main.lua b/[esx]/es_extended/server/main.lua index 7ca0a701..2a46a02f 100644 --- a/[esx]/es_extended/server/main.lua +++ b/[esx]/es_extended/server/main.lua @@ -131,8 +131,14 @@ function loadESXPlayer(identifier, playerId, isNew) if data.round == nil then data.round = true end - userData.accounts[#userData.accounts + 1] = {name = account, money = foundAccounts[account] or Config.StartingAccountMoney[account] or 0, - label = data.label, round = data.round} + local index = #userData.accounts + 1 + userData.accounts[index] = { + name = account, + money = foundAccounts[account] or Config.StartingAccountMoney[account] or 0, + label = data.label, + round = data.round, + index = index + } end -- Job