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 09-24-2006, 08:19 PM
xAndrewx xAndrewx is offline
Registered User
xAndrewx's Avatar
Join Date: Sep 2004
Posts: 5,260
xAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud of
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.
__________________
Reply With Quote
  #2  
Old 09-28-2006, 02:33 AM
KuJi KuJi is offline
Banned
Join Date: Apr 2004
Location: Staten Island, New York
Posts: 2,202
KuJi will become famous soon enough
Send a message via ICQ to KuJi Send a message via AIM to KuJi Send a message via MSN to KuJi Send a message via Yahoo to KuJi
Quote:
Originally Posted by xAndrewx View Post
[HTML]
A lottery system, draws a winning ticket each week.
if (playertrial) <-- works still? o.O
Reply With Quote
  #3  
Old 09-28-2006, 04:21 AM
Darkyoshi12345 Darkyoshi12345 is offline
Darky
Join Date: Jun 2006
Posts: 153
Darkyoshi12345 is on a distinguished road
Is there a GS2 command for playertrial?
Reply With Quote
  #4  
Old 09-28-2006, 08:40 AM
xAndrewx xAndrewx is offline
Registered User
xAndrewx's Avatar
Join Date: Sep 2004
Posts: 5,260
xAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud of
player.trial maybe, didn't try it.
__________________
Reply With Quote
  #5  
Old 09-28-2006, 02:30 PM
xXziroXx xXziroXx is offline
Malorian
xXziroXx's Avatar
Join Date: May 2004
Posts: 5,289
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
I would assume that its still: if (playertrial)
__________________
Follow my work on social media post-Graal:Updated august 2025.
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 12:23 AM.


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