Thread: Basic Bank
View Single Post
  #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