🎉 Character is released. Read more →
Paid Scripts
Company Manager
Functions & Events
Server
Get Account

GetAccount Function

The GetAccount function allows you to retrieve account information and methods for a specified company or gang.

Description

This function returns financial data and methods for a company or gang account, including regular money, black money, and earnings information. It also provides methods to modify and retrieve these values.

Usage

exports['bcs_companymanager']:GetAccount(name)

Parameters

NameTypeDescription
namestringThe name of the company or gang account to retrieve

Returns

If the account exists, returns a table with the following structure:

{
    company = string,     -- The company/gang name
    isGang = boolean,     -- Whether this is a gang account (true) or company account (false)
    money = number,       -- Current regular money balance
    blackMoney = number,  -- Current black money balance (if enabled)
    earning = number,     -- Current earnings
 
    -- Methods
    AddMoney = function(accountType, amount, identifier, reason, isPaying),         -- Add money to the account
    RemoveMoney = function(accountType, amount, identifier, reason, isPaying),      -- Remove money from the account
    GetMoney = function(),               -- Get the current money balance
    AddEarning = function(amount),       -- Add to the earnings record
}

Returns nil if the account doesn't exist.

Parameters

ParameterTypeDescription
accountTypenumberThe type of account (money/blackmoney)
amountnumberThe amount to add (must be positive)
identifierstringThe identifier of the person/entity making the transaction
reasonstringThe reason for the transaction
isPayingboolean(optional)Whether this transaction is for paying off a bill

Examples

Check Account Balance

local account = exports['bcs_companymanager']:GetAccount('police')
if account then
    print('Police department funds: $' .. account.money)
else
    print('Police account not found')
end

Add Account Balance

local account = exports['bcs_companymanager']:GetAccount('mechanic')
if account then
    -- Add $5000 to mechanic shop account
    account.AddMoney('money', 5000, 'license:1234567', 'Vehicle repair services', false)
    
    -- Check updated balance
    local newBalance = account.GetMoney()
    print('New mechanic shop balance: $' .. newBalance)
end

Remove Account Balance

local account = exports['bcs_companymanager']:GetAccount('police')
if account then
    -- Remove $2000 from the police department for equipment purchases
    account.RemoveMoney('money', 2000, 'license:1234567', 'Equipment purchase', false)
end

Track Earnings

local account = exports['bcs_companymanager']:GetAccount('ambulance')
if account then
    -- Record $1500 in service fees
    account.AddEarning(1500)
    
    -- Print current earnings
    print('Ambulance department earnings: $' .. account.earning)
end

Notes

  • The function refreshes the account data before returning it to ensure values are current
  • Account operations should be performed server-side for security
  • Gang accounts may have different permissions depending on your configuration
Last updated on