Usage:
!tatamachance|!lotto|!powerball|!lottery to start the Lottery
Examples: !lotto - Will start a 10 minute long Lottery
!lotto 3600 - Will start a 1 hour or 3600 second lottery
!lotto cancel - Will cancel the Lottery draw
!toplotto - Will display the Top 10 Lottery winners
!toplotto 20 - Will display the Top 20 Lottery winners, etc.
The winner will receive Ops in channel and previous winner will be de-Opped in channel
Feel free to edit accordingly :-)
on *:LOAD: {
$iif($exists($mircdir/Lotto),,mkdir $mircdir/Lotto)
}
on $*:TEXT:/!tatamachance|!lotto|!powerball|!lottery/:#: {
if (%lottolen) && ($2 == cancel) {
timerlotto? off
unset %lotto*
msg $chan The Lottery has been cancelled $nick $+ .
return
}
if (%lotto.fl [ $+ [ $address($nick,2) ] ] >= 2) { return }
if (!%lottolen) {
if ($2 > 86400) || ($2 < 60) { msg $chan Choose a number in range of: 60 - 86400 | return }
$iif(!$2,set %lottolen 600,set %lottolen $2)
}
inc -u $+ [ %lottolen ] %lotto.fl [ $+ [ $address($nick,2) ] ] 1
if (!%lottodraw) {
set %lottochan $chan
set %lottodraw $ctime
.timerlottodraw 1 %lottolen lotto
.timerlottodraw1 1 $calc(%lottolen + 5) unset %lotto*
}
if ($istok(%lotto,$nick,32)) {
msg $chan You are already entered into the lottery $nick $+ .
.timer2 1 1 msg $chan the Lotto Draw will take place in: $duration($timer(lottodraw).secs)
return
}
msg $chan You are entered into the Lottery $nick $+ .
.timer1 1 1 msg $chan the Lotto Draw will take place in: $duration($timer(lottodraw).secs)
%lotto = $addtok(%lotto,$nick,32)
}
alias -l lotto {
var %rand $r(1,$numtok(%lotto,32))
set %prevnick %winnick
set %winnick $gettok(%lotto,%rand,32)
msg %lottochan The Lottery Winner is: %winnick out of $iif($numtok(%lotto,32) == 1,1 entrant.,$numtok(%lotto,32) entrants.) Congratulations!
.timerlottodraw2 1 1 msg %lottochan You have won OP'S !!!
var %file $mircdir\Lotto\Lotto.txt
;by newklear - 2018
if ($read(%file,s,%winnick)) { var %line $readn | var %lwins $gettok($read(%file,%line),2,32) | write -ds $+ %winnick %file | inc %lwins | write %file %winnick %lwins | msg %winnick You have won the Lotto %lwins times. }
else { write %file %winnick 1 }
.timerlottodraw3 1 2 mode %lottochan -o %prevnick
.timerlottodraw4 1 3 mode %lottochan +o %winnick
}
on *:TEXT:!toplotto*:#:{
if (%toplotto. [ $+ [ $address($nick,2) ] ] == 6) { halt }
inc -u3600 %toplotto. [ $+ [ $address($nick,2) ] ] 1
if ($2 > 30) { msg $chan Keep it 30 and below @ $nick | return }
$iif($2,set -u30 %topwhat $2,set -u30 %topwhat 10)
toplotto #
}
alias -l toplotto {
var %file = $mircdir\Lotto\Lotto.txt, %l = %topwhat $+ , %d = $lines(%file), %w = @top10
window -hn %w
clear %w
while %d {
tokenize 32 $read(%file,nt,%d)
aline %w 4 $+ $1 $+ :3 $2 $+ 10
dec %d
}
filter -cuteww 2 32 %w %w
var %k = 1, %k1
while %k <= %l {
%k1 = $addtok(%k1,$+($chr(32),12,$chr(35),%k,) $iif($line(%w,%k),$v1,),44)
inc %k
}
msg $chan 12Top4 %toplotto 12Lotto Winner High Score's:
msg $chan %k1 $+ .
}
Hi Karlien, recopy the entire alias section.
It's now working as it should. My apologies once again, I uploaded this copy without testing, but tested now and it's all fine.
To only allow Ops too start it, add this:
if ($nick isop $chan) {
Under the 1st line of each text event
and add a: }
just before the last }
Hope that makes sense.
Works great, see if I can post some examples of what I did with it.
Other things in the room add to the lotto pot. Like abusing the bot, he'll take credits from you and put some in the lotto pot for the next time its active. You can also do !mylotto to see how many times you've entered and how much in total you've won per month.
!lotinfo
The Room Name Lottery: 50 credits to enter. 25 credits goes in the pot. The more entrants, the bigger the pot! To enter simply type !lotto when a lottery is active.
The winner will get: Pot credits, 1 carrot, 1 lockpick and 1 midget token.
[14:13] !lotcheck
[14:13] Last Winner: (nick here) Pot Won: 150 credits. Plus 1 carrot, 1 lockpick and 1 midget token.
[14:13] The lottery is active! Entrants: 5 Current Pot: 285 credits. The draw will take place in: 3hrs 46mins 35secs. To enter type !lotto
[14:15] !lotto
Bot takes your 50 credits, puts 25 in the pot and puts your name in the crusty hat. Check the lotto status with !lotcheck.
Hello? Mcflies? I am now randomly selecting the lottery winner.
Bot reaches into the crusty hat, pulls out a name...
and the winner is...
(winner nick here) out of (number of people here) entrants. Congratulations!
You have won: (pot credits) credits, 1 carrot, 1 lockpick, 1 midget token and a smile :)
I figured it out :)
In the "alias -l toplotto"
%toplotto needs to be %topwhat
Works like a charm now!