50p Posted February 18, 2008 Share Posted February 18, 2008 (edited) 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/2008Fixed 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 March 17, 2010 by Guest Link to comment
XetaQuake Posted February 18, 2008 Share Posted February 18, 2008 really nice! it is possibly to make it saved when the server are restart? i think the best way is to save the players money by serial (by serial = no login) in a file (not database) Link to comment
Mr.Hankey Posted February 18, 2008 Share Posted February 18, 2008 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
FIRESTARTER Posted February 22, 2008 Share Posted February 22, 2008 exaktly where is the bank? can you plz tell me where the bank is? ty Link to comment
50p Posted February 22, 2008 Author Share Posted February 22, 2008 http://img91.imageshack.us/img91/9951/bankcity3wo7.jpg Link to comment
XetaQuake Posted February 25, 2008 Share Posted February 25, 2008 50p or anybody else, can you pleas make a Fully Banking System, with deposit, withdraw and save in a file or mysql and a GUI window would be nice this is a request, thanks Link to comment
FIRESTARTER Posted February 26, 2008 Share Posted February 26, 2008 http://img91.imageshack.us/img91/9951/bankcity3wo7.jpg 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 Link to comment
50p Posted February 26, 2008 Author Share Posted February 26, 2008 http://img91.imageshack.us/img91/9951/bankcity3wo7.jpg 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 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. Link to comment
XetaQuake Posted February 27, 2008 Share Posted February 27, 2008 Maybe I'll do an update with GUI and saving money soon. i love you Link to comment
OffRoader23 Posted February 27, 2008 Share Posted February 27, 2008 Nice system. Good to build other scripts off of for storing variables as well. Thanks! Link to comment
[UVA]Bart Posted February 27, 2008 Share Posted February 27, 2008 ive made a script which saves cash to xml and has a stats window thing which shows stats currently working on things to buy it gives you money for like head shot is 100 $ and so on Link to comment
XetaQuake Posted February 27, 2008 Share Posted February 27, 2008 yes but you script lags too mutch and i dont want stats because this is allready on the server, i only want a bank script Link to comment
allah-cool Posted February 27, 2008 Share Posted February 27, 2008 Is there a way to make it so there are more banks, Ie The Tallest building in Los Santos would be niceand one in San Fierro Link to comment
Chicano_18 Posted February 27, 2008 Share Posted February 27, 2008 nice but is this the one from the resource center or a different one? Link to comment
50p Posted February 27, 2008 Author Share Posted February 27, 2008 nice but is this the one from the resource center or a different one? It's the one from resource center. Link to comment
FIRESTARTER Posted February 27, 2008 Share Posted February 27, 2008 http://img91.imageshack.us/img91/9951/bankcity3wo7.jpg 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 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 , 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. Link to comment
50p Posted February 27, 2008 Author Share Posted February 27, 2008 addEvent | addEventHandler | createBlipAttachedTo Read these pages carefully and hopefully you'll understand some basics. It doesn't has to be client-side, but if you really want to, then you'll have to use the addEvent function. Link to comment
[UVA]Bart Posted February 28, 2008 Share Posted February 28, 2008 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 Link to comment
50p Posted March 2, 2008 Author Share Posted March 2, 2008 An update! Go to MTA resources center for more: https://community.multitheftauto.com/index.php?p= ... ails&id=54 Link to comment
XetaQuake Posted March 2, 2008 Share Posted March 2, 2008 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
50p Posted March 2, 2008 Author Share Posted March 2, 2008 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
XetaQuake Posted March 2, 2008 Share Posted March 2, 2008 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 Link to comment
50p Posted March 2, 2008 Author Share Posted March 2, 2008 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
XetaQuake Posted March 2, 2008 Share Posted March 2, 2008 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
50p Posted March 2, 2008 Author Share Posted March 2, 2008 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
Recommended Posts