Skip to main content

GetAccount

This function returns the company account class.

exports.bcs_companymanager:GetAccount(companyname)

The Account Class​

Constructor​

VariableTypeDescription
companystringThe company/job name
moneynumberThe total money of the company
blackMoneynumberThe total dirty money of the company
earningnumberThe total earning of the company

Functions​

FunctionReturn TypeDescription
getMoney()numberReturns the company money
addEarning(amount)nilAdds earning to the company. Amount in number
addMoney(account, amount)nilAdds money to the company. Account in string can be money or black_money. Amount in number
removeMoney(account, amount)nilRemoves 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