Class Server.XAccount

Extends: Server.DBSC

Fields

bid: string
Visibility: public
the unique identifier of the account
balance_major: integer
Visibility: public
the major balance of the account
balance_minor: integer
Visibility: public
the minor balance of the account

Methods

new(): Server.XAccount
Note: @nodiscard - Return value should not be ignored
Creates a new XAccount instance.
Returns: account The new XAccount instance.
getBalanceFloat(): number
Note: @nodiscard - Return value should not be ignored
Returns the current balance of the account as a floating point number.
Returns: balance The current balance of the account.
getBalance(): integer
Note: @nodiscard - Return value should not be ignored
Returns the current balance of the account, as two seperate integers. The first integer is the major balance and the second integer is the minor balance. the major balance is the whole number part of the balance and the minor balance is the fractional part of the balance, multiplied by 100. If you don't care about floating point precision, you can use `XAccount:getBalanceFloat()` instead.
Returns: balance_minor The minor balance of the account.
hasBalanceFloat(amount: number): boolean
Note: @nodiscard - Return value should not be ignored
Checks if the account has at least the given amount of balance.
Parameters:
  • amount (number): The amount to check against the account balance.
Returns: has_balance True if the account has at least the given amount of balance, false otherwise.
hasBalance(major: number, minor: number): boolean
Note: @nodiscard - Return value should not be ignored
Checks if the account has at least the given amount of balance.
Parameters:
  • major (number): The major part of the amount to check against the account balance.
  • minor (number): The minor part of the amount to check against the account balance.
Returns: has_balance True if the account has at least the given amount of balance, false otherwise.
addBalance(major: number, minor: number)
Adds the given amount to the account balance.
Parameters:
  • major (number): The major part of the amount to add to the account balance.
  • minor (number): The minor part of the amount to add to the account balance.
addBalanceFloat(amount: number)
Adds a floating point amount to the account balance. When using larger amounts, this may lead to floating point precision issues. If you want to avoid this, use `XAccount:addBalance(major, minor)` instead.
Parameters:
  • amount (number): The amount to add to the account balance.
removeBalance(major: number, minor: number)
Removes the given amount from the account balance.
Parameters:
  • major (number): The major part of the amount to remove from the account balance.
  • minor (number): The minor part of the amount to remove from the account balance.
removeBalanceFloat(amount: number)
Removes a floating point amount from the account balance.
Parameters:
  • amount (number): The amount to remove from the account balance.
getFormattedBalance(): string
Note: @nodiscard - Return value should not be ignored
Returns the amount of money on this account as a string, using the currency formatting defined in `Config.Currency.format`.
Returns: formatted_balance The formatted balance of the account.
send(major: number, minor: number, to_account: Server.XAccount, reason: string): Server.XTransaction
Sends the given amount of money to the given account.
Parameters:
  • major (number):
  • minor (number):
  • to_account (Server.XAccount):
  • reason (string):
Returns: transaction the created transaction
sendFloat(amount: number, to_account: Server.XAccount, reason: string): Server.XTransaction
Sends the given amount of money to the given account.
Parameters:
Returns: transaction the created transaction
getTransactions(): table<Server.XTransaction>
Note: @nodiscard - Return value should not be ignored
Returns a table of all transactions associated with this account.
Returns: transactions all transactions of this account.
__tostring(): string
Returns a string representation of the account.
Returns: str The string representation of the account.