By RusselB on Dec 17, 2009

This is a simple lottery system.
Each player types !add to be added to the lottery.
When the list is full, or no one else wants to be added, an op issues the command !nextround.

Each round pulls 50% of the available players as winners, and those winners become the players for the next round.

on *:start:{
  if !$hget(Lotto) { .hmake Lotto 10 }
on *:text:!add:#:{
  if ($numtok($hget(Lotto,$+($network,.,$chan)),44) <= 10) {
    .hadd -m Lotto $+($network,.,$chan) $addtok($hget(Lotto,$+($network,.,$chan)),$nick,44)
    describe # smiles as $nick starts playing in the lottery
    .msg $chan Current lottery participants are $replace($sorttok($hget(Lotto,$+($network,.,$chan)),44),$chr(44),$+($chr(44),$chr(32)))
  else {
    describe # apologizes to $nick $+ .  Sorry, but the lottery list is full.
  .msg $chan If everyone is done being added, have an op (@) type !nextround to find out who the winners are.
on *:text:!nextround:#:{
  if $nick isop $chan {
    while $numtok($hget(Lotto,$+($network,.,$chan)),44)  > 1 {
      .hinc -m Lotto $+(round.,$network,.,$chan)
      .msg $chan Winners in round $hget(Lotto,$+(round.,$network,.,$chan))) are: $getwinners($chan,$network)
    .hdel Lotto $+(round.,$network,.,$chan)
alias -l getwinners {
  var %a = 1, %b = $int($calc($numtok($hget(Lotto,$+($2,.,$1)),44) / 2))
  while %a <= %b {
    var %winner = $numtok($hget(Lotto,$+($2,.,$1)),44)
    %winner = $r(1,%winner)
    %winner = $gettok($hget(Lotto,$+($2,.,$1)),%winner,44)
    var %winners = $addtok(%winners,%winner,44)
    .hadd -m Lotto $+($2,.,$1) $remtok($hget(Lotto,$+($2,.,$1)),%winner,1,44)
    inc %a
  .hadd -m Lotto $+($2,.,$1) %winners
  return $replace(%winners,$chr(44),$+($chr(44),$chr(32)))
on *:text:!remove:#:{
  describe # sighs as $nick decides to leave the lottery
  msg $chan Current lottery participants are $replace($sorttok($hget(Lotto,$+($network,.,$chan)),44),$chr(44),$+($chr(44),$chr(32)))
  lotto rem $nick
alias -l lotto {
  .hadd -m Lotto $+($network,.,$2) $remtok($hget(Lotto,$+($network,.,$2)),$1,1,44)
  var %winners = $remtok(%winners,$1,1,44)
on *:part:#:  lotto $nick $chan
on *:kick:#:  lotto $knick $chan
on *:quit:{
  var %a = 1, %b = $comchan($nick,0)
  while %a <= %b {
    lotto $nick $comchan($nick,%a)
    inc %a


Sign in to comment.
GuitarMasterx7   -  Jan 20, 2010

i dun think Onzichtbaar lotto script could be used in this

but nice work Russelb i likes it =]

slub77   -  Jan 12, 2010

ok cool

RusselB   -  Jan 11, 2010

Major re-work of this idea and code is in the works. I hope to incorporate most, if not all of the suggestions made here.

slub77   -  Jan 11, 2010

why don't you also throw in rewards etc like if you win it and there are (number here) you get a prize due to the number of people lowring your chanse say 20 people you get op for 5 min

SnoooP   -  Jan 07, 2010

Nice work RusselB =)

Bad_Girl   -  Jan 05, 2010

thanks Russel, now i get it

RusselB   -  Jan 05, 2010

if you are running the code, then someone else has to do !nextround. Additionally, the person that does !nextround must be opped in the channel.

A timer was considered, but I decided to not include it, as a slow or small channel might only get one participant in the one minute time limit you have suggested.

By having it be an actual command, then it can be run when there's a reasonable number of people participating.

Bad_Girl   -  Jan 05, 2010

Why i do !nextround and nothing happens?
why you don't put a timer?
".msg $chan Current lottery participants are..."
you don't need a !nextround, after um minute the game will say ".msg $chan Winners in round $hget(Lotto,$+(round.,$network,.,$chan))) are: $getwinners($chan,$network)....
is only an ideia

RusselB   -  Jan 04, 2010

OK, now that I understand what you're referring to, Jordyboy, I'll see what I can do.
As p0d stated it may end up being a completely different snippet, but if it is, I'll post the address for it here.

p0d   -  Jan 04, 2010

talkin bout havin buy ins and points .. players would never really leave the game until they hit 0

but this game is setup so that the losers from the rounds are exited from the game the winners move on to advance competing against one another until theres only 1 winner.. i dont see how that would work together.

That sounds like whole new monster to play with good idea though.

I still like this version of the game good job nice use of hash

Jordyboy   -  Jan 04, 2010

so like when they win they can be on say, a high score list or something e.g

<+LOTBOT[OO]> NAME bought a lot for $100, and didn't win the jackpot, the jackpot now contains $6,884. NAME has now got $10,653 And is ranked 4318th out of 6578.

see the And is ranked 4318th out of 6578. something like that?

and say if someone type !rank 4318 it would say Rank 4318: NAME

RusselB   -  Jan 04, 2010

I agree with Master-Of-Death, Jordyboy. You need to explain what you mean by a ranking system, as, in the long run, only one nick is the final winner.

Master-Of-Death   -  Jan 04, 2010

huh a ranking system?

Jordyboy   -  Jan 04, 2010

Add a ranking system as well then i will use :)

Master-Of-Death   -  Dec 18, 2009

nice 10/10 gd job as always

Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.