Advertisement
westor

Twitch BET Module for joshymanman v1.0

Jan 24th, 2016
268
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
mIRC 9.71 KB | None | 0 0
  1. ; Modified
  2. ; Adding support for !win <points> and !lose <points>
  3.  
  4. ON !*:TEXT:*:#: {
  5.   tokenize 32 $strip($1-)
  6.   if ($1 == !bet) {
  7.     if (!$check_mod($nick,$chan)) { .msg $chan ( $+ $nick $+ ): Error, You are NOT an channel moderator! | return }
  8.     if (!$2) { .msg $chan ( $+ $nick $+ ): Error, Try again and enter the correct value, more info at !bethelp | return }
  9.     if ($2 == open) || ($2 == start) || ($2 == on) {
  10.       if (%bet) && ($gettok(%bet,2,32) !== $chan) { return }
  11.       if (%bet) { .msg $chan ( $+ $nick $+ ): Error, There is already an BET running try again later or use !bet stop to stop the bet! | return }
  12.       set -e %bet $nick $chan
  13.       .msg $chan ( $+ $nick $+ ): The BET has been started, use now !win <points> or !lose <points> to enter the bet.
  14.     }
  15.     if ($2 == stop) || ($2 == end) || ($2 == off) {
  16.       if (%bet) && ($gettok(%bet,2,32) !== $chan) { return }
  17.       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 }
  18.       unset %bet_win %bet_lose %bet %bet_pause
  19.       .msg $chan ( $+ $nick $+ ): The BET has been stopped.
  20.     }
  21.     if ($2 == resume) {
  22.       if (%bet) && ($gettok(%bet,2,32) !== $chan) { return }
  23.       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 }
  24.       if (!%bet_pause) { .msg $chan ( $+ $nick $+ ): Error, There is NOT any bet paused since now! | return }
  25.       unset %bet_pause
  26.       .msg $chan ( $+ $nick $+ ): The BET has been resumed.
  27.     }
  28.     if ($2 == pause) {
  29.       if (%bet) && ($gettok(%bet,2,32) !== $chan) { return }
  30.       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 }
  31.       if (%bet_pause) { .msg $chan ( $+ $nick $+ ): Error, The BET is already paused! | return }
  32.       set -e %bet_pause $nick
  33.       .msg $chan ( $+ $nick $+ ): The BET has been paused.
  34.     }
  35.     if ($2 == result) || ($2 == results) {
  36.       if (%bet) && ($gettok(%bet,2,32) !== $chan) { return }
  37.       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 }
  38.       if (!$3) { .msg $chan ( $+ $nick $+ ): Error, Try again and enter the result win or lose . | return }
  39.       if ($3 == win) || ($3 == won) {
  40.         if (%bet) && ($gettok(%bet,2,32) !== $chan) { return }
  41.         .msg $chan ( $+ $nick $+ ) The BET has been stopped to win..
  42.         if (!%bet_win) { .msg $chan ( $+ $nick $+ ): There is NOT any user bet at win. }
  43.         elseif (%bet_win) { .msg $chan ( $+ $nick $+ ): The BET nick(s) are %bet_win - (Total: $numtok(%bet_win,44) $+ ) }
  44.         if (%bet_lose) { bet_delpoints $chan %bet_lose }
  45.         if (%bet_win) { bet_addpoints $chan %bet_win }
  46.         unset %bet_win %bet_lose %bet %bet_pause %bet_ [ $+ [ $chan ] $+ ] _*
  47.       }
  48.       if ($3 == lose) || ($3 == lost) {
  49.         if (%bet) && ($gettok(%bet,2,32) !== $chan) { return }
  50.         .msg $chan ( $+ $nick $+ ) The BET has been stopped to lose..
  51.         if (!%bet_lose) { .msg $chan ( $+ $nick $+ ): There is NOT any user bet at lose. }
  52.         elseif (%bet_lose) { .msg $chan ( $+ $nick $+ ): The BET nick(s) are %bet_lose - (Total: $numtok(%bet_lose,44) $+ ) }
  53.         if (%bet_lose) { bet_addpoints $chan %bet_lose }
  54.         if (%bet_win) { bet_delpoints $chan %bet_win }
  55.         unset %bet_win %bet_lose %bet %bet_pause %bet_ [ $+ [ $chan ] $+ ] _*
  56.       }
  57.     }
  58.   }
  59.   if ($1 == !win) {
  60.     if (%bet) && ($gettok(%bet,2,32) !== $chan) { return }
  61.     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 }
  62.     if (!$2) { .msg $chan ( $+ $nick $+ ): Error, Please specify a bet number! | return }
  63.     if ($2 !isnum) { .msg $chan ( $+ $nick $+ ): Error, Please specify only numbers! | return }
  64.     if (%bet_pause) { return }
  65.     var %fix = $chan $+ . $+ $nick
  66.     var %p = $readini(Points.ini,n,%fix,Points)
  67.     var %po = %bet_ [ $+ [ $chan ] $+ ] _ [ $+ [ $nick ] $+ ] _points
  68.     if (!%p) { .msg $chan ( $+ $nick $+ ): Error, You have NOT any points award yet! | return }
  69.     if ($2 > %p) { .msg $chan ( $+ $nick $+ ): Error, Your points are %p so you cannot use a larger number! | return }
  70.     if ($istok(%bet_win,$nick,44)) { .msg $chan ( $+ $nick $+ ): Error, You have already bet at win with %po bet points! | return }
  71.     if ($istok(%bet_lose,$nick,44)) { set -e %bet_lose $remtok(%bet_lose,$nick,1,44) | var %ch = 1 }
  72.     set -e %bet_ [ $+ [ $chan ] $+ ] _ [ $+ [ $nick ] $+ ] _points $2
  73.     set -e %bet_win $addtok(%bet_win,$nick,44)
  74.     .msg $chan ( $+ $nick $+ ): You have $iif(%ch,change your) bet at win with $2 bet points. - Good luck!
  75.   }
  76.   if ($1 == !lose) || ($1 == !lost) {
  77.     if (%bet) && ($gettok(%bet,2,32) !== $chan) { return }
  78.     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 }
  79.     if (!$2) { .msg $chan ( $+ $nick $+ ): Error, Please specify a bet number! | return }
  80.     if ($2 !isnum) { .msg $chan ( $+ $nick $+ ): Error, Please specify only numbers! | return }
  81.     if (%bet_pause) { return }
  82.     var %fix = $chan $+ . $+ $nick
  83.     var %p = $readini(Points.ini,n,%fix,Points)
  84.     var %po = %bet_ [ $+ [ $chan ] $+ ] _ [ $+ [ $nick ] $+ ] _points
  85.     if (!%p) { .msg $chan ( $+ $nick $+ ): Error, You have NOT any points award yet! | return }
  86.     if ($2 > %p) { .msg $chan ( $+ $nick $+ ): Error, Your points are %p so you cannot use a larger number! | return }
  87.     if ($istok(%bet_lose,$nick,44)) { .msg $chan ( $+ $nick $+ ): Error, You have already bet at lose with %po bet points! | return }
  88.     if ($istok(%bet_win,$nick,44)) { set -e %bet_win $remtok(%bet_win,$nick,1,44) | var %ch = 1 }
  89.     set -e %bet_ [ $+ [ $chan ] $+ ] _ [ $+ [ $nick ] $+ ] _points $2
  90.     set -e %bet_lose $addtok(%bet_lose,$nick,44)
  91.     .msg $chan ( $+ $nick $+ ): You have $iif(%ch,change your) bet at lose with $2 bet points. - Good luck!
  92.   }
  93.   if ($1 == !remove) {
  94.     if (%bet) && ($gettok(%bet,2,32) !== $chan) { return }
  95.     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 }
  96.     if (%bet_pause) { return }
  97.     var %po = %bet_ [ $+ [ $chan ] $+ ] _ [ $+ [ $nick ] $+ ] _points
  98.     if ($istok(%bet_lose,$nick,44)) { set -e %bet_lose $remtok(%bet_lose,$nick,1,44) | unset %bet_ [ $+ [ $chan ] $+ ] _ [ $+ [ $nick ] $+ ] _points | .msg $chan ( $+ $nick $+ ): You have been removed from the bet at lose with %po bet points! }
  99.     elseif ($istok(%bet_win,$nick,44)) { set -e %bet_win $remtok(%bet_win,$nick,1,44) | unset %bet_ [ $+ [ $chan ] $+ ] _ [ $+ [ $nick ] $+ ] _points | .msg $chan ( $+ $nick $+ ): You have been removed from the bet at win with %po bet points! }
  100.     else { .msg $chan ( $+ $nick $+ ): Error, You have NOT bet yet! }
  101.   }
  102.   if ($1 == !results) || ($1 == !stats) {
  103.     if (!$check_mod($nick,$chan)) { .msg $chan ( $+ $nick $+ ): Error, You are NOT an channel moderator! | return }
  104.     if (%bet) && ($gettok(%bet,2,32) !== $chan) { return }
  105.     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 }
  106.     if (%bet_pause) { return }
  107.     .msg $chan ( $+ $nick $+ ): Bet(s) at win: $iif(%bet_win,$numtok(%bet_win,44),0)
  108.     .msg $chan ( $+ $nick $+ ): Bet(s) at lose: $iif(%bet_lose,$numtok(%bet_lose,44),0)
  109.     .msg $chan ( $+ $nick $+ ): Total Bet(s): $calc($iif(%bet_win,$numtok(%bet_win,44),0) + $iif(%bet_lose,$numtok(%bet_lose,44),0))
  110.   }
  111.   if ($1 == !mybet) {
  112.     if (%bet) && ($gettok(%bet,2,32) !== $chan) { return }
  113.     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 }
  114.     if (%bet_pause) { return }
  115.     var %po = %bet_ [ $+ [ $chan ] $+ ] _ [ $+ [ $nick ] $+ ] _points
  116.     if ($istok(%bet_lose,$nick,44)) { .msg $chan ( $+ $nick $+ ): You have bet at lose with %po bet points! }
  117.     elseif ($istok(%bet_win,$nick,44)) { .msg $chan ( $+ $nick $+ ): You have bet at win with %po bet points! }
  118.     else { .msg $chan ( $+ $nick $+ ): Error, You have NOT bet yet! }
  119.   }
  120.   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 }
  121. }
  122.  
  123. alias check_mod {
  124.   if (!$1) { return }
  125.   if (!$2) { return }
  126.   if ($me !ison $2) { return 0 }
  127.   if ($1 !ison $2) { return 0 }
  128.   var %f = mods.txt
  129.   if (!$isfile(%f)) { return 0 }
  130.   if (!$lines(%f)) { return 0 }
  131.   var %r = $read(%f,nw,$1)
  132.   if (%r) { return 1 }
  133.   elseif (!%r) { return 0 }
  134. }
  135.  
  136. alias bet_addpoints {
  137.   if (!$1) { return }
  138.   if (!%bet) { return }
  139.   var %c = $1
  140.   var %l = $2
  141.   var %t = $numtok(%l,44)
  142.   var %i = 1
  143.   while (%i <= %t) {
  144.     var %n = $gettok(%l,%i,44)
  145.     var %fix = %c $+ . $+ %n
  146.     var %po = %bet_ [ $+ [ $1 ] $+ ] _ [ $+ [ %n ] $+ ] _points
  147.     var %p = $calc($readini(Points.ini,%fix,Points) + %po)
  148.     if (%n) && (%po) && (%p) { writeini -n $qt(Points.ini) %fix Points %p }
  149.     inc %i
  150.   }
  151. }
  152.  
  153. alias bet_delpoints {
  154.   if (!$1) { return }
  155.   if (!%bet) { return }
  156.   var %c = $1
  157.   var %l = $2
  158.   var %t = $numtok(%l,44)
  159.   var %i = 1
  160.   while (%i <= %t) {
  161.     var %n = $gettok(%l,%i,44)
  162.     var %fix = %c $+ . $+ %n
  163.     var %po = %bet_ [ $+ [ $1 ] $+ ] _ [ $+ [ %n ] $+ ] _points
  164.     var %p = $calc($readini(Points.ini,%fix,Points) - %po)
  165.     if (%n) && (%po) && (%p) { writeini -n $qt(Points.ini) %fix Points %p }
  166.     inc %i
  167.   }
  168. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement