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
}
}
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.
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
Cumps
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
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