![]() |
Bank System
Bank system I made using dbnpc.
DBNPC Script (Name is BankDB): PHP Code:
PHP Code:
PHP Code:
|
Slightly different approach to how I would do it, but good none the less.
|
Quote:
|
So I can't spell for peanuts. Does this really matter? No? Good :) .
|
Quote:
Good though :) |
Ok: How would you two do it?
|
Personally, I'd merge the Create account and Deposit into one. If the string inside the database doesn't exist, I'd then instantly create the bank account. I wouldn't use so many public functions, remember that they're public. I'd also convert your playerchats.
|
Clientside -> Trigger to Server -> Use ChatBar -> Ftw =O?
|
Quote:
PHP Code:
I also have a DB NPC for storing the bank data, i.e. PHP Code:
Then, instead of having to pass the account name, I can just use the this. object to access the player so that you can just do this to deposit 30g: PHP Code:
|
Hmm.. my atms a bit diff =o.
acc_123456=KuJi,PASSWORD,BALANCE I should probally MD5 the password, maybe I will redo the ATM sometime soon.. is kinda old. Anyway, when you use your ATM Card it has the ATM # in it automatically... so yeah. |
Quote:
That's a pretty good idea Skyld. May edit the code with a more user friendly version later ^^. I'm still pretty sucky at scripting but anything that seems half decent to me i'll share in the hope of receiving advice :) |
Skyld's idea is good :]
|
you people inspire me.
|
To do what? ^^
|
Update!
Bank System v 1.1 After receving advice from Skyld I have made a improved bank system using classes. DBNPC named BankDB PHP Code:
PHP Code:
PHP Code:
PHP Code:
May add a GUI script to use the Bank system next. |
You're using return quite alot, but you're not really giving reason why? Explain why you've used
'return "w/e";' as some people may not get it. |
Return tells whatever script accessed the commands the results of those commands. Eg. A NPC tries to withdraw 501 when you only have 500. It will receive "nem" and display the error message appropriately.
This in turn allows for customisation. Eg. a human banker may be polite about this while a rock troll banker will proceed to club you to death for not having enough money. |
Quote:
|
I know how it works, but you didn't seem to use any return error feature in your script. That's why I asked you about it :)
|
Well - the error feature basically is the 'nem' for instance. The script checks the return. If it is 'nem' then it displays it's own custom error message. What error feature would you be expecting? =o
[Edit]: For those who don't know to use RC commands simply type /npc <command> into RC. eg. /npc interest. If your account matches the test i've added then it will do the command. |
Quote:
|
I use return on almost every function. I'm used to programming in OO languages and I learned OO in Eiffel where "deign by contract" is a major philosopy. Basically means making sure the function can go ahead with the data it's been given (preconditions) and then making sure it's completed successfully (postconditions) the only real way to implement this in GS is return codes on functions. (Check my associative array class for example)
In GS it's best to use numbers imho for the following reasons: 1) You can use if (function()) {} for functions that return 1 or 0. 2) You can use if (function() > 3) {} and make error checks in a sensible order. E.g. in this case the first 3 errors are acceptable. 3) Comparing strings is more CPU intensive than comparing integers. |
Quote:
|
If i post a gui bank client - it will make use of the new returns.
|
That's an If :p
I'm only questioning it, because you've used it yet not explained how it works. Other than that, cool :) |
man i rock you all at scripting
nice bank system, + rep |
Woo thanks Gerami <3. Good to be acknowledged by the master >_<
|
| All times are GMT +2. The time now is 03:40 AM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.