Graal Forums  

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

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #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
 


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:32 PM.


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