mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-08-29 09:18:53 +00:00
Implemented starting balance, closes #537
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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
@@ -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
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user