mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-08-29 01:08:54 +00:00
Experimental - refactor(es_extended):change accounts to handle index within its object
this should correct the behaviour when working with ESX within v8
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user