This page details the Server-side Exports available in KS-Bank. These functions allow other resources to interact with the banking system, manage balances, cards, and log transactions.
π€ IsPrimaryAccount
Checks if a specific bank username represents a Primary Account (the default personal account linked to a player's license) or a Secondary/Business account.
Parameters:
username (string): The bank username to check.
Returns: true if the account is a Primary account, otherwise false.
localisPrimary=exports['KS-Bank']:IsPrimaryAccount("john_doe")ifisPrimarythenprint("This is a personal player account.")elseprint("This is a business or secondary account.")end
π€ Primary Account Management (By Source)
These exports interact with the player's main framework account (ESX/QBCore/Qbox) using their Server ID (source).
AddMoneyToPrimaryAccount
Adds funds to the player's default bank account.
Parameters:
source (number): The player's Server ID.
amount (number): Amount to add.
Returns: true if successful, false if the player is invalid or amount is invalid.
RemoveMoneyFromPrimaryAccount
Removes funds from the player's default bank account. Checks if the balance is sufficient before removing.
Parameters:
source (number): The player's Server ID.
amount (number): Amount to remove.
Returns: true if successful, false if funds are insufficient.
PrimaryBalance
Retrieves the current bank balance of the player linked to the source.
Parameters:
source (number): The player's Server ID.
Returns: (number) The current balance. Returns 0 if player not found.
GetPrimaryIbanBySource
Retrieves the IBAN associated with the player's primary account.
Parameters:
source (number): The player's Server ID.
Returns: (string) The IBAN, or nil if not found.
GetAccessibleUsernamesBySource
Returns a list of all banking usernames the player has access to. This includes their personal account and any shared/business accounts where they have saved credentials.
Parameters:
source (number): The player's Server ID.
Returns: (table) A list of strings (usernames).
π Username Management (System Internal)
These exports manage accounts using the specific Bank Username. They work for both player accounts and internal/business accounts stored in KS-Bank.
BalanceByUsername
Gets the balance of a specific bank username.
Parameters:
username (string): The unique bank username.
Returns: (number) The account balance.
GetIbanByUsername
Gets the IBAN associated with a specific username.
Parameters:
username (string): The bank username.
Returns: (string) The IBAN, or nil.
AddMoneyByUsername
Adds money to a specific username. Automatically syncs with ESX/QB if the username belongs to a player.
Parameters:
username (string): The bank username.
amount (number): Amount to add.
Returns: true on success, false on failure.
RemoveMoneyByUsername
Removes money from a specific username.
Parameters:
username (string): The bank username.
amount (number): Amount to remove.
Returns: true on success, false if balance is insufficient.
π Secure Management (Password Required)
These exports perform operations only if the correct password is provided
BalanceByUsernameSecure
Parameters: username, password, source (optional, for notifications).
Returns: (number) Balance or 0 if authentication fails.
AddMoneyByUsernameSecure
Parameters: username, password, amount, source.
Returns: (boolean) true on success.
RemoveMoneyByUsernameSecure
Parameters: username, password, amount, src.
Returns: (boolean) true on success.
π³ Card Management
Functions to manage card balances and limits.
AddMoneyToCard
Adds funds to a Credit or Prepaid card.
Parameters:
username (string): The account owner.
cardType (string): 'credit' or 'prepaid'.
amount (number): Amount to add.
Returns: true or false, "error_message".
RemoveMoneyFromCard
Deducts funds from a card. Checks both the Card Balance and the Daily Spending Limit.
Parameters:
username (string): The account owner.
cardType (string): 'credit' or 'prepaid'.
amount (number): Amount to deduct.
Returns: true or false, "error_message" (e.g., shop_limit_exceeded).
ResetUserCardLimits
Manually resets the daily spending limits for a specific user's card.
Parameters:
username (string): The account owner.
cardType (string): 'credit' or 'prepaid'.
Returns: true or false.
π Transactions (History)
Use these exports to log operations in the banking history or retrieve past records.
AddBankTransaction
Registers a new transaction in the database. Important: All fields in the transactionData table are mandatory. If a specific detail is unavailable (like a Full Name), you must provide a placeholder or an empty string. nil values may cause the transaction to fail or log incorrectly.
Parameters:
username (string): The username associated with the transaction log (usually the sender).
transactionData (table): A table containing all the following keys:
Key
Type
Description
sender_username
String
Username of the sender.
sender_fullname
String
Full name of the sender. Required.
sender_iban
String
IBAN of the sender. Required.
receiver_username
String
Username of the receiver.
receiver_fullname
String
Full name of the receiver. Required.
receiver_iban
String
IBAN of the receiver. Required.
amount
Number
The transaction amount.
reason
String
Description/Reason for the transfer. Required.
payment_type
String
Type label (e.g., "transfer", "withdraw").
Example Usage:
GetPlayerTransactions
Retrieves the transaction history for a specific username.
Parameters:
username (string): The account username.
limit (number, optional): Max number of records to fetch.