Resource:JRBank
From Multi Theft Auto: Wiki
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.
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
This functions are used to create a bank at the coordinates.
Syntax
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
This functions are used to count the number of banks.
Syntax
Returns
Returns an integer with the number of banks.
JRBank_getPlayerBankAccounts
This functions are used to get the player accounts (with his serial).
Syntax
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
This functions is used to open a new bank account.
Syntax
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
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
This functions is used to deposit money in a bank account.
Syntax
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
This functions is used to withdraw money from a bank account.
Syntax
Required Arguments
- accountName: The name of the account.
- amount: The amount of money to withdraw.
Returns
Returns a bool.
JRBank_depositFromPlayerToAccount
This functions is used to deposit money from a player to a bank account
Syntax
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
This functions is used to withdraw money from a bank account to a player.
Syntax
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
This functions is used to transfer money from a bank account to another bank account.
Syntax
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
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
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.