PDA

View Full Version : Basic Bank


Chandler
04-08-2007, 09:18 AM
What's needed

Weapon
Database to be called "Bank Control"


Weapon:

function onActionServerside(actionName)
("Bank Control").(@ temp.actionName)(player.chat.substring(temp.action Name.pos("Money") + 1));

//#CLIENTSIDE
function onPlayerChats()
if (player.chat.starts(":deposit"))
triggerserver("weapon", this.name, "depositMoney");
else
if (player.chat.starts(":withdraw"))
triggerserver("weapon", this.name, "withdrawMoney");
else
if (player.chat.starts(":statistics"))
triggerserver("weapon", this.name, "bankStatistics");


Bank Control

public function withdrawMoney(moneyAmount)
{
temp.moneyAmount = int(temp.moneyAmount);
if (temp.moneyAmount > 0)
if (temp.moneyAmount <= this.("bankAccount_" @ player.account))
{
this.("bankAccount_" @ player.account) -= temp.moneyAmount;
player.rupees += temp.moneyAmount;
player.chat = format(_("You've taken %d from your bank account! (%d)"),
temp.moneyAmount, this.("bankAccount_" @ player.account));
}
else
player.chat = "You don't have that much money!";
}
public function depositMoney(moneyAmount)
{
temp.moneyAmount = int(temp.moneyAmount);
if (temp.moneyAmount > 0)
if (temp.moneyAmount <= player.rupees)
{
this.("bankAccount_" @ player.account) += temp.moneyAmount;
player.rupees -= temp.moneyAmount;
player.chat = format(_("You've put %d inside of your bank account! (%d)"),
temp.moneyAmount, this.("bankAccount_" @ player.account));
}
else
player.chat = "You don't have that much money!";
}
public function bankStatistics()
{
for (temp.currentAccount: getstringkeys("this.bankAccount_"))
if (this.("bankAccount_" @ temp.currentAccount) > temp.richestPlayer[1])
temp.richestPlayer = {temp.currentAccount, this.("bankAccount_" @ temp.currentAccount)};
player.chat = format(_("%s is the richest player with %d gralats!"),
temp.richestPlayer[0], temp.richestPlayer[1]);
}


Commands:

:withdraw [Amount] (Withdraws money from your account)
:deposit [Amount] (Deposits money into your account)
:statistics (Draws some bank statistics)

killerogue
04-08-2007, 09:22 AM
Another useful script Chandler! :D

But, might I suggest something that can be used in a class bankwise?

Gambet
04-08-2007, 09:28 AM
I still think people should use the gui functions more with GS2 :/

Chandler
04-08-2007, 09:32 AM
Another useful script Chandler! :D

But, might I suggest something that can be used in a class bankwise?


function onPlayerChats()
{
temp.actionNames = {"deposit", "withdraw", "statistics"};
temp.realNames = {"depositMoney", "withdrawMoney", "bankStatistics"};
for (temp.currentAction: temp.actionNames)
if (player.chat.starts(":"@ temp.currentAction))
temp.sendServer = temp.realNames[temp.actionNames.index(temp.currentAction)];
if (temp.sendServer)
("Bank Control").(@ temp.sendServer)(player.chat.substring(temp.sendSe rver.pos("Money") + 1));
}

:)

I still think people should use the gui functions more with GS2 :/
I'd rather not. Hence the word "Basic" being in this thread name.

killerogue
04-08-2007, 10:12 AM
Oh, must've overlooked it. :P

Twinny
04-08-2007, 02:15 PM
I still think people should use the gui functions more with GS2 :/

GUI's take way too long to use compared to chat commands. I'd much rather enter the level and say /withdraw 1200 rather then going through a load of guis.

Gambet
04-08-2007, 10:45 PM
GUI's take way too long to use compared to chat commands. I'd much rather enter the level and say /withdraw 1200 rather then going through a load of guis.


Depends on whether you want a professional feel to it or not.


Unless your server is classic-style, I think you should encourage GUI-usage. ESPECIALLY if it's an RPG-style server.

Novo
04-08-2007, 10:48 PM
Depends on whether you want a professional feel to it or not.


Unless your server is classic-style, I think you should encourage GUI-usage. ESPECIALLY if it's an RPG-style server.

