Banking
The banking providers provide a service that allows resources to interact with bank accounts.
Usage
To retrieve the banking provider, use the load function with "banking" for the service parameter.
Lua:
local bankingProvider = exports.r3_servicesmanager:load("banking")JavaScript:
const bankingProvider = exports.r3_servicesmanager.load("banking");Server
On the server side, the following methods are available:
getAccountBalance
Retrieves the balance of the specified bank account.
bankingProvider.getAccountBalance(account)Parameters:
- account:
string
Returns:
numbernilif the account could not be found.
addAccountBalance
Adds money to the given account, and returns whether or not it was succesful.
bankingProvider.addAccountBalance(account, amount)Parameters:
- account:
string - amount:
number
Returns:
trueif the balance was successfully added.falseif the balance wasn’t successfully added (i.e. the account could not be found).
removeAccountBalance
Removes money from the given account, and returns whether or not it was succesful.
bankingProvider.removeAccountBalance(account, amount)Parameters:
- account:
string - amount:
number
Returns:
trueif the balance was successfully removed.falseif the balance wasn’t successfully removed (i.e. the account could not be found or there is not enough money in the account).
accountHasBalance
Checks whether the given account’s balance is bigger than or equal to the specified amount.
bankingProvider.accountHasBalance(account, amount)Parameters:
- account:
string - amount:
number
Returns:
trueif the account’s balance is bigger than or equal to the specified amount.falseif the account’s balance is less than the specified amount, or if the account could not be found.
Registration
To register a banking provider, ensure it implements all methods described above. Check out banking.lua and banking.ts for type definitions.
When your provider object implements all methods, you can register it as follows:
Lua:
exports.r3_servicesmanager:register("banking", provider, priority, GetCurrentResourceName())JavaScript:
exports.r3_servicesmanager.register("banking", provider, priority, GetCurrentResourceName());For priority, it is recommended to use priority 2, this corresponds to ServicePriority.Normal. It would be even better to allow server owners to configure the used priority in the configuration of your resource so that they can choose which resource takes priority.