Resource:JRBank

From Multi Theft Auto: Wiki

Jump to: navigation, search

A realistic bank system made from scratch by JR10.
It uses SQLite, to save accounts and balance, a player can open more than one account.

Contents

Features

  • Opening more than one account, there is settings for MaxAccounts.
  • Closing accounts, and you will withdraw all the money in it.
  • Changing name and password of the account.
  • Like a read ATM ... you have to select the amount by clicking the buttons.
  • Deposit, Withdraw and Transfer.
  • Transfer to account or player, if account the money will be transferred to the account, if player then a grid list containing all the accounts (with the same serial as the player's) and the player will choose which account to deposit the transferred money in.
  • Last action ... the last action you made whether it's deposit, withdraw or transfer.
  • Remember name and password.
  • Moving fading GUI when opening the bank
  • 3 Ways of adding banks, map (made EDF for it), Banks.xml, JRBank_createBank - JRBank_createATM function, There is settings in the meta for how to add banks. (all supported)
  • 14 Exported functions.
  • Meta.xml Settings:
    *AddingBanks: How to add banks, by maps, by Banks.xml, by functions, or all.
    *MaxAccounts: Number of max accounts for one serial.
    *BindKey: The key used to open the GUI when standing on a bank marker.
    *CaseSensitive: Whether Names and passwords are case sensitive or not.
    *AllowInterest: Every hour there will be interest if this is true.
    *Interest: Interest , The interest - example: 0.01 = 0.01 interest on the account's balance ( +1 will be added to the value!! So the value is only the interest ).

Exported Functions

JRBank_createBank || JRBank_createATM

Click to collapse [-]
Server

This functions are used to create a bank at the coordinates.

Syntax

bool JRBank_createBank(float posX, float posY, float posY[, int size, string type, int r, int g, int b, int interior, int dimension])
bool JRBank_createBank(float posX, float posY, float posY[, int size, string type, int r, int g, int b, int interior, int dimension])

Required Arguments

  • posX: The x coordinate of the destination.
  • posY: The y coordinate of the destination.
  • posZ: The z coordinate of the destination.

Optional Arguments

NOTE: When using optional arguments, you must supply all arguments before the one you wish to use. For more information on optional arguments, see Optional Arguments.

  • size: The size of the bank marker.
  • type: The type of the bank marker.
  • r: The R value of the color RGB format.
  • g: The G value of the color RGB format.
  • b: The B value of the color RGB format.
  • interior: The interior of the bank marker.
  • dimension: The dimension of the bank marker.

Returns

Returns a bool, Whether the bank were created successfully or not.


JRBank_countBanks || JRBank_countATMs || JRBank_countBanksAndATMs

Click to collapse [-]
Server

This functions are used to count the number of banks.

Syntax

int JRBank_countBanks()
int JRBank_countATMs()
int JRBank_countBanksAndATMs()

Returns

Returns an integer with the number of banks.


JRBank_getPlayerBankAccounts

Click to collapse [-]
Server

This functions are used to get the player accounts (with his serial).

Syntax

bool/table JRBank_getPlayerBankAccounts(player thePlayer)

Required Arguments

  • thePlayer: The player you wish the retrieve his bank accounts

Returns

Returns a table, with the player's accounts This table, or false if the player doesn't exist or he have no bank account, can be used like: theTable[accountID].attribute attribute can be:

    *name
    *password
    *balance
    *lastaction
    *serial

Example

local accounts = JRBank_getPlayerBankAccounts(player)
if accounts ~= false and #accounts > 0 then
     for id, account in ipairs (accounts) do
         outputChatBox("Account name: "..account.name)
         outputChatBox("Account password: "..account.password)
         outputChatBox("Account balance: "..account.balance)
         outputChatBox("Account lastaction: "..account.lastaction)
         outputChatBox("Account serial: "..account.serial)
     end
     -- another way:
    accounts[1].name
    accounts[1].password
    accounts[2].name
    accounts[2].balance
end


JRBank_openNewBankAccount

Click to collapse [-]
Server

This functions is used to open a new bank account.

Syntax

bool JRBank_openNewBankAccount(string accountName, string accountPassword[, int balance, string serial])

Required Arguments

  • accountName: The name of the account.
  • accountPassword: The password of the account.

Optional Arguments

NOTE: When using optional arguments, you must supply all arguments before the one you wish to use. For more information on optional arguments, see Optional Arguments.

  • balance: The amount of money in the account.
  • serial: The serial of the account.

Returns

Returns a bool whether the account was opened or not.


JRBank_closeBankAccount

Click to collapse [-]
Server

This functions is used to close a bank account.

Syntax

bool JRBank_closeBankAccount(string accountName)

Required Arguments

  • accountName: The name of the account.

Returns

Returns a bool whether the account was closed or not.


JRBank_depositToAccount

Click to collapse [-]
Server

This functions is used to deposit money in a bank account.

Syntax

bool JRBank_depositToAccount(string accountName, int amount)

Required Arguments

  • accountName: The name of the account.
  • amount: The amount of money to deposit.

Returns

Returns a bool whether the money was deposited or not.


JRBank_withdrawFromAccount

Click to collapse [-]
Server

This functions is used to withdraw money from a bank account.

Syntax

bool JRBank_withdrawFromAccount(string accountName, int amount)

Required Arguments

  • accountName: The name of the account.
  • amount: The amount of money to withdraw.

Returns

Returns a bool.


JRBank_depositFromPlayerToAccount

Click to collapse [-]
Server

This functions is used to deposit money from a player to a bank account

Syntax

bool JRBank_depositFromPlayerToAccount(player, thePlayer, string accountName, int amount)

Required Arguments

  • thePlayer: The player to deposit the money from.
  • accountName: The name of the account.
  • amount: The amount of money to withdraw, "all" can be used here to deposit all the player's money.

Returns

Returns a bool.


JRBank_withdrawFromAccountToPlayer

Click to collapse [-]
Server

This functions is used to withdraw money from a bank account to a player.

Syntax

bool JRBank_withdrawFromAccountToPlayer(string accountName, player thePlayer, int amount)

Required Arguments

  • accountName: The name of the account.
  • thePlayer: The player to give the money to.
  • amount: The amount of money to withdraw, "all" can be used here to withdraw all the money from the account.

Returns

Returns a bool.


JRBank_transferFromAccountToAccount

Click to collapse [-]
Server

This functions is used to transfer money from a bank account to another bank account.

Syntax

bool JRBank_transferFromAccountToAccount(string accountName, string toAccountName, int amount)

Required Arguments

  • accountName: The name of the account.
  • toAccountName: The name of the account to transfer the money to.
  • amount: The amount of money to withdraw, "all" can be used here to transfer all the balance in the account.

Returns

Returns a bool.


JRBank_transferFromAccountToPlayer

Click to collapse [-]
Server

This functions is used to transfer money from a bank account to a player Note: a grid list containing all the accounts (with the same serial as the player's) and the player will choose which account to deposit the transferred money in..

Syntax

bool JRBank_transferFromAccountToPlayer(string accountName, player thePlayer, int amount)

Required Arguments

  • accountName: The name of the account.
  • thePlayer: The player to transfer the money to.
  • amount: The amount of money to withdraw, "all" can be used here to transfer all the balance in the account.

Returns

Returns a bool.


Credits

Remp: for the guieditor.


See also

Official Forum Thread
Download page