And if the script is for the serverside component -- for the grand public. Making a GUI may not be the best thing to do: It is made for a wide amount of servers. In such case, it should allow the server to customize what they wish via GUI.

Gambet
04-08-2007, 10:54 PM
And if the script is for the serverside component -- for the grand public. Making a GUI may not be the best thing to do: It is made for a wide amount of servers. In such case, it should allow the server to customize what they wish via GUI.



This bank system was built on the basis of chat commands, not on the basis of a GUI, though it can be altered, but that's irrelevant.


Chat commands are nice, but they're another way of taking the lazy way out of things, since GUIs take a lot longer than simple chat commands. If what you're looking for is a chat based bank system, then great -- so as long as it fits your servers general style at least.

Novo
04-08-2007, 11:07 PM
This bank system was built on the basis of chat commands, not on the basis of a GUI, though it can be altered, but that's irrelevant.

Actually, the system in essence isn't chat-based. The NPCW presented here is a way of demonstrating how such commands may potentially be accessed. The system, as such, remains untouched no matter whether the user-interface changes.

Gambet
04-08-2007, 11:19 PM
Actually, the system in essence isn't chat-based. The NPCW presented here is a way of demonstrating how such commands may potentially be accessed. The system, as such, remains untouched no matter whether the user-interface changes.



It very well is chat based, considering all of the actions are chat-related. The player chats to trigger an action and the player's chat is set to receive an action.


As stated before, it can be altered, yes, but that's irrelevant to how it is in its present stage. Yes, you can pick apart the essentials and create it into a GUI system, but that's not what was presented.


It's a nice system regardless.

Twinny
04-09-2007, 07:57 AM
It very well is chat based, considering all of the actions are chat-related. The player chats to trigger an action and the player's chat is set to receive an action.


Gambet...notice how most of the serverside code has public functions relying on input? This isn't completely chat-based: the chat is an example on how to use it. You should read into it a bit more. Rapid's is easily modifiable.

The great thing about modular design is that you can easily change what you do with output. My example would be the difference between an ogre based town and a human based town when you have insufficient funds to withdraw ^^.

P.S. efficiency > flashy effects ^^.

Gambet
04-10-2007, 12:04 AM
The graphic itself has nothing to do with efficiency, more like luxury. Being able to change the GUI itself in different towns and so forth also has nothing to do with efficiency and wouldn't fit every server.

Rapidwolve
04-10-2007, 12:07 AM
Gambet...notice how most of the serverside code has public functions relying on input? This isn't completely chat-based: the chat is an example on how to use it. You should read into it a bit more. Rapid's is easily modifiable.

The great thing about modular design is that you can easily change what you do with output. My example would be the difference between an ogre based town and a human based town when you have insufficient funds to withdraw ^^.

P.S. efficiency > flashy effects ^^.

Just leave him alone, I don't he will ever understand modular scripts and how people can modify and make it their own (even into GUI's if they wish)

Gambet
04-10-2007, 12:14 AM
Just leave him alone, I don't he will ever understand modular scripts and how people can modify and make it their own (even into GUI's if they wish)


That doesn't say anything, and if you try to prove me wrong you'll look as much of a fool as I would if I said so.


We could argue about this all night because it can go both ways. Usually when you release content to the public, it's so they would be able to use it with minimal, if any, changes needed. Of course, you can release whatever you'd like, but if the whole point is to release content for public use, then it would be best to leave them with very little things to alter.


If I make a system GUI Based and you make it chat based, then it is what it is. This system is chat based, though you can pick apart the core and change it around if you want. Yes, I understand that, and I already acknowledged this. That still does not change this from a chat based system. You could do the same with a GUI Based system, thus why we can argue about this all night.


I'm not here for anyone to give their input on what they think I know, I was simply stating an opinion and then we had these smart cats that think their Jesus and they have the authority to shoot down one's opinions.


It's simply my opinion, stop trying to tell me I'm wrong when it can go either way. We don't need to argue about this anymore, for it shouldn't have even started in the first place. I gave my input that I think people should use GUI's more if it fits the server's general theme. It's a valid opinion and it's my own opinion. Of course some people will disagree, that's how things work with opinions.