Bank System v2.3
As name of the topic says. This is a bank system resource. I've seen some topics where people where asking for a bank system so I made it. I started learning OOP in Lua and found THIS website. It contains some basic OOP that is also based on a bank account example.
If you want your server players to save their money you can use this advanced system. Permanent saving is available for registered/logged in players!
By default bank marker are inside "City Planing Department" (Las Venturas, behind the TransFender tuning shop) and there is also a new ATM near Cluckin' Bell (east side of LV).
Banks in XML
New attributes added, here is a structure of bank (also ATM)
<bank name="Bank name here" blip="true" depositAllowed="true" >
<location posX="0.0" posY="0.0" posZ="0.0" ATM="false" ATMRot="0.0" markerSize="2" interior="0" />
<entrance posX="0.0" posY="0.0" posZ="0.0" teleX="0.0" teleY="0.0" teleZ="0.0" teleRot="0.0" teleInterior="0" />
<exit posX="0.0" posY="0.0" posZ="0.0" teleX="0.0" teleY="0.0" teleZ="0.0" teleRot="0.0" teleInterior="0" interior="0" />
</bank>
- main bank construction starts with this node
name - Bank's name will be displayed at the top window bar when you enter the bank's marker ().
blip(optional, default = true) - whether you want to show '$' sign on the map when close to bank or not (true/false)
allowedDeposit(optional, default = true) - whether deposit tab is enabled or disabled (you can disable it if you don't want players to deposit money at ATMs)
[*] - the marker location of the bank itself
posX, posY, posZ - position of the main bank marker (shows bank window when entered)
ATM - whether this bank is ATM or not (true/false)
interior (old ATMInterior) - what interior the bank is in (this is required if interior ID is not 0, outside world)
ATMRot - rotation of the ATM (Z axis) (0 => ATM object is set on the north side of the bank marker)
markerSize - size of the marker, you could change it to 2 if it's a Bank and 1 if it's ATM (any value is acceptable)
[*] - the marker that sends you to the different interior
posX, posY, posZ - position of the marker
teleX, teleY, teleZ - position where you will be teleported when you hit this marker
teleRot - rotation of the player after teleportation
teleInterior - interior of the teleport position (usually same as bank's interior)
[*] - the marker that is placed inside the bank interior and should send you back outside the bank (somewhere near entrance)
posX, posY, posZ - position of the marker
teleX, teleY, teleZ - position where you should be teleported back when you hit this marker
teleRot - rotation of the player after teleportation
teleInterior - interior of the teleportation (usually 0, outside)
Custom events
MTA allows us to add custom event. I took this advantage and added a few events that can be used in your resource. Here they are:
onPlayerWithdrawMoney
onPlayerDepositMoney
onPlayerTransferMoney
onPlayerEnterBank
onPlayerLeaveBank
All of the event's source is player. The parameters for each of the events are in "server/test.eventsAndFunctions.lua".
Exported functions
Here is a list of all exported functions that can be called from other resources.
getBankID( bankMarker )
getBankMarker( bankID )
getBankName( bankID )
getBankMarkers( )
getBankEntranceMarker( bankID )
getBankExitMarker( bankID )
countBanks( )
getBankAccountBalance( accountName, SQLdata )
setBankAccountBalance( accountName, newbalance, SQLdata )
getPlayersInBank( bankID )
getPlayerBank( player )
withdrawPlayerMoney( player, amount, SQLdata )
depositPlayerMoney( player, amount, SQLdata )
Most of the functions are documented in "server/bank.exported.funcs.lua".
NOTE: Some of the functions have SQLdata parameter, this parameter is a table which should have 3 fields (tab, username, balance). This is optional param, if you won't use it, resource will use the data from meta.xml. More about it below.
Settings in meta.xml
When you open meta.xml you will see some setting nodes. These are mostly settings of SQL.
useATM - if you want to use this ATMs this should be set to true (default = true)
SQLTable - table name of where the money is saved into
SQLUserNameField - the name of field where usernames are stored
SQLMoneyField - what is the field where money are stored in
Download:
https://community.multitheftauto.com/index.php?p= ... ails&id=54
Installation:
Place .zip file in your server's resources folder.