on *:start:unset %eggsonline.*
on *:text:!ticket:#: {
var %h = eggs. $+ #,%p $hget(%h,$nick),%w @eggs. $+ #
if ($hget(%h)) {
if (!$window(%w)) .notice $nick Giveaway is not active currently, so you can't buy tickets.
elseif (%p >= 50) {
hadd %h $nick $calc(%p -50)
aline %w $nick
.notice $nick Ticket bought! You now have $iif($fline(%w,$nick,0) == 1,1 ticket,$bytes($v1,b) tickets) and $iif($hget(%h,$nick) == 1,1 egg.,$bytes($v1,b) eggs.)
}
else .notice $nick You need more eggs to buy a ticket! You currently have %p $iif(%p == 1,egg.,eggs.)
}
}
on *:text:!eggs:#: {
var %h = eggs. $+ #,%w @eggs. $+ #
if ($hget(%h)) {
if ($window(%w)) .notice $nick You currently have $iif($hget(%h,$nick) == 1,1 egg,$bytes($v1,b) eggs) and $fline(%w,$nick,0) tickets in the giveaway.
else .notice $nick You currently have $iif($hget(%h,$nick) == 1,1 egg.,$bytes($v1,b) eggs.)
}
}
menu channel {
-
Egg options
.$iif(%eggsonline. [ $+ [ # ] ],Go offline,Go online):$iif(%eggsonline. [ $+ [ # ] ],unset,set) %eggsonline. [ $+ [ # ] ] 1
.-
.$iif($window(@eggs. $+ #),Conclude the giveaway): {
var %w = @eggs. $+ #,%t $line(%w,0)
if (%t > 0) msg # Giveaway is over: the winner is $line(%w,$rand(1,%t)) $+ !
else msg # Giveaway is over: not enough participants.
window -c %w
}
.$iif(!$window(@eggs. $+ #),Start a giveaway): {
window -h @eggs. $+ #
msg # A giveaway has started! You can buy tickets by typing !TICKET for 50 eggs each.
}
.-
.Give everyone eggs: {
var %h = eggs. $+ #
if ($input(How many eggs would you give to the eggheads of # $+ ?,buqe,Eggs,50) > 0) noop $hfind(%h,*,0,w,hinc %h $1 $v1)
}
-
}
on *:join:#: {
var %h = eggs. $+ #
if ($nick == $me) {
hfree -w %h
hmake %h 100
.timereggs. $+ # 1 600 addeggs #
}
elseif ($hget(%h)) && ($hget(%h,$nick) == $null) hadd %h $nick 100
}
on *:part:#:if ($nick == $me) saveeggs #
on *:kick:#:if ($knick == $me) saveeggs #
on *:disconnect: {
var %x = 1
while ($chan(%x)) { saveeggs $v1 | inc %x }
}
alias -l saveeggs {
var %h = eggs. $+ $1
if ($hget(%h)) {
hsave -i %h Eggs.db $1
hfree -w %h
.timereggs. $+ # off
}
}
alias -l addeggs {
var %x = 1,%h eggs. $+ $1,%p $iif(%eggsonline. [ $+ [ $1 ] ],10,2)
if ($hget(%h)) {
while ($nick($1,%x)) { hinc %h $nick($1,%x) %p | inc %x }
hsave -i %h Eggs.db $1
}
}
raw 366:*:checkforneweggs $2
alias -l checkforneweggs {
var %h = eggs. $+ $1,%x 1
if ($hget(%h)) {
while ($nick($1,%x)) { if ($hget(%h,$nick($1,%x)) == $null) hadd %h $nick($1,%x) 100 | inc %x }
hsave -i %h Eggs.db $1
}
}