alias -l bet {
noop $regex($3,/^!((?:new|won)?bet)/)
var %r $regml(1)
if $istok(newbet wonbet,%r,32) && $2 !isop $1 && !%bet. [ $+ [ %r ] ] {
set -u60 %bet. [ $+ [ %r ] ] 1
msg $1 $+(!,%r) is OP command.
return
}
if %r == newbet {
if %bet.q { .notice $2 Bet was already opened and not closed yet. | return }
if !$4 || $numtok($4-,58) != 3 { .notice $2 command: !newbet <question> : <option1>,<option2>,<option3>,<etc> : <point> | return }
var %p $remove($gettok($4-,3,58),$chr(32))
if %p !isnum || %p < 1 { .notice $2 <point> was set incorrectly | return }
set -e %bet.q $gettok($4-,1,58)
noop $regex($gettok($4-,2,58),/(\S.+$)/iS)
var %re /((:?\s+)?,(:?\s+)?)/giS
set -e %bet.a $regsubex($regml(1),%re,$chr(44))
set -e %bet.p %p
msg $1 [BET OPENED] Question: %bet.q :: Option: %bet.a :: Bet Point: %bet.p - Use: !bet <option> to set your bet.
.timerbet.warn 1 90 msg $1 [BET] Bet will be closed in 30secs.
.timerbet.close 1 120 set -e %bet.closed 1 | msg $1 [BET] Bet is closed.
}
if %r == bet && !%bet.closed {
if !%bet.q && !%bet.bet {
set -u60 %bet.bet 1
msg $1 [BET] There is no BET yet.
return
}
if $readini(casino.ini,$2,Money) < %bet.p {
if !$istok(%bet.point,$2,32) {
.notice $2 You dont have enough point to bet. Point required to bet is $+(<,%bet.p,>)
set -e %bet.point $addtok(%bet.point,$2,32)
}
return
}
if $wildtok(%bet.user,$+($2,*),1,215) {
if !$istok(%bet.twice,$2,32) {
.notice $2 You can't bet twice!
set -e %bet.twice $addtok(%bet.twice,$2,32)
}
return
}
if !$4 {
if !$istok(%bet.warned,$2,32) || $2 isop $1 {
.notice $2 [BET] %bet.q : %bet.a - Use: !bet <option> to set your bet.
set -e %bet.warned $addtok(%bet.warned,$2,32)
}
return
}
if !$istok(%bet.a,$4-,44) {
if !$istok(%bet.invalid,$2,32) {
.notice $2 Valid options are: %bet.a
set -e %bet.invalid $addtok(%bet.invalid,$2,32)
}
return
}
set -e %bet.user $addtok(%bet.user,$2 $4-,215)
msg $1 $+($2,'s) bet is $4-
}
if %r == wonbet {
if !%bet.q { .notice $2 There is no open BET yet. | return }
if !$4 { .notice $2 command: !wonbet <option> | return }
if !$istok(%bet.a,$4-,44) { .notice $2 Valid options are: %bet.a | return }
var %i 1
while $gettok(%bet.user,%i,215) {
var %w $v1, %n $gettok(%w,1,32), %add 0
if $+(*,$4-) iswm %w && %n ison $1 { var %win %win %n, %add 1 }
if $+(*,$4-) !iswm %w { var %add -1 }
writeini -n casino.ini %n Money $calc($readini(casino.ini,%n,Money) + (%bet.p * %add))
inc %i
}
msg $1 [BET RESULT] $+(<,$4-,>) was the winning option! $iif(%win,Winners are: %win - good luck for all others on the next bet!,There is no winner!)
unset %bet.*
.timerbet.* off
}
}