Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   Code Gallery (https://forums.graalonline.com/forums/forumdisplay.php?f=179)
-   -   Lottery (https://forums.graalonline.com/forums/showthread.php?t=68927)

xAndrewx 09-24-2006 08:19 PM

Lottery
 
HTML Code:

function onCreated()
{
  showcharacter();
  DisplayAmount();

  setTimer(50);
}
function onTimeout()
{
  if (this.drawtime == NULL)
  {
    sendtorc("Drawing the winner of the lottery!");
    findwinner();
    this.drawtime = 10080;
  }
  this.drawtime--;
  setTimer(50);

function onActionGrab()
{
  say2("Hi there! We draw the winning" NL
  "ticket randomly once a week. If" NL
  "you're interested in purchasing a" NL
  "ticket just say 'buy ticket'." NL
  "Tickets cost $20." NL
  "Good luck!");
}

function onPlayerChats()
{
  if (player.chat != "buy ticket")
  {
    return;
  }
  if (player.account in this.PTickets)
  {
    player.chat = "I have already purchased a ticket!";
    return;
  }
  if(player.rupees >= 20)
  {
    PurchaseTicket();
  }
    else
  {
    player.chat = "I don't have enough money to purchase a ticket!";
  }
}
function findwinner()
{
  temp.tokens = this.tickets.tokenize();
  temp.winnernumber = temp.tokens.size();
  temp.winnerpicked = int(random(0, temp.winnernumber));

  this.LWinner = temp.tokens[temp.winnerpicked];
     
  //Add the pay in here, if the player isn't online, add it to their bank account or something.
  //Removed it for public use!

  sendtonc(format(_("Lottery Winner: %s. Amount: %s."), this.LWinner, this.LAmount));
  resetDatabase();
}
function resetDatabase()
{
  this.PTickets = NULL;
  this.LAmount = NULL;

  DisplayAmount();
}
function PurchaseTicket()
{
  if(playertrial)
  {
    player.chat = "(Trials can't participate!)";
    return;
  }
  this.PTickets.add(player.account);
 
  player.rupees -= 20;
  this.LAmount += 20;
  DisplayAmount();
 
  player.chat = "I have purchased a ticket!";
  savelog2("lottery.txt", format(_("%s purchased a ticket!"), player.account));
}
function DisplayAmount()
{
  message(format(_("Jackpot is $%i! Last weeks winner was %s"), this.LAmount, this.LWinner));
}

A lottery system, draws a winning ticket each week.

KuJi 09-28-2006 02:33 AM

Quote:

Originally Posted by xAndrewx (Post 1221647)
[HTML]
A lottery system, draws a winning ticket each week.

if (playertrial) <-- works still? o.O

Darkyoshi12345 09-28-2006 04:21 AM

Is there a GS2 command for playertrial?

xAndrewx 09-28-2006 08:40 AM

player.trial maybe, didn't try it.

xXziroXx 09-28-2006 02:30 PM

I would assume that its still: if (playertrial)


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

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