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: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
  #4  
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
  #5  
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
  #6  
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
  #7  
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
  #8  
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
  #9  
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
  #10  
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
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 01:16 PM.


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