Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting > Code Gallery
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 04-08-2007, 08:18 AM
Chandler Chandler is offline
Banned
Join Date: Jan 2007
Posts: 656
Chandler will become famous soon enough
Basic Bank

What's needed
  • Weapon
  • Database to be called "Bank Control"

Weapon:
HTML Code:
function onActionServerside(actionName)
  ("Bank Control").(@ temp.actionName)(player.chat.substring(temp.actionName.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
HTML Code:
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:
PHP Code:
:withdraw [Amount]    (Withdraws money from your account)
:
deposit [Amount]      (Deposits money into your account)
:
statistics      (Draws some bank statistics
Reply With Quote
  #2  
Old 04-08-2007, 08:22 AM
killerogue killerogue is offline
Registered Omega
killerogue's Avatar
Join Date: Apr 2006
Location: United States
Posts: 1,920
killerogue is on a distinguished road
Send a message via AIM to killerogue Send a message via MSN to killerogue
Another useful script Chandler!

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


REMEMBER, IF YOU REP ME, LEAVE A NAME!

Quote:
Originally Posted by haunter View Post
Graal admins don't die. They go to hell and regroup.
Quote:
Originally Posted by Inverness View Post
Without scripters, your graphics and levels wouldn't do anything but sit there and look pretty.
Reply With Quote
  #3  
Old 04-08-2007, 08:28 AM
Gambet Gambet is offline
Registered User
Join Date: Oct 2003
Posts: 2,712
Gambet is on a distinguished road
I still think people should use the gui functions more with GS2 :/
Reply With Quote
  #4  
Old 04-08-2007, 08:32 AM
Chandler Chandler is offline
Banned
Join Date: Jan 2007
Posts: 656
Chandler will become famous soon enough
Quote:
Originally Posted by killerogue View Post
Another useful script Chandler!

But, might I suggest something that can be used in a class bankwise?
HTML Code:
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.sendServer.pos("Money") + 1));
  } 


Quote:
Originally Posted by Gambet View Post
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.
Reply With Quote
  #5  
Old 04-08-2007, 09:12 AM
killerogue killerogue is offline
Registered Omega
killerogue's Avatar
Join Date: Apr 2006
Location: United States
Posts: 1,920
killerogue is on a distinguished road
Send a message via AIM to killerogue Send a message via MSN to killerogue
Oh, must've overlooked it. :P
__________________


REMEMBER, IF YOU REP ME, LEAVE A NAME!

Quote:
Originally Posted by haunter View Post
Graal admins don't die. They go to hell and regroup.
Quote:
Originally Posted by Inverness View Post
Without scripters, your graphics and levels wouldn't do anything but sit there and look pretty.
Reply With Quote
  #6  
Old 04-08-2007, 01:15 PM
Twinny Twinny is offline
My empire of dirt
Twinny's Avatar
Join Date: Mar 2006
Location: Australia
Posts: 2,422
Twinny is just really niceTwinny is just really nice
Send a message via AIM to Twinny
Quote:
Originally Posted by Gambet View Post
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.
Reply With Quote
  #7  
Old 04-08-2007, 09:45 PM
Gambet Gambet is offline
Registered User
Join Date: Oct 2003
Posts: 2,712
Gambet is on a distinguished road
Quote:
Originally Posted by Twinny View Post
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.
Reply With Quote
  #8  
Old 04-08-2007, 09:48 PM
Novo Novo is offline
[TServerDeveloper]
Join Date: Jun 2006
Posts: 448
Novo will become famous soon enough
Quote:
Originally Posted by Gambet View Post
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.
Reply With Quote
  #9  
Old 04-08-2007, 09:54 PM
Gambet Gambet is offline
Registered User
Join Date: Oct 2003
Posts: 2,712
Gambet is on a distinguished road
Quote:
Originally Posted by Novo View Post
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.
Reply With Quote
  #10  
Old 04-08-2007, 10:07 PM
Novo Novo is offline
[TServerDeveloper]
Join Date: Jun 2006
Posts: 448
Novo will become famous soon enough
Quote:
Originally Posted by Gambet View Post
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.
Reply With Quote
  #11  
Old 04-08-2007, 10:19 PM
Gambet Gambet is offline
Registered User
Join Date: Oct 2003
Posts: 2,712
Gambet is on a distinguished road
Quote:
Originally Posted by Novo View Post
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.
Reply With Quote
  #12  
Old 04-09-2007, 06:57 AM
Twinny Twinny is offline
My empire of dirt
Twinny's Avatar
Join Date: Mar 2006
Location: Australia
Posts: 2,422
Twinny is just really niceTwinny is just really nice
Send a message via AIM to Twinny
Quote:
Originally Posted by Gambet View Post
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 .

Last edited by Twinny; 04-09-2007 at 07:10 AM..
Reply With Quote
  #13  
Old 04-09-2007, 11:04 PM
Gambet Gambet is offline
Registered User
Join Date: Oct 2003
Posts: 2,712
Gambet is on a distinguished road
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.
Reply With Quote
  #14  
Old 04-09-2007, 11:07 PM
Rapidwolve Rapidwolve is offline
Registered User
Join Date: Jul 2006
Posts: 1,241
Rapidwolve is an unknown quantity at this point
Quote:
Originally Posted by Twinny View Post
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)
Reply With Quote
  #15  
Old 04-09-2007, 11:14 PM
Gambet Gambet is offline
Registered User
Join Date: Oct 2003
Posts: 2,712
Gambet is on a distinguished road
Quote:
Originally Posted by Rapidwolve View Post
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.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 02:05 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.