RX Scripts Logo
Account

Functions

Server-side society/shared account functions for managing organization funds.

The Account adapter provides unified management of society/shared accounts across different systems.

Note: RxBanking support is available but commented out by default. Uncomment the code in adapters/server/account.lua if you want to integrate with RxBanking.

Functions

getMoney

Gets the current balance of a society/shared account.

FM.account.getMoney(accountName)
accountName
string required

The name of the society/shared account (e.g., 'society_police')

Returns: number - The current balance (returns 0 if account not found)

Example:

local policeBalance = FM.account.getMoney("society_police")
print("Police department balance: $", policeBalance)

local mechanicBalance = FM.account.getMoney("society_mechanic")
if mechanicBalance >= 10000 then
    print("Mechanic shop has enough funds")
end

addMoney

Adds money to a society/shared account.

FM.account.addMoney(accountName, amount)
accountName
string required

The name of the society/shared account

amount
number required

The amount of money to add

Returns: boolean - True if money was added successfully

Example:

-- Add money to police account
if FM.account.addMoney("society_police", 5000) then
    print("Added $5000 to police department")
end

-- Deposit mechanic earnings
FM.account.addMoney("society_mechanic", 2500)

removeMoney

Removes money from a society/shared account.

FM.account.removeMoney(accountName, amount)
accountName
string required

The name of the society/shared account

amount
number required

The amount of money to remove

Returns: boolean - True if money was removed successfully, false if insufficient funds or account not found

Example:

-- Withdraw from police account
if FM.account.removeMoney("society_police", 1000) then
    print("Withdrew $1000 from police department")
else
    print("Insufficient funds")
end

-- Purchase equipment
local cost = 5000
if FM.account.removeMoney("society_ambulance", cost) then
    -- Give equipment
    print("Equipment purchased")
else
    print("Cannot afford equipment")
end

Exports

All account functions are available as exports:

exports['fmLib']:account_getMoney(accountName)
exports['fmLib']:account_addMoney(accountName, amount)
exports['fmLib']:account_removeMoney(accountName, amount)