Jump to content

[REL] Banking System 2.3


50p

Recommended Posts

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.

7/05/2008

Fixed the most irritating bug which deleted accounts.xml file after restarting server!

8/05/2008

Not saving money at all caused by not creating "account" in SQL database.

10/05/2008

/deposit command fixed and your bank balance shown to everyone on server when you log in

11/05/2008

Admins have ability to add their own banks into an XML file (banks.locations.xml), so you can have more banks on your server!

13/05/2008

Fixed a strange bug. When you typed negative values you gained lots of money.

1/11/2008

Added lots of features that are described above.

17/03/2010

Fixed issues with invisible bank and ATM markers.

Edited by Guest
Link to comment
  • Replies 152
  • Created
  • Last Reply

Top Posters In This Topic

Yes thats possible. In earlier times i made something like this to learn xml functions but i never finished it =)

Basically all you need is xmlCreateSubNote, xmlNodeSetAttribute, xmlNodeGetAttribute, xmlFindSubNode, xmlLoadFile and xmlSaveFile but don't forget to set the resource in an acl group that is allowed to edit other files.

Link to comment

ty but is this marked at the map when the script is on? if it isnt, well then its just to make a con or something on that place :P

I think it's not really important. But if you think it is then you can attach a blip or add an icon yourself. Maybe I'll do an update with GUI and saving money soon.

well i have tried, i have never scripted but here it goes

function createBlip( ) 
  
   -- blip createBlip ( float 2413.0571289063, float 1123.8974609375, float 10.8203125, [int icon=52, int size=2, int r=255, int g=0, int b=0, int a=255, int ordering=0, visibleTo=getRootElement()] ) 
end 
  
addEvent("doShowObjectBrowser")  -----------what are im suposed to type here? 
  
  
addEventHandler("doShowObjectBrowser", getRootElement(), showObjectBrowser)  ------- what are im suposed to type here? 

this is my very first thing ive tried to script so dont be so hard im trying :D, what have i done wrong? and what are im suposed to write in some plases that ive marked, would be very nice if someone tried to help me, and i know that this must be a client side. :D

Link to comment

ok in the script that i have made you can enable or disable the stats, window and enable or disable the bank script, i have so far made it so that players can use the petrol stations and other things in game, banks are on next on my list.

i fixed the laggy ness of the script for the next release :D

Link to comment

realy nice! works pretty good!

but i have a desire:

its possibly that when the player is NOT loged in, the GUI dont show and a chat text is shown with the text "login or register first to use the bank system"

and a question:

its allowed to commenting line 56 on bank.script.server.lua ?

Link to comment
realy nice! works pretty good!

but i have a desire:

its possibly that when the player is NOT loged in, the GUI dont show and a chat text is shown with the text "login or register first to use the bank system"

and a question:

its allowed to commenting line 56 on bank.script.server.lua ?

If you want to comment it, do it. But you want your players to know that this script is running, so they can go banking.

Link to comment
ok thanks, and i last question: i get things like "false userdata:" sometimes, i have search keywords like userdata in the script, but nothing found :?:

i want to remove this

When does it usually happens?

EDIT:

Found it. Fixed it. Re-download it.

Link to comment

thanks!

can you say me waht you have change to fix this? because i will learn it and i have translatet the script and changed a few things

//EDIT: i have found a new very very strange bug:

sometimes in the accounts.xml all accounts are deleted, i am not sure why and when but it happened sometimes

sorry for all my bug-reports, your script is so good but it a little bit pity when the money goes lost

Link to comment
thanks!

//EDIT: i have found a new very very strange bug:

sometimes in the accounts.xml all accounts are deleted, i am not sure why and when but it happened sometimes

sorry for all my bug-reports, your script is so good but it a little bit pity when the money goes lost

Never noticed that! If you could find out when the accounts gets deleted then maybe I could fix it you it might be MTA bug.

If you didn't report the bugs, the script wouldn't be useful and nobody would download it.

Link to comment
Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.

×
×
  • Create New...