Requested by: VitruxPT
Contact: http://westor.ucoz.com/contact
Description:
This code let you open/stop/pause/resume an bet from your channel and give the bet winners points and those who will bet at the opposite side they will lose points, in order to make this work you must create an 'mods.txt' in the same folder as mirc.exe is and adding one by one your twitch channel moderators to access the module.
Commands:
!BETHelp = This command will give you all the available bet commands.
!BET Start = This command will start an new bet on the channel.
!BET Stop = This command will stop the currently bet from the channel.
!BET Pause = This command will pause the currently bet from the channel.
!BET Resume = This command will resume the currently bet from the channel.
!BET Result WIN/LOSE = This command decide you which side you wanna take the points if you select WIN then all the users that have been added on the win list (using !WIN command) will gonna earn 25 points and all the other users that have been added to LOSE list will be lose 25 points.
!WIN = This command adding you to the WIN list of the active bet.
!LOSE = This command adding you on the LOSE list of the active bet.
!REMOVE = This command will remove your self from any list (WIN or LOSE).
!RESULTS = This command will give you the currently BET results of how many bet on WIN and on LOSE list.
!MYBET = This command will give you your self BET set.
ON !*:TEXT:*:#: {
tokenize 32 $strip($1-,burci)
if ($1 == !bet) {
if (!$check_mod($nick,$chan)) { .msg $chan ( $+ $nick $+ ): Error, You are NOT an channel moderator! | return }
if (!$2) { .msg $chan ( $+ $nick $+ ): Error, Try again and enter the correct value, more info at !bethelp | return }
if ($2 == open) || ($2 == start) || ($2 == on) {
if (%bet) && ($gettok(%bet,2,32) !== $chan) { return }
if (%bet) { .msg $chan ( $+ $nick $+ ): Error, There is already an BET running try again later or use !bet stop to stop the bet! | return }
set -e %bet $nick $chan
.msg $chan ( $+ $nick $+ ): The BET has been started, use now !win or !lose to enter the bet.
}
if ($2 == stop) || ($2 == end) || ($2 == off) {
if (%bet) && ($gettok(%bet,2,32) !== $chan) { return }
if (!%bet) { .msg $chan ( $+ $nick $+ ): Error, There is NOT any BET running try again later or use !bet open to start a new bet! | return }
unset %bet_win %bet_lose %bet %bet_pause
.msg $chan ( $+ $nick $+ ): The BET has been stopped.
}
if ($2 == resume) {
if (%bet) && ($gettok(%bet,2,32) !== $chan) { return }
if (!%bet) { .msg $chan ( $+ $nick $+ ): Error, There is NOT any BET running try again later or use !bet open to start a new bet! | return }
if (!%bet_pause) { .msg $chan ( $+ $nick $+ ): Error, There is NOT any bet paused since now! | return }
unset %bet_pause
.msg $chan ( $+ $nick $+ ): The BET has been resumed.
}
if ($2 == pause) {
if (%bet) && ($gettok(%bet,2,32) !== $chan) { return }
if (!%bet) { .msg $chan ( $+ $nick $+ ): Error, There is NOT any BET running try again later or use !bet open to start a new bet! | return }
if (%bet_pause) { .msg $chan ( $+ $nick $+ ): Error, The BET is already paused! | return }
set -e %bet_pause $nick
.msg $chan ( $+ $nick $+ ): The BET has been paused.
}
if ($2 == result) || ($2 == results) {
if (%bet) && ($gettok(%bet,2,32) !== $chan) { return }
if (!%bet) { .msg $chan ( $+ $nick $+ ): Error, There is NOT any BET running try again later or use !bet open to start a new bet! | return }
if (!$3) { .msg $chan ( $+ $nick $+ ): Error, Try again and enter the result win or lose . | return }
if ($3 == win) || ($3 == won) {
if (%bet) && ($gettok(%bet,2,32) !== $chan) { return }
.msg $chan ( $+ $nick $+ ) The BET has been stopped to win..
if (!%bet_win) { .msg $chan ( $+ $nick $+ ): There is NOT any user bet at win. }
elseif (%bet_win) { .msg $chan ( $+ $nick $+ ): The BET nick(s) are %bet_win - (Total: $numtok(%bet_win,44) $+ ) }
if (%bet_lose) { bet_delpoints $chan %bet_lose }
if (%bet_win) { bet_addpoints $chan %bet_win }
unset %bet_win %bet_lose %bet %bet_pause
}
if ($3 == lose) || ($3 == lost) {
if (%bet) && ($gettok(%bet,2,32) !== $chan) { return }
.msg $chan ( $+ $nick $+ ) The BET has been stopped to lose..
if (!%bet_lose) { .msg $chan ( $+ $nick $+ ): There is NOT any user bet at lose. }
elseif (%bet_lose) { .msg $chan ( $+ $nick $+ ): The BET nick(s) are %bet_lose - (Total: $numtok(%bet_lose,44) $+ ) }
if (%bet_lose) { bet_addpoints $chan %bet_lose }
if (%bet_win) { bet_delpoints $chan %bet_win }
unset %bet_win %bet_lose %bet %bet_pause
}
}
}
if ($1 == !win) {
if (%bet) && ($gettok(%bet,2,32) !== $chan) { return }
if (!%bet) { .msg $chan ( $+ $nick $+ ): Error, There is NOT any BET running try again later or use !bet open to start a new bet! | return }
if (%bet_pause) { return }
var %fix = $chan $+ . $+ $nick
var %p = $readini(Points.ini,n,%fix,Points)
if (!%p) { .msg $chan ( $+ $nick $+ ): Error, You have NOT any points award yet, you must have at least 25 points to enter the bet! | return }
if (%p < 25) { .msg $chan ( $+ $nick $+ ): Error, You have %p points but you must have at least 25 points to enter the bet! | return }
if ($istok(%bet_win,$nick,44)) { .msg $chan ( $+ $nick $+ ): Error, You have already bet at win! | return }
if ($istok(%bet_lose,$nick,44)) { set -e %bet_lose $remtok(%bet_lose,$nick,1,44) | var %ch = 1 }
set -e %bet_win $addtok(%bet_win,$nick,44)
.msg $chan ( $+ $nick $+ ): You $iif(%ch,have change your,have) bet at win. - Good luck!
}
if ($1 == !lose) || ($1 == !lost) {
if (%bet) && ($gettok(%bet,2,32) !== $chan) { return }
if (!%bet) { .msg $chan ( $+ $nick $+ ): Error, There is NOT any BET running try again later or use !bet open to start a new bet! | return }
if (%bet_pause) { return }
var %fix = $chan $+ . $+ $nick
var %p = $readini(Points.ini,n,%fix,Points)
if (!%p) { .msg $chan ( $+ $nick $+ ): Error, You have NOT any points award yet, you must have at least 25 points to enter the bet! | return }
if (%p < 25) { .msg $chan ( $+ $nick $+ ): Error, You have %p points but you must have at lease 25 points to enter the bet! | return }
if ($istok(%bet_lose,$nick,44)) { .msg $chan ( $+ $nick $+ ): Error, You have already bet at lose! | return }
if ($istok(%bet_win,$nick,44)) { set -e %bet_win $remtok(%bet_win,$nick,1,44) | var %ch = 1 }
set -e %bet_lose $addtok(%bet_lose,$nick,44)
.msg $chan ( $+ $nick $+ ): You $iif(%ch,have change your,have) bet at lose. - Good luck!
}
if ($1 == !remove) {
if (%bet) && ($gettok(%bet,2,32) !== $chan) { return }
if (!%bet) { .msg $chan ( $+ $nick $+ ): Error, There is NOT any BET running try again later or use !bet open to start a new bet! | return }
if (%bet_pause) { return }
if ($istok(%bet_lose,$nick,44)) { set -e %bet_lose $remtok(%bet_lose,$nick,1,44) | .msg $chan ( $+ $nick $+ ): You have been removed from the bet at lose! }
elseif ($istok(%bet_win,$nick,44)) { set -e %bet_win $remtok(%bet_win,$nick,1,44) | .msg $chan ( $+ $nick $+ ): You have been removed from the bet at win! }
else { .msg $chan ( $+ $nick $+ ): Error, You have NOT bet yet! }
}
if ($1 == !results) || ($1 == !stats) {
if (!$check_mod($nick,$chan)) { .msg $chan ( $+ $nick $+ ): Error, You are NOT an channel moderator! | return }
if (%bet) && ($gettok(%bet,2,32) !== $chan) { return }
if (!%bet) { .msg $chan ( $+ $nick $+ ): Error, There is NOT any BET running try again later or use !bet open to start a new bet! | return }
if (%bet_pause) { return }
.msg $chan ( $+ $nick $+ ): Bet(s) at win: $iif(%bet_win,$numtok(%bet_win,44),0)
.msg $chan ( $+ $nick $+ ): Bet(s) at lose: $iif(%bet_lose,$numtok(%bet_lose,44),0)
.msg $chan ( $+ $nick $+ ): Total Bet(s): $calc($iif(%bet_win,$numtok(%bet_win,44),0) + $iif(%bet_lose,$numtok(%bet_lose,44),0))
}
if ($1 == !mybet) {
if (%bet) && ($gettok(%bet,2,32) !== $chan) { return }
if (!%bet) { .msg $chan ( $+ $nick $+ ): Error, There is NOT any BET running try again later or use !bet open to start a new bet! | return }
if (%bet_pause) { return }
if ($istok(%bet_lose,$nick,44)) { .msg $chan ( $+ $nick $+ ): You have bet at lose! }
elseif ($istok(%bet_win,$nick,44)) { .msg $chan ( $+ $nick $+ ): You have bet at win! }
else { .msg $chan ( $+ $nick $+ ): Error, You have NOT bet yet! }
}
if ($1 == !bethelp) { .msg $chan ( $+ $nick $+ ): BET Commands are: !Bet open - !Bet stop - !Bet pause - !Bet resume - !Bet result win/lose - !win - !lose - !remove - !results - !mybet }
}
alias check_mod {
if (!$1) { return }
if (!$2) { return }
if ($me !ison $2) { return 0 }
var %f = mods.txt
if (!$isfile(%f)) { return 0 }
if (!$lines(%f)) { return 0 }
var %r = $read(%f,nw,$1)
if (%r) { return 1 }
elseif (!%r) { return 0 }
}
alias bet_addpoints {
if (!$1) { return }
if (!%bet) { return }
var %GIVE_POINTS = 25
var %c = $1
var %l = $2
var %t = $numtok(%l,44)
var %i = 1
while (%i <= %t) {
var %n = $gettok(%l,%i,44)
var %fix = %c $+ . $+ %n
var %p = $calc($readini(Points.ini,%fix,Points) + %give_points)
if (%n) { writeini -n $qt(Points.ini) %fix Points %p }
inc %i
}
}
alias bet_delpoints {
if (!$1) { return }
if (!%bet) { return }
var %TAKE_POINTS = 25
var %c = $1
var %l = $2
var %t = $numtok(%l,44)
var %i = 1
while (%i <= %t) {
var %n = $gettok(%l,%i,44)
var %fix = %c $+ . $+ %n
var %p = $calc($readini(Points.ini,%fix,Points) - %take_points)
if (%n) { writeini -n $qt(Points.ini) %fix Points %p }
inc %i
}
}
notice the if (!$check_mod($network,$nick)) { in the code above. add yourself to mods.txt, it also says how to do this in the description at the top of this page.
alias check_mod {
if (!$1) { return }
if (!$2) { return }
if ($me !ison $2) { return 0 }
if ($1 !ison $2) { return 0 }
var %f = mods.txt
if (!$isfile(%f)) { return 0 }
if (!$lines(%f)) { return 0 }
var %r = $read(%f,nw,$1)
if (%r) { return 1 }
elseif (!%r) { return 0 }
}
Theres a glitch with the results part. If you request !win and put !bet result lose, the person with the !win still gets the points and the people that did !lose end up losing theirs.
Also, would there be a way to make it so they can bet their own custom amount of points "!win 15" (to bet 15 points on winning) instead of only being 25?
Thanks.
@Scootycoolguy Theres a glitch with the results part. If you request !win and put !bet result lose, the person with the !win still gets the points and the people that did !lose end up losing theirs. -> Yes thats suppose the code to do (fixed the description read it again).
change the variables %TAKE_POINTS = 25 and %GIVE_POINTS = 25 to your number.