All pastes #152234 Raw Edit

MIRC UNO

public text v1 · immutable
#152234 ·published 2006-08-28 17:27 UTC
rendered paste body
/* This section contains the help contents for IRC Uno Commands.
!Uno - Use this command in an active Uno channel to start a game of IRC Uno.
Join - Use this command to join a game after someone has typed !Uno
!Deal - If you started a game with !Uno you will be informed to use this command to deal the cards after 1-9 other players join.
!Play - Use !Play <color> <card> to play standard cards, 0-9, Reverse, Skip, DrawTwo. Use !Play W <color> to play a wild and !Play WD4 to play a wild draw for. (Colors, numbers and words are accepted values. Red, r, five, 5, d2, drawtwo, etc.. are all accepted values.)
!Draw - Use this if none of your cards play to draw a card off of the top of the deck.
!Pass - If enabled use this to pass if your drawn card cannot play.
!UnoTop10 <Option> - Type this to see the top 10 players. Options: Average, Games, Points
!Score - Type !Score to see your score, type !Score <Nick> to see someone else's score.
!TopCard - Missed which card was on top? This command will reshow it.
!ShowCards - Missed your cards? This command will let you look again.
!UnoStop - Stops Uno, Ops and the player who started the game are allowed to stop it.
!Quit - Tired of the game? !Quit will remove you.
!Players - Who's playing Uno? Type !Players to find out.
!Rank - If enabled this command will tell you how you rank.
!Count - Tells you how many cards each player has.
*/
;----------------------------------------------------------------------
on *:load: {
  echo -a 0,1---=) 4Loaded 11{15IRC-Uno11} 9by 11{15Lost.Lion@gmail.com11} 0(=---
  if (!$exists(" $+ $scriptdir $+ Uno.txt $+ ")) {
    echo -a 0,1" $+ $scriptdir $+ Uno.txt $+ " not found, creating now.
    write -l1 " $+ $scriptdir $+ Uno.txt $+ " !PlayerList!
    write -l2 " $+ $scriptdir $+ Uno.txt $+ " !Options!.1.0.1.0.0.0.1.0.0
    write -l3 " $+ $scriptdir $+ Uno.txt $+ " !Channels!,#Uno
    write -l4 " $+ $scriptdir $+ Uno.txt $+ " 0
    if (!$exists(" $+ $scriptdir $+ Uno.txt $+ ")) {
      echo -a 0,1" $+ $scriptdir $+ Uno.txt $+ " was not sucessfully created, please make sure $scriptdir is not write-protected and reload Uno.mrc.
      halt
    }
    else {
      echo -a 0,1" $+ $scriptdir $+ Uno.txt $+ " was sucessfully created.
    }
  }
  echo -a 0,1Right click in any Channel or type 4/UnoOptions0 for options.
  unoreset
}
;----------------------------------------------------------------------
on *:text:deal:%iuno.c2: {
  if ($network == %iuno.np) {
    if (%iuno.dl != 1) {
      if ($nick == %iuno.fp) {
        if ($numtok(%iuno.u,46) >= 2) {
          var %iuno.s 1
          while (%iuno.s <= 7) {
            var %iuno.v 2
            while (%iuno.v <= $numtok(%iuno.u,46)) {
              set %iuno.h. $+ $gettok(%iuno.u,%iuno.v,46) $instok(%iuno.h. [ $+ [ $gettok(%iuno.u,%iuno.v,46) ] ] ,$gettok(%iuno.d,1,46),-0,46)
              set %iuno.d $deltok(%iuno.d,1,46)
              inc %iuno.v
            }
            set %iuno.h. $+ %iuno.fp $instok(%iuno.h. [ $+ [ %iuno.fp ] ] ,$gettok(%iuno.d,1,46),-0,46)
            set %iuno.d $deltok(%iuno.d,1,46)
            inc %iuno.s
          }
          set %iuno.dl 1
          while ($pos($gettok(%iuno.d,1,46),w,0)) {
            set %iuno.d $instok(%iuno.d,$gettok(%iuno.d,1,46),$rand(1,$numtok(%iuno.d,46)),46)
            set %iuno.d $deltok(%iuno.d,1,46)
          }
          set %iuno.dp $instok(%iuno.dp,$gettok(%iuno.d,1,46),1,46)
          set %iuno.d $deltok(%iuno.d,1,46)
          set %iuno.u $instok(%iuno.u,$gettok(%iuno.u,1,46),-0,46)
          set %iuno.u $deltok(%iuno.u,1,46)
          if ($pos($gettok(%iuno.dp,1,46),S,1)) {
            skip $network $gettok(%iuno.u,1,46)
          }
          elseif ($pos($gettok(%iuno.dp,1,46),D2,1)) {
            drawtwo $network $gettok(%iuno.u,1,46)
          }
          elseif ($pos($gettok(%iuno.dp,1,46),R,1)) {
            reverse $network $nick
          }
          else {
            showtopcard $network $chan
            unomsg $network $chan $gettok(%iuno.u,1,46) $+ 's turn.
           unocards $network $gettok(%iuno.u,1,46)
          }
        }
        else {
          unomsg $network $chan Sorry but you need 2 people to play.
        }
      }
      else {
        unomsg $network $chan Sorry but %iuno.fp needs to deal.
      }
    }
    else {
      unomsg $network $chan Uno has already been delt.
    }
  }
}
;----------------------------------------------------------------------
on *:text:join:%iuno.c2: {
  if ($network == %iuno.np) {
    if ($numtok(%iuno.u,46) < 10) {
      if (%iuno.dl != 1) {
        set %iuno.u $addtok(%iuno.u,$nick,46)
        unomsg $network $chan $nick is Uno player $chr(35) $+ $findtok(%iuno.u,$nick,1,46)
        unomsg3 $network %iuno.fp There are now $numtok(%iuno.u,46) players for Uno, type deal in %iuno.c2 to start the game.
      }
      else {
        set %iuno.u $addtok(%iuno.u,$nick,46)
        unomsg $network $chan Dealing $nick into current Uno game.
        var %iuno.jt 1
        while (%iuno.jt <= 7) {
          if (!$numtok(%iuno.d,46)) {
            set %iuno.ud %iuno.dp
            unset %iuno.dp
            set %iuno.dp $gettok(%iuno.ud,1,46)
            set %iuno.ud $deltok(%iuno.ud,1,46)
            unomsg $network $chan Shuffling discard pile
            newunodeck x
          }
          set %iuno.h. $+ $nick $instok( %iuno.h. [ $+ [ $nick ] ] ,$gettok(%iuno.d,1,46),-0,46)
          set %iuno.d $deltok(%iuno.d,1,46)
          inc %iuno.jt
        }
       unocards $network $nick
      }
    }
    else {
      unomsg $network $chan Sorry $nick but 10 users are already playing.
    }
  }
}
;----------------------------------------------------------------------
on *:text:!unostop:%iuno.c2: {
  if ($network == %iuno.np) {
    if ($nick == %iuno.fp || $nick isop %iuno.c2) {
      unomsg $network $chan $nick has stopped IRC-Uno: Type !Uno to begin anew.
      unoreset
    }
    else {
      unomsg $network $chan Only %iuno.fp may stop the current game, type !quit to leave the game.
    }
  }
}
;----------------------------------------------------------------------
on *:text:!uno:%iuno.c: {
  if ($chanvalid($chan,$network))  {
    set %iuno.color $gettok($read(" $+ $scriptdir $+ Uno.txt $+ ",2),2,46)
    set %iuno.rank $gettok($read(" $+ $scriptdir $+ Uno.txt $+ ",2),3,46)
    set %iuno.draw $gettok($read(" $+ $scriptdir $+ Uno.txt $+ ",2),4,46)
    set %iuno.comm $gettok($read(" $+ $scriptdir $+ Uno.txt $+ ",2),5,46)
    set %iuno.c $gettok($read(" $+ $scriptdir $+ Uno.txt $+ ",3),2-,44)
    unocolors
    if (!%iuno.fp) {
      set %iuno.fp $nick
      set %iuno.c2 $chan
      set %iuno.np $network
      set %iuno.abv m.b.g.m.y.s.d2.d2.r.0.1.2.3.4.5.6.7.8.9
      set %iuno.words r.Blue.Green.Red.Yellow.Skip.Draw2.DrawTwo.Reverse.Zero.One.Two.Three.Four.Five.Six.Seven.Eight.Nine
      newunodeck
      set %iuno.u $addtok(%iuno.u,$nick,46)
      unomsg $network $chan IRC-Uno Started: Type join to join in.
    }
    else {
      unomsg3 $network %iuno.fp An Uno game has already been started in %iuno.c2 $+ .
    }
    unset %iuno.t.u
  }
}
;----------------------------------------------------------------------
on *:text:play W*D* *:%iuno.c2: {
  if ($network == %iuno.np) {
    if (($2 == WD4) || ($2 == WildDrawFour) || ($2 == WildDraw4)) {
      if (!$findtok(%iuno.abv,$3,46)) set %iuno.pv $gettok(%iuno.abv,$findtok(%iuno.words,$3,46),46)
      elseif ($3 == r) set %iuno.pv m
      else set %iuno.pv $3
      if ($nick == $gettok(%iuno.u,1,46)) {
        if ($pos(%iuno.h. [ $+ [ $nick ] ],zWD4,1)) {
          if ((%iuno.udc != 1) || ((%iuno.udc == 1) && ($pos($gettok(%iuno.h. [ $+ [ $nick ] ],$numtok(%iuno.h. [ $+ [ $nick ] ],46),46),zWD4,1)))) {
            if (%iuno.pv == b || %iuno.pv ==  g || %iuno.pv ==  m || %iuno.pv ==  y ) {
              set %iuno.dp $instok(%iuno.dp,[ %iuno.pv ] $+ $chr(42),1,46)
              set %iuno.h. [ $+ [ $nick ] ] $remtok(%iuno.h. [ $+ [ $nick ] ],zWD4,1,46)
              if ($numtok(%iuno.h. [ $+ [ $nick ] ],46) == 1) unomsg $network $chan  $+ %iuno.cr $+ U $+ %iuno.cy $+ n $+ %iuno.cb $+ o $+ %iuno.cg $+ !  $+ %iuno.fc $+ $nick has one card left!
              set %iuno.u $instok(%iuno.u,$gettok(%iuno.u,1,46),-0,46)
              set %iuno.u $deltok(%iuno.u,1,46)
              if (%iuno.pv == b) set %iuno.pv Blue.
              if (%iuno.pv == g) set %iuno.pv Green.
              if (%iuno.pv == m) set %iuno.pv Red.
              if (%iuno.pv == y) set %iuno.pv Yellow.
              if (%iuno.udc) unset %iuno.udc
              var %iuno.d4 1
              while (%iuno.d4 <= 4) {
                if (!$numtok(%iuno.d,46)) {
                  set %iuno.ud %iuno.dp
                  unset %iuno.dp
                  set %iuno.dp $gettok(%iuno.ud,1,46)
                  set %iuno.ud $deltok(%iuno.ud,1,46)
                  unomsg $network $chan Shuffling discard pile
                  newunodeck x
                }
                set [ %iuno.h. [ $+ [ $gettok(%iuno.u,1,46) ] ] ] $instok(%iuno.h. [ $+ [ $gettok(%iuno.u,1,46) ] ],$gettok(%iuno.d,1,46),-0,46)
                set %iuno.d $deltok(%iuno.d,1,46)
                inc %iuno.d4
              }
              unset %iuno.d4
              unomsg $network $chan $gettok(%iuno.u,1,46) draws 4 cards and is skipped!
              drawncards $network $gettok(%iuno.u,1,46) 4
              set %iuno.u $instok(%iuno.u,$gettok(%iuno.u,1,46),-0,46)
              set %iuno.u $deltok(%iuno.u,1,46)
              if (!$numtok(%iuno.h. [ $+ [ $nick ] ],46)) {
                score $network $nick
              }
              else {
                unomsg $network $chan $gettok(%iuno.u,1,46) $+ 's turn.
                showtopcard $network $chan
                unocards $network $gettok(%iuno.u,1,46)
              }
            }
            else {
              unomsg $network $chan Please specify a color $nick $+ . play WD4 [b,g,r,y]
            }
          }
          else {
            unomsg $network $chan Sorry $nick but you must play the card you've drawn or !Pass.
          }
        }
        else {
          unomsg $network $chan You don't have that card $nick $+ .
        }
      }
    }
  }
}
;----------------------------------------------------------------------
on *:text:play W*:%iuno.c2: {
  if ($network == %iuno.np) {
    if (!$findtok(%iuno.abv,$3,46)) set %iuno.pv $gettok(%iuno.abv,$findtok(%iuno.words,$3,46),46)
    elseif ($3 == r) set %iuno.pv m
    else set %iuno.pv $3
    if ($nick == $gettok(%iuno.u,1,46)) {
      if ($poscs(%iuno.h. [ $+ [ $nick ] ],ZW,1)) {
        if ((%iuno.udc != 1) || ((%iuno.udc == 1) && ($poscs($gettok(%iuno.h. [ $+ [ $nick ] ],$numtok(%iuno.h. [ $+ [ $nick ] ],46),46),ZW,1)))) {
          if (%iuno.pv == b || %iuno.pv == g || %iuno.pv == m || %iuno.pv == y ) {
            set %iuno.dp $instok(%iuno.dp,[ %iuno.pv ] $+ $chr(42),1,46)
            set %iuno.h. [ $+ [ $nick ] ] $remtok(%iuno.h. [ $+ [ $nick ] ],ZW,1,46)
            if ($numtok(%iuno.h. [ $+ [ $nick ] ],46) == 1) unomsg $network $chan  $+ %iuno.cr $+ U $+ %iuno.cy $+ n $+ %iuno.cb $+ o $+ %iuno.cg $+ !  $+ %iuno.fc $+ $nick has one card left!
            if (!$numtok(%iuno.h. [ $+ [ $nick ] ],46)) {
              score $network $nick
            }
            else {
              set %iuno.u $instok(%iuno.u,$gettok(%iuno.u,1,46),-0,46)
              set %iuno.u $deltok(%iuno.u,1,46)
              if (%iuno.udc) unset %iuno.udc
              if (%iuno.pv == b) set %iuno.pv Blue.
              if (%iuno.pv == g) set %iuno.pv Green.
              if (%iuno.pv == m) set %iuno.pv Red.
              if (%iuno.pv == y) set %iuno.pv Yellow.
              unomsg $network $chan $nick changed the color to %iuno.pv $gettok(%iuno.u,1,46) $+ 's turn.
              showtopcard $network $chan
             unocards $network $gettok(%iuno.u,1,46)
            }
          }
          else {
            unomsg $network $chan Please specify a color $nick $+ . play W [b,g,r,y]
          }
        }
        else {
          unomsg $network $chan Sorry $nick but you must play the card you've drawn or !Pass.
        }
      }
      else {
        unomsg $network $chan You don't have that card $nick $+ .
      }
    }
  }
}
;----------------------------------------------------------------------
on *:text:play *:%iuno.c2: {
  if ($network == %iuno.np) {
    if (!$findtok(%iuno.abv,$2,46)) set %iuno.pv $gettok(%iuno.abv,$findtok(%iuno.words,$2,46),46)
    elseif ($2 == r) set %iuno.pv m
    else set %iuno.pv $2
    if (!$findtok(%iuno.abv,$3,46)) set %iuno.px $gettok(%iuno.abv,$findtok(%iuno.words,$3,46),46)
    else set %iuno.px $3
    set %iuno.pvx %iuno.pv $+ %iuno.px
    if ($nick == $gettok(%iuno.u,1,46)) {
      if ($findtok(%iuno.h. [ $+ [ $nick ] ],%iuno.pvx,0,46)) {
        if (($pos($gettok(%iuno.dp,1,46),[ %iuno.pv ],1)) || (($pos($gettok(%iuno.dp,1,46),[ %iuno.px ],1)) && ($iif($pos($gettok(%iuno.dp,1,46),D2,1),$iif($pos(%iuno.pvx,D2,1),$true,$false),$true)))) {
          if ((%iuno.udc != 1) || ((%iuno.udc == 1) && ($pos($gettok(%iuno.h. [ $+ [ $nick ] ],$numtok(%iuno.h. [ $+ [ $nick ] ],46),46),%iuno.pvx,1)))) {
            set %iuno.dp $instok(%iuno.dp,$upper(%iuno.pvx),1,46)
            set %iuno.h. [ $+ [ $nick ] ] $remtok(%iuno.h. [ $+ [ $nick ] ],%iuno.pvx,1,46)
            if ($numtok(%iuno.h. [ $+ [ $nick ] ],46) == 1) unomsg $network $chan  $+ %iuno.cr $+ U $+ %iuno.cy $+ n $+ %iuno.cb $+ o $+ %iuno.cg $+ !  $+ %iuno.fc $+ $nick has one card left!
            set %iuno.u $instok(%iuno.u,$gettok(%iuno.u,1,46),-0,46)
            set %iuno.u $deltok(%iuno.u,1,46)
            if ($numtok(%iuno.h. [ $+ [ $nick ] ],46)) {
              if ($pos($gettok(%iuno.dp,1,46),S,1)) {
                skip $network $gettok(%iuno.u,1,46)
              }
              elseif ($pos($gettok(%iuno.dp,1,46),D2,1)) {
                drawtwo $network $gettok(%iuno.u,1,46)
              }
              elseif ($pos($gettok(%iuno.dp,1,46),R,1)) {
                reverse $network $nick
              }
              else {
                unomsg $network $chan $gettok(%iuno.u,1,46) $+ 's turn.
                showtopcard $network $chan
                unocards $network $gettok(%iuno.u,1,46)
              }
            }
            else {
              score $network $nick
            }
            if (!$numtok(%iuno.h. [ $+ [ $nick ] ],46)) {
              score $network $nick
            }
            if (%iuno.udc) unset %iuno.udc
          }
          else {
            unomsg $network $chan Sorry $nick but you must play the card you've drawn or !Pass.
          }
        }
        else {
          unomsg $network $chan Sorry but that card doesn't play $nick $+ .
        }
      }
      else {
        unomsg $network $chan You don't have that card $nick $+ .
      }
    }
  }
}
;----------------------------------------------------------------------
on *:text:draw:%iuno.c2: {
  if ($network == %iuno.np) {
    if ($nick == $gettok(%iuno.u,1,46)) {
      if (%iuno.udc != 1) {
        if (!$numtok(%iuno.d,46)) {
          set %iuno.ud %iuno.dp
          unset %iuno.dp
          set %iuno.dp $gettok(%iuno.ud,1,46)
          set %iuno.ud $deltok(%iuno.ud,1,46)
          unomsg $network $chan Shuffling discard pile
          newunodeck x
        }
        set %iuno.h. $+ $nick $instok( %iuno.h. [ $+ [ $nick ] ] ,$gettok(%iuno.d,1,46),-0,46)
        set %iuno.d $deltok(%iuno.d,1,46)
        if (%iuno.draw == 1) set %iuno.udc 1
        drawncards $network $gettok(%iuno.u,1,46) 1
        unomsg $network $chan $nick draws a card.
      }
      else {
        unomsg $network $chan $nick you must play the card you drew or !Pass
      }
    }
  }
}
;----------------------------------------------------------------------
on *:text:!TopCard:%iuno.c2: {
  if ($network == %iuno.np) showtopcard $network $chan
}
;----------------------------------------------------------------------
on *:text:pass:%iuno.c2: {
  if ($network == %iuno.np) {
    if ($nick == $gettok(%iuno.u,1,46)) {
      if (%iuno.draw == 1) {
        if (%iuno.udc == 1) {
          set %iuno.u $instok(%iuno.u,$gettok(%iuno.u,1,46),-0,46)
          set %iuno.u $deltok(%iuno.u,1,46)
          unomsg $network $chan $nick passes, $gettok(%iuno.u,1,46) $+ 's turn.
          showtopcard $network $chan
          unocards $network $gettok(%iuno.u,1,46)
         unset %iuno.udc
        }
        else {
          unomsg $network $chan $nick you must draw before you can pass.
        }
      }
      else {
        unomsg $network $chan $nick you must draw until you can play.
      }
    }
  }
}
;----------------------------------------------------------------------
on *:text:!UnoTop10*:%iuno.c: {
  if ($chanvalid($chan,$network))  {
    if (%iuno.tt == 1) {
      if ($2 == Points) filter -ffac " $+ $scriptdir $+ Uno.txt $+ " " $+ $scriptdir $+ UnoTop.txt $+ " unofilter2 */*
      elseif ($2 == Games) filter -ffac " $+ $scriptdir $+ Uno.txt $+ " " $+ $scriptdir $+ UnoTop.txt $+ " unofilter3 */*
      else filter -ffac " $+ $scriptdir $+ Uno.txt $+ " " $+ $scriptdir $+ UnoTop.txt $+ " unofilter */*
      unomsg3 $network $nick  $+ %iuno.fc $+ , $+ %iuno.bc $+ Uno Top 10 for $iif($2 == Points,Total Points,$iif($2 == Games,Games Played,Average Points Per Game $chr(40) $+ Points/Games $+ $chr(41))) is:
      set %iuno.ptv.n $network
      write -il1 " $+ $scriptdir $+ UnoTop.txt $+ " [Top10]
      write -il12 " $+ $scriptdir $+ UnoTop.txt $+ " [EndTop10]
      play -aq5m1tTop10 unomsg3 $nick " $+ $scriptdir $+ UnoTop.txt $+ " 1000
      write -dl1 " $+ $scriptdir $+ UnoTop.txt $+ "
      write -dl12 " $+ $scriptdir $+ UnoTop.txt $+ "
    }
    else {
      unomsg3 $network $nick Sorry but !UnoTop10 is disabled.
    }
  }
}
;----------------------------------------------------------------------
on *:text:!Rank:%iuno.c: {
  if ($chanvalid($chan,$network))  {
    if (%iuno.rank == 1) {
      filter -ffac " $+ $scriptdir $+ Uno.txt $+ " " $+ $scriptdir $+ UnoTop.txt $+ " unofilter2 */*
      if ($read(" $+ $scriptdir $+ UnoTop.txt $+ ", nw, $nick *)) {
        set %iuno.r.t $read(" $+ $scriptdir $+ UnoTop.txt $+ ", nw, $nick *)
        set %iuno.r.p $readn
        filter -ffac " $+ $scriptdir $+ Uno.txt $+ " " $+ $scriptdir $+ UnoTop.txt $+ " unofilter3 */*
        set %iuno.r.t $read(" $+ $scriptdir $+ UnoTop.txt $+ ", nw, $nick *)
        set %iuno.r.g $readn
        filter -ffac " $+ $scriptdir $+ Uno.txt $+ " " $+ $scriptdir $+ UnoTop.txt $+ " unofilter */*
        set %iuno.r.t $read(" $+ $scriptdir $+ UnoTop.txt $+ ", nw, $nick *)
        set %iuno.r.a $readn
        unomsg3 $network $nick Your IRC Uno Rankings: %iuno.r.a / %iuno.r.p / %iuno.r.g
        unomsg3 $network $nick (Points per Game / Total Points / Total Games)
      }
      else {
        unomsg3 $network $nick Sorry but you are currently unranked, play Uno to get into the rankings!
      }
    }
    else {
      unomsg3 $network $nick Sorry but individual ranks are disabled.
    }
  }
}
;----------------------------------------------------------------------
on *:text:!score:%iuno.c: {
  if ($chanvalid($chan,$network))  {
    if (%iuno.sco == 1) {
      if ($read(" $+ $scriptdir $+ Uno.txt $+ ",s,$nick)) unomsg3 $network $nick You have $gettok($read(" $+ $scriptdir $+ Uno.txt $+ ",s,$nick),1,47) total points and $gettok($read(" $+ $scriptdir $+ Uno.txt $+ ",s,$nick),2,47) games played.
      else unomsg3 $network $nick No score saved.
    }
    else {
      unomsg3 $network $nick !Score has been disabled.
    }
  }
}
;----------------------------------------------------------------------
on *:text:!score *:%iuno.c: {
  if ($chanvalid($chan,$network))  {
    if (%iuno.scon == 1) {
      if ($read(" $+ $scriptdir $+ Uno.txt $+ ",s,$2)) unomsg3 $network $nick $2 has $gettok($read(" $+ $scriptdir $+ Uno.txt $+ ",s,$2),1,47) total points and $gettok($read(" $+ $scriptdir $+ Uno.txt $+ ",s,$2),2,47) games played.
      else unomsg3 $network $nick No score saved for $2
    }
    else {
      unomsg3 $network $nick !Score <Nick> has been disabled.
    }
  }
}
;----------------------------------------------------------------------
on *:text:!showcards:%iuno.c2: {
  if ($network == %iuno.np) unocards $network $nick
}
;----------------------------------------------------------------------
on *:text:!quit:%iuno.c2: {
  if (($findtok(%iuno.u,$nick,46)) && ($network == %iuno.np)) runoplayer $network $nick
}
;----------------------------------------------------------------------
on *:text:players:%iuno.c2: {
  if ($network == %iuno.np) {
    unomsg3 $network $nick  $+ %iuno.fc $+ , $+ %iuno.bc $+ Current Uno Players are:
    unomsg3 $network $nick  $+ %iuno.fc $+ , $+ %iuno.bc $+ $replace(%iuno.u,.,$chr(32))
  }
}
;----------------------------------------------------------------------
on *:text:!Commands:%iuno.c: {
  if ($chanvalid($chan,$network))  {
    set %iuno.cmnd !Uno, Join, !Deal, !Play <color> <card>, !Play [W/WD4] <color>, !Draw, !Pass, !UnoTop10, !Score, !Score <nick>, !TopCard, !ShowCards, !UnoStop, !Quit, !Players, !Rank, !Count
    unomsg3 $network $nick  $+ %iuno.fc $+ , $+ %iuno.bc $+ Commands for IRC Uno are: %iuno.cmnd
    unomsg3 $network $nick  $+ %iuno.fc $+ , $+ %iuno.bc $+ Type !Help <Command> for more information on a command.
    unset %iuno.cmnd
  }
}
;----------------------------------------------------------------------
on *:text:!Help*:%iuno.c: {
  if ($chanvalid($chan,$network))  {
    set %iuno.cmnd !Uno.Join.!Deal.!Play.!Draw.!Pass.!UnoTop10.!Score.!TopCard.!ShowCards.!UnoStop.!Quit.!Players.!Rank.!Count
    if (!$findtok(%iuno.cmnd,$2,1,46)) {
      unomsg3 $network $nick  $+ %iuno.fc $+ , $+ %iuno.bc $+ Sorry but I cannot find any help for that command.
    }
    else {
      set %iuno.line $findtok(%iuno.cmnd,$2,1,46) + 1
      unomsg3 $network $nick  $+ %iuno.fc $+ , $+ %iuno.bc $+ $Read(" $+ $scriptdir $+ Uno.mrc $+ ", %iuno.line)
      unset %iuno.line
    }
    unset %iuno.cmnd
  }
}
;----------------------------------------------------------------------
on *:text:Count:%iuno.c2: {
  set %iuno.cnt.tmp 1
  set %iuno.cnt.rp Card Count:
  while (%iuno.cnt.tmp <= $numtok(%iuno.u,46)) {
    set %iuno.cnt.rp %iuno.cnt.rp $+ $chr(32) $+ $gettok(%iuno.u,%iuno.cnt.tmp,46) $numtok(%iuno.h. [ $+ [ $gettok(%iuno.u,%iuno.cnt.tmp,46) ] ],46) :
    inc %iuno.cnt.tmp
  }
  unomsg3 $network $nick %iuno.cnt.rp
  unset %iuno.cnt.*
}
;----------------------------------------------------------------------
on *:KICK:%iuno.c: {
  if (($findtok(%iuno.u,$knick,46)) && ($network == %iuno.np)) runoplayer $network $knick
}
;----------------------------------------------------------------------
on *:NICK: {
  if ($network == %iuno.np)  {
    if ($findtok(%iuno.u,$nick,1,46)) {
      set %iuno.u $reptok(%iuno.u,$nick,$newnick,1,46)
      if ($nick == %iuno.fp) {
        set %iuno.fp $newnick
      }
      set %iuno.h. [ $+ [ $newnick ] ] %iuno.h. [ $+ [ $nick ] ]
      unset %iuno.h. [ $+ [ $nick ] ]
    }
  }
}
;----------------------------------------------------------------------
on *:PART:%iuno.c2: {
  if (($findtok(%iuno.u,$nick,46)) && ($network == %iuno.np)) runoplayer $network $nick
}
;----------------------------------------------------------------------
on *:QUIT: {
  if (($findtok(%iuno.u,$nick,46)) && ($network == %iuno.np)) runoplayer $network $nick
}
;----------------------------------------------------------------------
alias chanvalid {
  if (%iuno.mn == 0) return $true
  elseif ((%iuno.mn == 1) && ($findtok(%iuno.c. [ $+ [ $2 ] ],$1,1,46))) return $true
  else return $false
}
;----------------------------------------------------------------------
alias score {
  unomsg $1 %iuno.c2 We have a winner! Go $2
  set %iuno.u $deltok(%iuno.u,$findtok(%iuno.u,$2,1,46),46)
  var %iuno.sc 1
  var %iuno.cs $numtok(%iuno.u,46)
  while (%iuno.sc <= %iuno.cs) {
    addplayerscoreb $gettok(%iuno.u,%iuno.sc,46)
    inc %iuno.sc
  }
  addplayerscore $2
  unomsg $1 %iuno.c2 $2 gains %iuno.t.u points. For a total of %iuno.t.k points, and a total of $gettok($read(" $+ $scriptdir $+ Uno.txt $+ ",s,$2),2,47) games played.
  unoreset
}
;----------------------------------------------------------------------
alias unocid {
  if ($isid) {
    var %e = return $+($chr(3),$color(info),$!unocid: Error -)
    if ($version < 6.0) %e multi-server capability was only added in version 6.0
    if (!$len($1)) %e you must specify a network, server, or wildcarded string as first parameter.
    if (!$regex($ticks,$2,/^-?\d+-?(?:-\d+)?$/)) %e second param should either be a number or a range.
    var %n = $iif($3 isnum 1-15,$3,1), %params = $1 $iif($3 !isnum,$3)
    set -u %result
    scon -at $+ %n unocid % $+ params
    return $gettok(%result,$2,32)
  }
  if ($1 iswm $server) || ($istok($server $network,$1,32)) {
    if ($2) && ($me !ison $2) return
    set -u %result %result $cid
  }
}
;----------------------------------------------------------------------
alias unomsg {
  if ($unocid($1,1,$2)) {
    scid $ifmatch
    msg $2  $+ %iuno.fc $+ , $+ %iuno.bc $+ $3-
    scid -r
  }
}
;----------------------------------------------------------------------
alias unomsg2 {
  if ($unocid($1,1,$2)) {
    scid $ifmatch
    msg $2  $+ %iuno.fc $+ , $+ %iuno.bc $+ $3-
    scid -r
  }
}
;----------------------------------------------------------------------
alias unomsg3 {
  if ($play($1).status) {
    set %iuno.um3n %iuno.ptv.n
    set %iuno.um3c $1
    set %iuno.um3m $2-
  }
  else {
    set %iuno.um3n $1
    set %iuno.um3c $2
    set %iuno.um3m $3-
  }
  if ($unocid(%iuno.um3n,1,%iuno.c2)) {
    scid $ifmatch
    if (%iuno.comm == 0) notice %iuno.um3c  $+ %iuno.fc $+ , $+ %iuno.bc $+ $iif($play(%iuno.um3c).status,$chr(35) $+ $play(%iuno.um3c).pos $+ $chr(32)) $+ %iuno.um3m
    if (%iuno.comm == 1) msg %iuno.um3c  $+ %iuno.fc $+ , $+ %iuno.bc $+ $iif($play(%iuno.um3c).status,$chr(35) $+ $play(%iuno.um3c).pos $+ $chr(32)) $+ %iuno.um3m
    scid -r
  }
}
;----------------------------------------------------------------------
alias runoplayer {
  if ($2 == %iuno.fp) {
    set %iuno.u $deltok(%iuno.u,$findtok(%iuno.u,$2,46),46)
    if ($numtok(%iuno.u,46) <= 1) {
      if ($numtok(%iuno.u,46) != 0) {
        addplayerscoreb $2
        addplayerscore $gettok(%iuno.u,1,46)
        unomsg $1 %iuno.c2 $gettok(%iuno.u,1,46) gains %iuno.t.u points. For a total of %iuno.t.k points, and a total of $gettok($read(" $+ $scriptdir $+ Uno.txt $+ ",s,$gettok(%iuno.u,1,46)),2,47) games played.
        unoreset
      }
      else {
        unomsg $1 %iuno.c2 No one is playing Uno t.t Type !Uno to begin anew.
        unoreset
      }
    }
    else {
      set %iuno.fp $gettok(%iuno.u,1,46)
      unomsg $1 %iuno.c2 $2 was removed from the current Uno game.
      unomsg $1 %iuno.c2 %iuno.fp is now in control of the current Uno game.
      unomsg3 $1 %iuno.fp You may now stop Uno by typing !unostop into %iuno.c2
      if (%iuno.dl == 1) {
        set %iuno.t.x 1
        set %iuno.t.r $numtok(%iuno.h. [ $+ [ $2 ] ],46)
        while (%iuno.t.r >= %iuno.t.x) {
          set %iuno.d $instok(%iuno.d,$gettok(%iuno.h. [ $+ [ $2 ] ],%iuno.t.x,46),$rand(1,$numtok(%iuno.d,46)),46)
          inc %iuno.t.x
        }
        addplayerscoreb $2
      }
    }
  }
  elseif ($findtok(%iuno.u,$2,0,46)) {
    set %iuno.u $deltok(%iuno.u,$findtok(%iuno.u,$2,1,46),46)
    if ($numtok(%iuno.u,46) <= 1) {
      if ($numtok(%iuno.u,46) != 0) {
        addplayerscoreb $2
        addplayerscore $gettok(%iuno.u,1,46)
        unomsg $1 %iuno.c2 $gettok(%iuno.u,1,46) gains %iuno.t.u points. For a total of %iuno.t.k points, and a total of $gettok($read(" $+ $scriptdir $+ Uno.txt $+ ",s,$gettok(%iuno.u,1,46)),2,47) games played.
        unoreset
      }
      else {
        unomsg $1 %iuno.c2 No one is playing Uno t.t Type !Uno to begin anew.
        unoreset
      }
    }
    else {
      unomsg $1 %iuno.c2 $2 was removed from the current Uno game.
      if (%iuno.dl == 1) {
        set %iuno.t.x 1
        set %iuno.t.r $numtok(%iuno.h. [ $+ [ $2 ] ],46)
        while (%iuno.t.r >= %iuno.t.x) {
          set %iuno.d $instok(%iuno.d,$gettok(%iuno.h. [ $+ [ $2 ] ],%iuno.t.x,46),$rand(1,$numtok(%iuno.d,46)),46)
          inc %iuno.t.x
        }
        addplayerscoreb $2
      }
    }
  }
}
;----------------------------------------------------------------------
alias addplayerscore {
  set %iuno.t.q $gettok($read(" $+ $scriptdir $+ Uno.txt $+ ",s,$1),2,47)
  inc %iuno.t.q
  write -l1 " $+ $scriptdir $+ Uno.txt $+ " $addtok($read(" $+ $scriptdir $+ Uno.txt $+ ",1),$1,46)
  if (!$read(" $+ $scriptdir $+ Uno.txt $+ ",s,$1)) write " $+ $scriptdir $+ Uno.txt $+ " $1 0/0
  set %iuno.t.r $gettok($read(" $+ $scriptdir $+ Uno.txt $+ ",s,$1),1,47)
  set %iuno.t.k $calc(%iuno.t.r + %iuno.t.u)
  $eval(write -s $+ $1 " $+ $scriptdir $+ Uno.txt $+ " $1 %iuno.t.k $+ $chr(47) $+ %iuno.t.q)
}
;----------------------------------------------------------------------
alias addplayerscoreb {
  set %iuno.h. [ $+ [ $1 ] ] $remove(%iuno.h. [ $+ [ $1 ] ],b,g,m,y,z,D4)
  set %iuno.t.s $replace(%iuno.h. [ $+ [ $1 ] ],.,+,S,20,D2,20,R,20,W,50)
  set %iuno.t.s $calc(%iuno.t.s)
  write -l1 " $+ $scriptdir $+ Uno.txt $+ " $addtok($read(" $+ $scriptdir $+ Uno.txt $+ ",1),$1,46)
  if (!$read(" $+ $scriptdir $+ Uno.txt $+ ",s,$1)) write " $+ $scriptdir $+ Uno.txt $+ " $1 0/0
  set %iuno.t.a $gettok($read(" $+ $scriptdir $+ Uno.txt $+ ",s,$1),2,47)
  inc %iuno.t.a
  set %iuno.t.u $calc(%iuno.t.s + %iuno.t.u)
  $eval(write -s $+ $1 " $+ $scriptdir $+ Uno.txt $+ " $1 $gettok($read(" $+ $scriptdir $+ Uno.txt $+ ",s,$1),1,47) $+ $chr(47) $+ %iuno.t.a)
}
;----------------------------------------------------------------------
alias unocards { /* Network, Nick */
  if (%iuno.h. [ $+ [ $2 ] ]) {
    set %iuno.ch. [ $+ [ $2 ] ] $sorttok(%iuno.h. [ $+ [ $2 ] ],46,a)
    set %iuno.ch. [ $+ [ $2 ] ] $replace(%iuno.ch. [ $+ [ $2 ] ],b,$eval($chr(3) $+ %iuno.cb $+ $chr(44) $+ %iuno.bc $+ $chr(91)))
    set %iuno.ch. [ $+ [ $2 ] ] $replace(%iuno.ch. [ $+ [ $2 ] ],g,$eval($chr(3) $+ %iuno.cg $+ $chr(44) $+ %iuno.bc $+ $chr(91)))
    set %iuno.ch. [ $+ [ $2 ] ] $replace(%iuno.ch. [ $+ [ $2 ] ],m,$eval($chr(3) $+ %iuno.cr $+ $chr(44) $+ %iuno.bc $+ $chr(91)))
    set %iuno.ch. [ $+ [ $2 ] ] $replace(%iuno.ch. [ $+ [ $2 ] ],y,$eval($chr(3) $+ %iuno.cy $+ $chr(44) $+ %iuno.bc $+ $chr(91)))
    set %iuno.ch. [ $+ [ $2 ] ] $replace(%iuno.ch. [ $+ [ $2 ] ],z,$eval($chr(3) $+ %iuno.cw $+ $chr(44) $+ %iuno.bc $+ $chr(91)))
    set %iuno.ch. [ $+ [ $2 ] ] $replace(%iuno.ch. [ $+ [ $2 ] ],.,$chr(93) $+ $chr(3))
    set %iuno.ch. [ $+ [ $2 ] ] %iuno.ch. [ $+ [ $2 ] ] $+ $chr(93)
    unomsg3 $1 $2 %iuno.d4.s %iuno.ch. [ $+ [ $2 ] ]
  }
  else {
    echo -s Uno error - User $2 does not have any cards.
  }
}
;----------------------------------------------------------------------
alias showtopcard {  /* Network, Channel */
  set %iuno.dc $gettok(%iuno.dp,1,46)
  set %iuno.dc $replace(%iuno.dc,b,$eval($chr(3) $+ %iuno.cb $+ $chr(44) $+ %iuno.bc $+ $chr(91)))
  set %iuno.dc $replace(%iuno.dc,g,$eval($chr(3) $+ %iuno.cg $+ $chr(44) $+ %iuno.bc $+ $chr(91)))
  set %iuno.dc $replace(%iuno.dc,m,$eval($chr(3) $+ %iuno.cr $+ $chr(44) $+ %iuno.bc $+ $chr(91)))
  set %iuno.dc $replace(%iuno.dc,y,$eval($chr(3) $+ %iuno.cy $+ $chr(44) $+ %iuno.bc $+ $chr(91)))
  set %iuno.dc $replace(%iuno.dc,z,$eval($chr(3) $+ %iuno.cw $+ $chr(44) $+ %iuno.bc $+ $chr(91)))
  set %iuno.dc $replace(%iuno.dc,.,$chr(93) $+ $chr(3))
  unomsg $1 $2 Top Card: %iuno.dc $+ $chr(93)
  var %iuno.cc 2
  set %iuno.cl Next:
  while (%iuno.cc <= $numtok(%iuno.u,46)) {
    set %iuno.cl %iuno.cl $chr(124) $gettok(%iuno.u,%iuno.cc,46) - $numtok(%iuno.h. [ $+ [ $gettok(%iuno.u,%iuno.cc,46) ] ],46) Cards
    inc %iuno.cc
  }
  unomsg3 $1 $gettok(%iuno.u,1,46)  $+ %iuno.fc $+ , $+ %iuno.bc $+ %iuno.cl
}
;----------------------------------------------------------------------
alias unoreset {
  unset %iuno.*
  set %iuno.color $gettok($read(" $+ $scriptdir $+ Uno.txt $+ ",2),2,46)
  set %iuno.rank $gettok($read(" $+ $scriptdir $+ Uno.txt $+ ",2),3,46)
  set %iuno.draw $gettok($read(" $+ $scriptdir $+ Uno.txt $+ ",2),4,46)
  set %iuno.comm $gettok($read(" $+ $scriptdir $+ Uno.txt $+ ",2),5,46)
  set %iuno.rwt $gettok($read(" $+ $scriptdir $+ Uno.txt $+ ",2),6,46)
  set %iuno.tt $gettok($read(" $+ $scriptdir $+ Uno.txt $+ ",2),7,46)
  set %iuno.sco $gettok($read(" $+ $scriptdir $+ Uno.txt $+ ",2),8,46)
  set %iuno.scon $gettok($read(" $+ $scriptdir $+ Uno.txt $+ ",2),9,46)
  set %iuno.mn $gettok($read(" $+ $scriptdir $+ Uno.txt $+ ",2),10,46)
  set %iuno.c $gettok($read(" $+ $scriptdir $+ Uno.txt $+ ",3),2-,44)
  set %iuno.as $gettok($read(" $+ $scriptdir $+ Uno.txt $+ ",4),1,32)
  if (%iuno.as > 0) {
    set %iuno.networks $gettok($read(" $+ $scriptdir $+ Uno.txt $+ ",4),2,32)
    set %iuno.as3 $gettok($read(" $+ $scriptdir $+ Uno.txt $+ ",4),3-,32)
  }
  set %iuno.as.c 1
  while (%iuno.as.c <= %iuno.as) {
    set %iuno.c. [ $+ [ $gettok(%iuno.networks,%iuno.as.c,44) ] ] $gettok(%iuno.as3,%iuno.as.c,32)
    inc %iuno.as.c
  }
  unocolors
}
;----------------------------------------------------------------------
alias newunodeck {
  if (!$1) set %iuno.ud b0.b1.b2.b3.b4.b5.b6.b7.b8.b9.b1.b2.b3.b4.b5.b6.b7.b8.b9.g0.g1.g2.g3.g4.g5.g6.g7.g8.g9.g1.g2.g3.g4.g5.g6.g7.g8.g9.m0.m1.m2.m3.m4.m5.m6.m7.m8.m9.m1.m2.m3.m4.m5.m6.m7.m8.m9.y0.y1.y2.y3.y4.y5.y6.y7.y8.y9.y1.y2.y3.y4.y5.y6.y7.y8.y9.bD2.bD2.gD2.gD2.mD2.mD2.yD2.yD2.bS.bS.gS.gS.yS.yS.mS.mS.bR.bR.gR.gR.yR.yR.mR.mR.ZW.ZW.ZW.ZW.zWD4.zWD4.zWD4.zWD4
  if ($1) {
    set %iuno.ud $replace(%iuno.ud,b $+ $chr(42),$chr(42),g $+ $chr(42),$chr(42),m $+ $chr(42),$chr(42),y $+ $chr(42),$chr(42))
    
    if ($findtok(%iuno.ud,$chr(42),0,46)) set %iuno.ud $reptok(%iuno.ud,$chr(42),ZW,1,46)
    if ($findtok(%iuno.ud,$chr(42),0,46)) set %iuno.ud $reptok(%iuno.ud,$chr(42),ZW,1,46)
    if ($findtok(%iuno.ud,$chr(42),0,46)) set %iuno.ud $reptok(%iuno.ud,$chr(42),ZW,1,46)
    if ($findtok(%iuno.ud,$chr(42),0,46)) set %iuno.ud $reptok(%iuno.ud,$chr(42),ZW,1,46)
    if ($findtok(%iuno.ud,$chr(42),0,46)) set %iuno.ud $reptok(%iuno.ud,$chr(42),zWD4,1,46)
    if ($findtok(%iuno.ud,$chr(42),0,46)) set %iuno.ud $reptok(%iuno.ud,$chr(42),zWD4,1,46)
    if ($findtok(%iuno.ud,$chr(42),0,46)) set %iuno.ud $reptok(%iuno.ud,$chr(42),zWD4,1,46)
    if ($findtok(%iuno.ud,$chr(42),0,46)) set %iuno.ud $reptok(%iuno.ud,$chr(42),zWD4,1,46)
  }
  var %iuno.it $numtok(%iuno.ud,46)
  unset %iuno.d
  var %iuno.i = 1
  while (%iuno.i <= %iuno.it) {
    var %iuno.r $rand(1,$numtok(%iuno.ud,46))
    set %iuno.d $instok(%iuno.d,$gettok(%iuno.ud,%iuno.r,46),-0,46)
    set %iuno.ud $deltok(%iuno.ud,%iuno.r,46)
    inc %iuno.i
  }
  unset %iuno.ud
}
;----------------------------------------------------------------------
alias skip {
  set %iuno.u $instok(%iuno.u,$gettok(%iuno.u,1,46),-0,46)
  set %iuno.u $deltok(%iuno.u,1,46)
  unomsg $1 %iuno.c2 $2 was Skipped! $gettok(%iuno.u,1,46) $+ 's turn.
  showtopcard $1 %iuno.c2
  unocards $1 $gettok(%iuno.u,1,46)
}
;----------------------------------------------------------------------
alias drawtwo {
  var %iuno.d2v 1
  while (%iuno.d2v <= 2) {
    if (!$numtok(%iuno.d,46)) {
      set %iuno.ud %iuno.dp
      unset %iuno.dp
      set %iuno.dp $gettok(%iuno.ud,1,46)
      set %iuno.ud $deltok(%iuno.ud,1,46)
      unomsg $1 %iuno.c2 Shuffling discard pile
      newunodeck x
    }
    set %iuno.h. [ $+ [ $2 ] ] $instok(%iuno.h. [ $+ [ $2 ] ],$gettok(%iuno.d,1,46),-0,46)
    set %iuno.d $deltok(%iuno.d,1,46)
    inc %iuno.d2v
  }
  set %iuno.u $instok(%iuno.u,$gettok(%iuno.u,1,46),-0,46)
  set %iuno.u $deltok(%iuno.u,1,46)
  unomsg $1 %iuno.c2 $2 Draws Two and is Skipped! $gettok(%iuno.u,1,46) $+ 's turn.
  showtopcard $1 %iuno.c2
  drawncards $network $2 2
  unocards $1 $gettok(%iuno.u,1,46)
}
;----------------------------------------------------------------------
alias unocolors {
  if (%iuno.color == 1) {
    set %iuno.cb 12
    set %iuno.cg 9
    set %iuno.cw 0
    set %iuno.fc 0
    set %iuno.bc 1
  }
  else {
    set %iuno.cb 2
    set %iuno.cg 3
    set %iuno.cw 1
    set %iuno.fc 1
    set %iuno.bc 0
  }
  set %iuno.cr 4
  set %iuno.cy 8
}
;----------------------------------------------------------------------
alias drawncards {
  set %iuno.t.m $numtok(%iuno.h. [ $+ [ $2 ] ],46)
  set %iuno.t.l $gettok(%iuno.h. [ $+ [ $2 ] ],%iuno.t.m,46)
  set %iuno.t.j $3
  while (%iuno.t.j > 1) {
    dec %iuno.t.m
    set %iuno.t.l %iuno.t.l $+ $chr(46) $+ $gettok(%iuno.h. [ $+ [ $2 ] ],%iuno.t.m,46)
    dec %iuno.t.j
  }
  set %iuno.t.l $replace(%iuno.t.l,b,$eval($chr(3) $+ %iuno.cb $+ $chr(44) $+ %iuno.bc $+ $chr(91)))
  set %iuno.t.l $replace(%iuno.t.l,g,$eval($chr(3) $+ %iuno.cg $+ $chr(44) $+ %iuno.bc $+ $chr(91)))
  set %iuno.t.l $replace(%iuno.t.l,m,$eval($chr(3) $+ %iuno.cr $+ $chr(44) $+ %iuno.bc $+ $chr(91)))
  set %iuno.t.l $replace(%iuno.t.l,y,$eval($chr(3) $+ %iuno.cy $+ $chr(44) $+ %iuno.bc $+ $chr(91)))
  set %iuno.t.l $replace(%iuno.t.l,z,$eval($chr(3) $+ %iuno.cw $+ $chr(44) $+ %iuno.bc $+ $chr(91)))
  set %iuno.t.l $replace(%iuno.t.l,.,$chr(93) $+ $chr(3))
  set %iuno.t.l %iuno.t.l $+ $chr(93)
  unomsg3 $1 $2  $+ %iuno.fc $+ , $+ %iuno.bc $+ Drawn Card(s): %iuno.t.l
}
;----------------------------------------------------------------------
alias reverse { /* Network, Nick */
  var %iuno.ri 2
  while (%iuno.ri <= $numtok(%iuno.u,46)) {
    set %iuno.u $instok(%iuno.u,$gettok(%iuno.u,%iuno.ri,46),1,46)
    inc %iuno.ri
    set %iuno.u $deltok(%iuno.u,%iuno.ri,46)
  }
  if ((%iuno.rwt == 1) && ($numtok(%iuno.u,46) == 2)) {
    set %iuno.u $instok(%iuno.u,$gettok(%iuno.u,1,46),-0,46)
    set %iuno.u $deltok(%iuno.u,1,46)
  }
  set %iuno.u $instok(%iuno.u,$gettok(%iuno.u,1,46),-0,46)
  set %iuno.u $deltok(%iuno.u,1,46)
  unomsg $1 %iuno.c2 $2 Reversed it! $gettok(%iuno.u,1,46) $+ 's turn.
  showtopcard $1 %iuno.c2
  unocards $1 $gettok(%iuno.u,1,46)
}
;----------------------------------------------------------------------
alias chanpop {
  did -r UnoOptions 10
  didtok UnoOptions 10 44 %iuno.c
  did -c UnoOptions 10 1
}
;----------------------------------------------------------------------
alias chanpop2 {
  did -r UnoOptions 43
  if (!$1) didtok UnoOptions 43 46 %iuno.c. [ $+ [ $did(53).text ] ]
  if ($1) didtok UnoOptions 43 46 %iuno.c. [ $+ [ $did(40).text ] ]
  did -c UnoOptions 43 1
  if (!$1) did -c UnoOptions 40 $findtok($didtok(UnoOptions,40,44),$did(53).text,1,44)
}
;----------------------------------------------------------------------
alias unofilter { ;Average per Game
  if ($calc($gettok($1,2,32)) > $calc($gettok($2,2,32))) return -1
  if ($calc($gettok($1,2,32)) < $calc($gettok($2,2,32))) return 1
  if ($calc($gettok($1,2,32)) == $calc($gettok($2,2,32))) return 0
}
;----------------------------------------------------------------------
alias unofilter2 { ;Total Points
  if ($gettok($gettok($1,2,32),1,47) > $gettok($gettok($2,2,32),1,47)) return -1
  if ($gettok($gettok($1,2,32),1,47) < $gettok($gettok($2,2,32),1,47)) return 1
  if ($gettok($gettok($1,2,32),1,47) == $gettok($gettok($2,2,32),1,47)) return 0
}
;----------------------------------------------------------------------
alias unofilter3 { ;Total Games
  if ($gettok($gettok($1,2,32),2,47) > $gettok($gettok($2,2,32),2,47)) return -1
  if ($gettok($gettok($1,2,32),2,47) < $gettok($gettok($2,2,32),2,47)) return 1
  if ($gettok($gettok($1,2,32),2,47) == $gettok($gettok($2,2,32),2,47)) return 0
}
;----------------------------------------------------------------------
alias UnoOptions {
  dialog -ma UnoOptions UnoOptions
}
;----------------------------------------------------------------------
alias mnunoupdate {
  set %iuno.networks $didtok(UnoOptions,40,44)
  set %iuno.tv.c 1
  while (%iuno.tv.c <= $numtok(%iuno.networks,44)) {
    set %iuno.tv2.c 1
    while (%iuno.tv2.c <= $numtok(%iuno.c. [ $+ [ $gettok(%iuno.networks,%iuno.tv.c,44) ] ],46)) {
      set %iuno.c $addtok(%iuno.c,$gettok(%iuno.c. [ $+ [ $gettok(%iuno.networks,%iuno.tv.c,44) ] ],%iuno.tv2.c,46),44)
      inc %iuno.tv2.c
    }
    inc %iuno.tv.c
  }
}
;----------------------------------------------------------------------
dialog -l UnoOptions {
  title "IRC Uno by Lost.Lion@gmail.com"
  size -1 -1 300 328
  option pixels notheme
  tab "Options", 6, 1 1 299 300
  tab "Network Options", 38
  tab "Variations", 27
  tab "About", 7
  button "Apply", 1, 220 300 70 25, ok
  button "UnLoad", 23, 7 265 70 25, tab 6
  button "ReLoad", 24, 78 265 70 25, tab 6
  button "Reset", 25, 149 265 70 25, tab 6
  button "Open Uno.txt", 26, 220 265 72 25, tab 6
  button "Remove Network", 47, 158 168 87 20, tab 38 disable
  button "Add Channel", 48, 7 66 87 20, tab 38 disable
  button "Remove Channel", 49, 158 121 87 20, tab 38 disable
  button "Add Channel", 39, 5 32 87 20, tab 6
  button "Remove Channel", 50, 145 74 87 20, tab 6
  button "Cancel", 46, 141 300 65 25
  box "Color Scheme", 8, 5 95 140 55, tab 6
  box "User Communications", 20, 145 95 140 55, tab 6
  box "Rank System", 32, 5 150 140 55, tab 6
  box "Score System", 34, 145 150 140 55, tab 6
  text "Uno Channel(s)", 9, 145 33 84 17, tab 6 center
  text "Uno for mIRC created by Lost.Lion@gmail.com", 11, 6 24 289 17, tab 7
  text "Version 1.12", 12, 6 40 100 17, tab 7
  text "Find me at irc.rizon.net channel #Lovely Nick KovuKun", 14, 5 83 290 17, tab 7
  text "Special Thanks To:", 15, 5 122 291 17, tab 7 center
  text "superlady of #lovely for giving me many ideas and lots of support.", 16, 5 141 291 30, tab 7 center
  text "All the members of #lovely for putting up with the testing and for joining in to help find the bugs.", 17, 5 172 291 30, tab 7 center
  text "RG for making the Dialog Editor and Script Editor that I am Using.", 18, 5 203 291 30, tab 7 center
  text "Networks", 41, 7 150 100 17, tab 38
  text "Channels", 42, 7 103 100 17, tab 38
  text "IRC Uno uses $findcid ($unocid) by FiberOPtics", 44, 5 253 291 17, tab 7 center
  link "http://www.LostLion.tk", 13, 6 56 146 17, tab 7
  link "http://www.mircscripts.org/users/RG", 19, 58 234 185 17, tab 7
  link "http://www.mirc.net/user/FiberOPtics", 45, 58 272 186 17, tab 7
  radio "Black Background", 4, 7 113 107 17, tab 6 group
  radio "White Background", 5, 7 129 107 17, tab 6
  radio "Notice", 21, 148 113 57 17, tab 6 group
  radio "Message", 22, 148 129 64 17, tab 6
  check "Enable !Rank", 3, 7 168 100 17, tab 6
  check "Reverse acts like Skip with 2 Players", 28, 5 45 196 17, tab 27
  check "Enable !UnoTop10", 33, 7 183 111 17, tab 6
  check "Enable !Score", 36, 147 168 100 17, tab 6
  check "Enable !Score <nick>", 37, 147 184 126 17, tab 6
  check "Enable Multi-Network", 35, 7 26 118 17, tab 38
  check "1 !Draw then !Pass", 2, 5 27 117 17, tab 27
  check "All Networks", 54, 145 68 100 17, tab 38 disable
  check "Cards Dealt Face Up", 29, 5 81 124 17, tab 27 disable
  check "!Play or Lose (No !Draw)", 30, 5 99 140 17, tab 27 disable
  check "DrawTwo/DrawFours Accumulate", 31, 5 117 185 17, tab 27 disable
  check "Wild Draw 4 Doesn't Skip Player", 55, 5 63 195 17, tab 27 disable
  combo 10, 145 51 138 70, tab 6 drop sort
  combo 40, 7 168 149 70, tab 38 drop sort disable
  combo 43, 7 121 149 70, tab 38 drop sort disable
  edit "#Channel", 51, 5 51 138 20, tab 6
  edit "#Channel", 52, 7 47 138 20, tab 38 disable
  edit "Network", 53, 145 47 138 20, tab 38 disable
}
;----------------------------------------------------------------------
on *:dialog:UnoOptions:init:0: {
  if (%iuno.draw == 1) did -c UnoOptions 2
  if (%iuno.rank == 1) did -c UnoOptions 3
  if (%iuno.color == 1) did -c UnoOptions 4
  if (%iuno.color == 2) did -c UnoOptions 5
  if (%iuno.comm == 0) did -c UnoOptions 21
  if (%iuno.comm == 1) did -c UnoOptions 22
  if (%iuno.rwt == 1) did -c UnoOptions 28
  if (%iuno.tt == 1) did -c UnoOptions 33
  if (%iuno.sco == 1) did -c UnoOptions 36
  if (%iuno.scon == 1) did -c UnoOptions 37
  if (%iuno.mn == 1) {
    did -c UnoOptions 35
    didtok UnoOptions 40 44 %iuno.networks
    didtok UnoOptions 43 46 %iuno.c. [ $+ [ $gettok(%iuno.networks,1,44) ] ]
    did -c UnoOptions 40 1
    did -c UnoOptions 43 1
    did -b UnoOptions 39,51,10,50
    did -e UnoOptions 52,53,48,54,43,49,40,47
  }
  chanpop
}
;----------------------------------------------------------------------
on *:dialog:UnoOptions:sclick:23: {
  dialog -x UnoOptions
  unload -rs " $+ $scriptdir $+ Uno.mrc $+ "
}
on *:dialog:UnoOptions:sclick:24: {
  dialog -x UnoOptions
  reload -rs " $+ $scriptdir $+ Uno.mrc $+ "
}
on *:dialog:UnoOptions:sclick:25: {
  dialog -x UnoOptions
  unoreset
}
on *:dialog:UnoOptions:sclick:26: {
  dialog -x UnoOptions
  run " $+ $scriptdir $+ Uno.txt $+ "
}
on *:dialog:UnoOptions:sclick:46: {
  dialog -x UnoOptions
}
on *:dialog:UnoOptions:sclick:39: {
  set %iuno.c $addtok(%iuno.c,$did(51).text,44)
  chanpop
}
on *:dialog:UnoOptions:sclick:50: {
  set %iuno.c $remtok(%iuno.c,$did(10,1).seltext,44)
  did -d UnoOptions 10 $did(10).sel
  chanpop
}
on *:dialog:UnoOptions:sclick:48: {
  if ($did(54).state == 1) {
    set %iuno.c.all $addtok(%iuno.c.all,$did(52).text,46)
    did -r UnoOptions 53
    did -a UnoOptions 53 All
  }
  else {
    set %iuno.c. [ $+ [ $did(53).text ] ] $addtok(%iuno.c. [ $+ [ $did(53).text ] ],$did(52).text,46)
  }
  if (!$findtok($didtok(UnoOptions,40,46),$did(53).text,46)) {
    did -a UnoOptions 40 $did(53).text
  }
  mnunoupdate
  chanpop2
}
on *:dialog:UnoOptions:sclick:49: {
  set %iuno.c. [ $+ [ $did(40).seltext ] ] $remtok(%iuno.c. [ $+ [ $did(40).seltext ] ],$did(43).seltext,46)
  if ($numtok( %iuno.c. [ $+ [ $did(40).seltext ] ],46) == 0) {
    unset %iuno.c. [ $+ [ $did(40).seltext ] ]
    did -d UnoOptions 40 $did(40).sel
  }
  did -c UnoOptions 40 1
  chanpop2 X
}
on *:dialog:UnoOptions:sclick:47: {
  unset %iuno.c. [ $+ [ $did(40).seltext ] ]
  did -d UnoOptions 40 $did(40).sel
  set %iuno.networks $remtok(%iuno.networks,$did(40).seltext,1,44)
  chanpop2
}
on *:dialog:UnoOptions:sclick:40: {
  chanpop2 X
}
on *:dialog:UnoOptions:sclick:35: {
  if ($did(35).state == 1) {
    did -r UnoOptions 40,43
    didtok UnoOptions 40 44 %iuno.networks
    didtok UnoOptions 43 46 %iuno.c. [ $+ [ $gettok(%iuno.networks,1,44) ] ]
    did -c UnoOptions 40 1
    did -c UnoOptions 43 1
    did -b UnoOptions 39,51,10,50
    did -e UnoOptions 52,53,48,54,43,49,40,47
  }
  else {
    did -e UnoOptions 39,51,10,50
    did -b UnoOptions 52,53,48,54,43,49,40,47
  }
}
;----------------------------------------------------------------------
on *:dialog:UnoOptions:close:*: {
  set %iuno.draw $did(2).state
  set %iuno.rank $did(3).state
  set %iuno.rwt $did(28).state
  set %iuno.tt $did(33).state
  set %iuno.sco $did(36).state
  set %iuno.scon $did(37).state
  set %iuno.mn $did(35).state
  if ($did(4).state == 1) set %iuno.color 1
  else set %iuno.color 2
  if ($did(21).state == 1) set %iuno.comm 0
  else set %iuno.comm 1
  unocolors
  write -l3 " $+ $scriptdir $+ Uno.txt $+ " !Channels! $+ $chr(44) $+ %iuno.c
  write -l2 " $+ $scriptdir $+ Uno.txt $+ " !Options! $+ $chr(46) $+ %iuno.color $+ $chr(46) $+ %iuno.rank $+ $chr(46) $+ %iuno.draw $+ $chr(46) $+ %iuno.comm $+ $chr(46) $+ %iuno.rwt $+ $chr(46) $+ %iuno.tt $+ $chr(46) $+ %iuno.sco $+ $chr(46) $+ %iuno.scon $+ $chr(46) $+ %iuno.mn
  unset %iuno.c
  if (%iuno.mn == 0) set %iuno.c $didtok(UnoOptions,10,44)
  else {
    mnunoupdate
  }
  set %iuno.lfc 1
  set %iuno.lft $numtok(%iuno.networks,44) $+ $chr(32) $+ %iuno.networks
  while (%iuno.lfc <= $numtok(%iuno.networks,44)) {
    set %iuno.lft $addtok(%iuno.lft,%iuno.c. [ $+ [ $gettok(%iuno.networks,%iuno.lfc,44) ] ],32)
    inc %iuno.lfc
  }
  write -l4 " $+ $scriptdir $+ Uno.txt $+ " %iuno.lft
  unset %iuno.lfc
  unset %iuno.lft
}
;----------------------------------------------------------------------
menu channel {
  Uno Options: UnoOptions
}
;----------------------------------------------------------------------
on *:unload: {
  unset %iuno.*
  echo -a 0,1--=) 4UnLoaded 11{15IRC-Uno11} 9by 11{15Lost.Lion@gmail.com11} 0(=--
}