Graal Forums  

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

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 08-19-2011, 10:35 AM
Gunderak Gunderak is offline
Coder
Gunderak's Avatar
Join Date: Jun 2011
Location: Australia
Posts: 795
Gunderak is on a distinguished road
Lottery NPC

Basically i got the idea from xXAndrewXx.
But i noticed somthing with his script.
The information isn't stored properly, meaning if the npc server were restarted or someone updated the level all the data would disappear.
so i set off to script it from scratch.
here is my problem, i cant figure out how to make serverr.winner be the winner.
here is what i would like it to do, if any player has clientr.Ticket=1 there a potential candidate for the winner flag.
here is my script so far.

PHP Code:
function onCreated(){
  
onUpdateText();
}
function 
onPlayertouchsme(){
  
say2("To Buy A Lottery Ticket Say #b''/Buy Ticket'' It Cost 20 Gralats!#bThe Lottery Is Drawn At Random#bIf You Are Chosen At Random#bYoul Win The Jackpot!");
}
function 
onUpdateText(){
  if(
serverr.jackpot == 0){
    
this.chat "The Current Jackpot Is 0 Gralats.";
    return;
  }
  
this.chat "The Current Jackpot Is "@serverr.jackpot@" Gralats.";
}
function 
onPlayerchats(){
  if(
player.chat == "/Buy Ticket"){
    if(
clientr.Ticket == 1){
      
player.chat "I Have Already Purchased A Ticket!";
      return;
    }
    if(
player.rupees 20){
      
player.chat "I Dont Have Enough Money!";
    }
    if(
player.rupees 19){
      
clientr.Ticket=1;
      
player.chat "I Brought A Lottery Ticket!";
      
player.rupees -= 20;
      
serverr.jackpot += 20;
      
onUpdateText();
    }
  }
  if(
player.chat == "/Draw Lottery"){
    if(
clientr.isStaff){
      
onAwardWinner();
    }
  }
}
function 
onAwardWinner(){
  for (
temp.pl allplayers){
    
findplayer(temp.pl).clientr.Ticket=0;
  }
  echo(
"Lottery: "@serverr.winner@" Has Won The Lottery! They Won: "@serverr.jackpot@" Gralats!");
  
findplayer(serverr.winner).rupees += serverr.jackpot;
  
serverr.jackpot 0;
  
onUpdateText();

__________________

Gund for president.

Remote PM {P*}x (Graal813044) from eraiphone -> Stefan: I hav 1 qustion
*Gunderak: he hav 1
*Gunderak: qustion
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 05:26 AM.


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