Thread: Lottery NPC
View Single Post
  #17  
Old 08-21-2011, 05:14 AM
0PiX0 0PiX0 is offline
Coder
0PiX0's Avatar
Join Date: Jan 2011
Posts: 130
0PiX0 is a jewel in the rough0PiX0 is a jewel in the rough
Quote:
PHP Code:
if(player.rupees 19){
player.chat "I Brought A Lottery Ticket!";
Lottery.addAccount(player.account);
player.rupees -= 20;
server.jackpot += 20;
onUpdateText();

You probably should check if the player has already gotten a ticket before removing their rupees, or increase his/her chances by removing:
Quote:
PHP Code:
if (inLottery(acct)) {
    
// Already in lottery
    
return false;
  } 
Also, I believe there is a rediculously slight chance that
Quote:
PHP Code:
public function pickLotteryWinner() {
  return 
this.lottery[int(random(0this.lottery.size()))];

will return null in the case that the random function returned the maximum possibility. However, I might be wrong about that. I'm not sure.
Perhaps try something like this to ensure that does not happen, although this does very slightly affect the odds...
PHP Code:
return this.lottery[int(random(0this.lottery.size()-0.01))]; 
Reply With Quote