The following 2 codes are for a Lottery Game I made to work in conjunction with trivia. One code is for Nightchillz Trivia and the other is for Hybrid Trivia. The game will add trivia points for winning. Its not easy to win but I believe like any lottery its possible. The winner should get alot of points if the pot is ever won.
The following Lottery Code will ONLY work with Nightchillz Trivia.
on *:JOIN:#: {
 if ($nick != $me) {
  ctcpreply $nick TIME Type !lotto To See The Available Commands For Lottery
 }
}
on ^*:TEXT:*:#: {
 if ($1 === !lotto) && ($nick != $me) {
  hmake Lottery 100
  hadd -m Lottery Chan $chan
  ctcpreply $nick TIME To Play Lottery Type:
!lottery To Begin The Game$&
   â€©!pot To See How Large The Pot Is$&
   â€©!quickpick If You Want The Computer To Pick Your Ticket$&
   â€©!regular And 6 Numbers To Set Your Own Ticket$&
   â€©Your Numbers Need To Be From 1-8, 9-18, 19-27, 28-36, 37-45, And 46-54
  ctcpreply $nick TIME Type:
!drawing For The Computer Drawing Of The Lottery Numbers$&
   â€©!winner If You Have The Winning Numbers. If No One Has The Winning Numbers The Point Pot Grows Until The Next Drawing$&
   â€©!nowinner If No One Has The Winning Numbers
 }
 if ($1 === !lottery) {
  if $hget(Lottery,Chan) == $null) { msg $chan You Need To Type !lotto Before Typing !lottery }
  hadd Lottery Pot %lotterypot
  msg $hget(Lottery,Chan) Lets Play The Lottery For Extra Trivia Points. There Is Currently $hget(Lottery,Pot) Points In The Pot
 }
 if ($1 === !quickpick) {
  hadd -m Lottery Ticket $+ $nick $r(1,9), $r(10,18), $r(19,27), $r(28,36), $r(37,45), $r(46,54)
  hinc -m Lottery Pot 50
  trivia.credit $nick -5
  ctcpreply $nick TIME Your Lucky Lottery Numbers Are $hget(Lottery,Ticket $+ $nick)
 }
 if ($1 === !regular) {
  if ($hget(Lottery,Numbers) != $null) halt
  hadd -m Lottery Ticket $+ $nick $2 $3 $4 $5 $6 $7
  hinc -m Lottery Pot 50
  trivia.credit $nick -5
  ctcpreply $nick TIME Your Lucky Lottery Numbers Are $hget(Lottery,Ticket $+ $nick)
 }
 if ($1 === !drawing) {
  hadd -m Lottery Numbers $r(1,9), $r(10,18), $r(19,27), $r(28,36), $r(37,45), $r(46,54)
  msg $hget(Lottery,Chan) $hget(Lottery,Numbers)
 }
 if ($1 === !winner) {
  hadd Lottery Winner $nick
  msg $hget(Lottery,Chan) Hold Your Tickets While We Check To Verify The Winning Numbers
  if ($correctnrs == 3) $three
  if ($correctnrs == 4) $four
  if ($correctnrs == 5) $five
  if ($correctnrs == 6) $winmessage
  if ($correctnrs <= 2) $losemessage
  set %lotterypot $hget(Lottery,Pot)
 }
 if ($1 == !nowinner) {
  msg $hget(Lottery,Chan) There Was No Winner This Drawing. The Pot Is Being Saved For The Next Drawing.
  set %lotterypot $hget(Lottery,Pot)
  hdel Lottery Winner $nick
  hfree Lottery
 }
 if ($1 == !pot) {
  msg $chan The Pot Is Currently Worth %lotterypot Points
 }
}
alias winmessage {
 msg $hget(Lottery,Chan) $hget(Lottery,Winner) Is The WINNER And Won %lotterypot Points. For Winning The Lottery $me has made $hget(Lottery,Winner) an owner.
 trivia.credit $hget(Lottery,Winner) $hget(Lottery,Pot)
 unset %lotterypot
 hdel Lottery Winner $nick
 hfree Lottery
}
alias losemessage {
 msg $hget(Lottery,Chan) Sorry $hget(Lottery,Winner) Didnt Have The Right Numbers.
 hdel Lottery Winner $nick
 hfree Lottery
}
alias three {
 msg $hget(Lottery,Chan) $hget(Lottery,Winner) Was The Winner And Won $calc(%lotterypot / 10) Points
 trivia.credit $nick $calc(%lotterypot / 10)
}
alias four {
 msg $hget(Lottery,Chan) $hget(Lottery,Winner) Was The Winner And Won $calc(%lotterypot / 5) Points
 trivia.credit $hget(Lottery,Winner) $calc(%lotterypot / 5)
}
alias five {
 msg $hget(Lottery,Chan) $hget(Lottery,Winner) Was The Winner And Won $calc(%lotterypot / 2) Points
 trivia.credit $hget(Lottery,Winner) $calc(%lotterypot / 2)
}
alias correctnrs {
 var %i = 6, %tot
 while (%i > 0) {
  if ($gettok($hget(Lottery,Ticket $+ $nick),%i,32) == $gettok($hget(Lottery,Numbers),%i,32)) inc %tot
  dec %i
 }
 return %tot
}
The following code will ONLY work with Hybrid Trivia.
on *:JOIN:#: {
 if ($nick != $me) {
  ctcpreply $nick TIME Type !lotto To See The Available Commands For Lottery
 }
}
on ^*:TEXT:*:#: {
 if ($1 === !lotto) && ($nick != $me) {
  hmake Lottery 100
  hadd -m Lottery Chan $chan
  ctcpreply $nick TIME To Play Lottery Type:
!lottery To Begin The Game$&
   â€©!pot To See How Large The Pot Is$&
   â€©!quickpick If You Want The Computer To Pick Your Ticket$&
   â€©!regular And 6 Numbers To Set Your Own Ticket$&
   â€©Your Numbers Need To Be From 1-8, 9-18, 19-27, 28-36, 37-45, And 46-54
  ctcpreply $nick TIME Type:
!drawing For The Computer Drawing Of The Lottery Numbers$&
   â€©!winner If You Have The Winning Numbers. If No One Has The Winning Numbers The Point Pot Grows Until The Next Drawing$&
   â€©!nowinner If No One Has The Winning Numbers
 }
 if ($1 === !lottery) {
  if $hget(Lottery,Chan) == $null) { msg $chan You Need To Type !lotto Before Typing !lottery }
  hadd Lottery Pot %lotterypot
  msg $hget(Lottery,Chan) Lets Play The Lottery For Extra Trivia Points. There Is Currently $hget(Lottery,Pot) Points In The Pot
 }
 if ($1 === !quickpick) {
  hadd -m Lottery Ticket $+ $nick $r(1,9), $r(10,18), $r(19,27), $r(28,36), $r(37,45), $r(46,54)
  hinc -m Lottery Pot 50
  inc % [ $+ player. $+ [ $nick ] ] -5
  ctcpreply $nick TIME Your Lucky Lottery Numbers Are $hget(Lottery,Ticket $+ $nick)
 }
 if ($1 === !regular) {
  if ($hget(Lottery,Numbers) != $null) halt
  hadd -m Lottery Ticket $+ $nick $2 $3 $4 $5 $6 $7
  hinc -m Lottery Pot 50
  inc % [ $+ player. $+ [ $nick ] ] -5
  ctcpreply $nick TIME Your Lucky Lottery Numbers Are $hget(Lottery,Ticket $+ $nick)
 }
 if ($1 === !drawing) {
  hadd -m Lottery Numbers $r(1,9), $r(10,18), $r(19,27), $r(28,36), $r(37,45), $r(46,54)
  msg $hget(Lottery,Chan) $hget(Lottery,Numbers)
 }
 if ($1 === !winner) {
  hadd Lottery Winner $nick
  msg $hget(Lottery,Chan) Hold Your Tickets While We Check To Verify The Winning Numbers
  if ($correctnrs == 3) $three
  if ($correctnrs == 4) $four
  if ($correctnrs == 5) $five
  if ($correctnrs == 6) $winmessage
  if ($correctnrs <= 2) $losemessage
  set %lotterypot $hget(Lottery,Pot)
 }
 if ($1 == !nowinner) {
  msg $hget(Lottery,Chan) There Was No Winner This Drawing. The Pot Is Being Saved For The Next Drawing.
  set %lotterypot $hget(Lottery,Pot)
  hdel Lottery Winner $nick
  hfree Lottery
 }
 if ($1 == !pot) {
  msg $chan The Pot Is Currently Worth %lotterypot Points
 }
}
alias winmessage {
 msg $hget(Lottery,Chan) $hget(Lottery,Winner) Is The WINNER And Won %lotterypot Points. For Winning The Lottery $me has made $hget(Lottery,Winner) an owner.
 inc % [ $+ player. $+ [ $hget(Lottery,Winner) ] ] $hget(Lottery,Pot)
 unset %lotterypot
 hdel Lottery Winner $nick
 hfree Lottery
}
alias losemessage {
 msg $hget(Lottery,Chan) Sorry $hget(Lottery,Winner) Didnt Have The Right Numbers.
 hdel Lottery Winner $nick
 hfree Lottery
}
alias three {
 msg $hget(Lottery,Chan) $hget(Lottery,Winner) Was The Winner And Won $calc(%lotterypot / 10) Points
 inc % [ $+ player. $+ [ $hget(Lottery,Winner) ] ] $calc(%lotterypot / 10)
}
alias four {
 msg $hget(Lottery,Chan) $hget(Lottery,Winner) Was The Winner And Won $calc(%lotterypot / 5) Points
 inc % [ $+ player. $+ [ $hget(Lottery,Winner) ] ] $calc(%lotterypot / 5)
}
alias five {
 msg $hget(Lottery,Chan) $hget(Lottery,Winner) Was The Winner And Won $calc(%lotterypot / 2) Points
 inc % [ $+ player. $+ [ $hget(Lottery,Winner) ] ] $calc(%lotterypot / 2)
}
alias correctnrs {
 var %i = 6, %tot
 while (%i > 0) {
  if ($gettok($hget(Lottery,Ticket $+ $nick),%i,32) == $gettok($hget(Lottery,Numbers),%i,32)) inc %tot
  dec %i
 }
 return %tot
}
Edited for small error in the way numbers were assigned. Added method of subtracting 5 trivia points for "buying" a ticket. Changed the messages to the channel to ctcpreplies instead. Added an award system to award a chatter a percentage of trivia points based on how many numbers they have correct. 6 numbers still awards the entire pot like before. This game should be alot easier to win now than before. Many thanks to Petertje for supplying the correctnrs alias.
Edited Jul 11, 2005 7:34 PM by Mail