GetAccount
This function returns the company account class.
exports.bcs_companymanager:GetAccount(companyname)
The Account Class​
Constructor​
Variable | Type | Description |
---|---|---|
company | string | The company/job name |
money | number | The total money of the company |
blackMoney | number | The total dirty money of the company |
earning | number | The total earning of the company |
Functions​
Function | Return Type | Description |
---|---|---|
getMoney() | number | Returns the company money |
addEarning(amount) | nil | Adds earning to the company. Amount in number |
addMoney(account, amount) | nil | Adds money to the company. Account in string can be money or black_money . Amount in number |
removeMoney(account, amount) | nil | Removes money from the company. Account in string can be money or black_money . Amount in number |
Example Usage​
You can use this to add/remove money/black money.
RegisterCommand('withdrawpolice', function(source, args, raw)
local companyAccount = exports['bcs_companymanager']:GetAccount('police')
local xPlayer = ESX.GetPlayerFromId(source)
if companyAccount.money >= 5000 then
companyAccount.removeMoney('money', 5000)
xPlayer.addMoney(5000)
end
end, true)
RegisterCommand('withdrawblackpolice', function(source, args, raw)
local companyAccount = exports['bcs_companymanager']:GetAccount('police')
local xPlayer = ESX.GetPlayerFromId(source)
if companyAccount.blackMoney >= 5000 then
companyAccount.removeMoney('black_money', 5000)
xPlayer.addMoney(5000)
end
end, true)
QB Example for qb-customs
.
qb-customs/server/sv_bennys.lua
if paidBySociety then
local companyAccount = exports['bcs_companymanager']:GetAccount(job)
if companyAccount.money >= price then
companyAccount.removeMoney('money', price)
else
paidBySociety = false
TriggerClientEvent('QBCore:Notify', source, "Your job society can't pay for this. You will be charged instead.")
end
end
if balance >= price or paidBySociety then
if not paidBySociety then
Player.Functions.RemoveMoney(moneyType, price, "bennys")
end
if jobRestricted and job ~= 'mechanic' then
local companyAccount = exports['bcs_companymanager']:GetAccount("mechanic")
companyAccount.addMoney("money", price)
end
TriggerClientEvent('qb-customs:client:purchaseSuccessful', source)
else
TriggerClientEvent('qb-customs:client:purchaseFailed', source)
end