Implemented starting balance, closes #537

This commit is contained in:
ElPumpo
2020-03-04 13:01:46 +01:00
parent 4e4ebfff7b
commit a2308dec59
3 changed files with 12 additions and 10 deletions
+2
View File
@@ -7,6 +7,8 @@ Config.Accounts = {
money = _U('account_money')
}
Config.StartingAccountMoney = {bank = 50000}
Config.EnableSocietyPayouts = false -- pay from the society account that the player is employed at? Requirement: esx_society
Config.DisableWantedLevel = true
Config.EnableHud = true -- enable the default hud? Display current job and accounts (black, bank & cash)
+5 -4
View File
@@ -164,7 +164,7 @@ function CreateExtendedPlayer(playerId, identifier, group, accounts, inventory,
end
if not found then
table.insert(missingAccounts, account)
missingAccounts[account] = Config.StartingAccountMoney[account] or 0
end
end
@@ -172,10 +172,11 @@ function CreateExtendedPlayer(playerId, identifier, group, accounts, inventory,
end
self.createMissingAccounts = function(missingAccounts, cb)
for k,v in ipairs(missingAccounts) do
MySQL.Async.execute('INSERT INTO user_accounts (identifier, name) VALUES (@identifier, @name)', {
for name,money in pairs(missingAccounts) do
MySQL.Async.execute('INSERT INTO user_accounts (identifier, name, money) VALUES (@identifier, @name, @money)', {
['@identifier'] = self.identifier,
['@name'] = v
['@name'] = name,
['@money'] = money
}, function(rowsChanged)
if cb then
cb()
+5 -6
View File
@@ -169,12 +169,12 @@ function loadESXPlayer(identifier, playerId)
local xPlayer = CreateExtendedPlayer(playerId, identifier, userData.group, userData.accounts, userData.inventory, userData.job, userData.loadout, userData.playerName, userData.coords)
xPlayer.getMissingAccounts(function(missingAccounts)
if #missingAccounts > 0 then
for k,v in ipairs(missingAccounts) do
if ESX.Table.SizeOf(missingAccounts) > 0 then
for name,money in pairs(missingAccounts) do
table.insert(xPlayer.accounts, {
name = v,
money = 0,
label = Config.Accounts[v]
name = name,
money = money,
label = Config.Accounts[name]
})
end
@@ -192,7 +192,6 @@ function loadESXPlayer(identifier, playerId)
inventory = xPlayer.getInventory(),
job = xPlayer.getJob(),
loadout = xPlayer.getLoadout(),
money = xPlayer.getMoney(),
maxWeight = xPlayer.maxWeight
})