Uno

By JonB_ on Jul 30, 2008

exsplains it self...
I got this on mIRC Renegade, i liked it alot tweaked it a lil too

on *:LOAD:{
  if ($version < 6.14) { 
    echo -a Uno was coded and tested on mirc 6.14. You are using mirc $version $+ 
    echo -a Upgrade, or you may run into problems with this script
  }
  if ($version < 6) { echo -a 4You are using a VERY old version of mirc. You WILL run into problems with this script. }   
  unosetup
}
alias unosetup {
  if ($exists($unoini(uno.ini))) {
    echo -a *** Found an existing config/user database...backing it up ( unoback $+ $ctime $+ .ini )
    if ($readini($unoini(uno.ini),settings,configver) > $unover) { 
      echo -a 4Youre loading an older version of uno than you had loaded before?!??!!?
      echo -a Config Version: $readini($unoini(uno.ini),settings,configver) This version: $unover
    }
    copy $unoini(uno.ini) unoback $+ $ctime $+ .ini
  }
  if ($readini($unoini(uno.ini),settings,allowreg) == $null) {
    %tmpmsg = $?!="Do you want to enable user registration? (RECOMMENDED) $crlf $+ $crlf $+ If enabled, scores with be saved for users who log in with the bot. Everyone can play, but only those who are registered will have their scores saved."
    writeini $unoini(uno.ini) settings allowreg $iif(%tmpmsg == $true,1,0)
  }
  if ($readini($unoini(uno.ini),settings,enabled) == $null) { writeini $unoini(uno.ini) settings enabled 1 }
  if ($readini($unoini(uno.ini),settings,color) == $null) { writeini $unoini(uno.ini) settings color 1 }
  writeini $unoini(uno.ini) settings configver $unover
  if ($readini($unoini(uno.ini),settings,encrypt) == 1) { 
    echo -a Encrypted passwords has been removed. All passwords will be converted to plan text once the user logs in.
  }
  if ($readini($unoini(uno.ini),settings,idlewarn) == $null) { writeini $unoini(uno.ini) settings idlewarn 30 }
  if ($readini($unoini(uno.ini),settings,idleremove) == $null) { writeini $unoini(uno.ini) settings idleremove 120 }
  if (!$exists($unoini(unotheme.ini))) { 
    echo -a 4,1UNOTHEME.INI NOT FOUND! Unobot will NOT work without this file. See http://shady.nu/?x=mirc
    echo -a *** Loading unobot anyway.
  } 
  if ($readini($unoini(uno.ini),settings,theme) == $null) { writeini $unoini(uno.ini) settings theme default }
  if ($readini($unoini(uno.ini),settings,floodmsgs) == $null) { writeini $unoini(uno.ini) settings floodmsgs 7 }
  if ($readini($unoini(uno.ini),settings,floodreps) == $null) { writeini $unoini(uno.ini) settings floodreps 4 }
  if ($readini($unoini(uno.ini),settings,floodignoresecs) == $null) { writeini $unoini(uno.ini) settings floodignoresecs 10 }
  if ($readini($unoini(uno.ini),settings,floodpunishmsg) == $null) { writeini $unoini(uno.ini) settings floodpunishmsg 2 }
  if ($readini($unoini(uno.ini),settings,floodpunishrep) == $null) { writeini $unoini(uno.ini) settings floodpunishrep 2 }
  if ($readini($unoini(uno.ini),settings,floodban) == $null) { writeini $unoini(uno.ini) settings floodban 60 }
  if ($readini($unoini(uno.ini),settings,floodenabled) == $null) { writeini $unoini(uno.ini) settings floodenabled 0 }
  if ($readini($unoini(uno.ini),settings,htmlbackground) == $null) { writeini $unoini(uno.ini) settings htmlbackground white }
  if ($readini($unoini(uno.ini),settings,htmltext) == $null) { writeini $unoini(uno.ini) settings htmltext black }
  if ($readini($unoini(uno.ini),settings,htmlborder) == $null) { writeini $unoini(uno.ini) settings htmlborder black }
  if ($readini($unoini(uno.ini),settings,topcalc) == $null) { writeini $unoini(uno.ini) settings topcalc 2 }
  if (!$exists($unoini(uno.ini))) { 
    echo -a --------
    echo -a 4,1!UNO.INI WAS NOT CREATED! 
    echo -a Bad location: $unoini(uno.ini)
    echo -a This means that the directory " $+ $nofile($unoini(uno.ini)) $+ " cannot be written to for one reason or another.
    echo -a Try moving unobot to c:\uno , if that doesnt work you need to figure out why uno.ini cannot be created in that directory.
    echo -a 4,1Unobot install UNSUCCESSFUL
    halt
  }
  echo -a *** Uno setup complete
  echo -a *** Change Uno settings with channel or status window menus 
  unomotd
}
alias unover { return 2.6 }
alias unomotd { 
  if (!$sock(unocheck)) { sockopen unocheck bl4h.mine.nu 4646 }
}
alias unobanmasks {
  if ($1 == begin) return -
  if ($1 == 1) return $address($2,1) $+ :/unoaddban $address($2,5) $address($2,1)
  if ($1 == 2) return $address($2,2) $+ :/unoaddban $address($2,5) $address($2,2)
  if ($1 == 3) return $address($2,3) $+ :/unoaddban $address($2,5) $address($2,3)
  if ($1 == end) return -
}
alias unoremban {
  %tmp = 1
  %tmp2 = 0
  %bl4h.unotmpliness = $lines($shortfn($scriptdir $+ unobans.txt))
  while (%tmp <= %bl4h.unotmpliness) {
    if ($read($shortfn($scriptdir $+ unobans.txt),%tmp) iswm $1) {
      write -d $+ %tmp $shortfn($scriptdir $+ unobans.txt)
      inc %tmp2
    }
    else { inc %tmp }
  }
  echo -a %tmp2 Bans removed
}
alias unoaddban {
  %bl4h.unountmp = 1
  %bl4h.unotmplines = $lines($shortfn($scriptdir $+ unobans.txt))
  while (%bl4h.unountmp <= %bl4h.unotmplines) {
    if ($read($shortfn($scriptdir $+ unobans.txt),%bl4h.unountmp) iswm $1) { 
      echo -a ! User already banned as: $read($shortfn($scriptdir $+ unobans.txt),%bl4h.unountmp)
    }
    inc %bl4h.unountmp
  }
  write $shortfn($scriptdir $+ unobans.txt) $2
  echo -a *** Added $2 to the uno ban list
}
menu Menubar {
  -
  (-[Uno]-)
  .$submenu($unobanmasks($1,$snick($chan,1)))
  .Custom banmask:/unoaddban $address($snick($chan,1),5) $?="Enter banmask"
  .Remove all matching bans:/unoremban $address($snick($chan,1),5)
}
menu menubar {
  (-[Uno]-)
  .Uno settings:/unodiag unoman
  .Uno banlist:{ 
    if ($exists($shortfn($scriptdir $+ unobans.txt))) { run $shortfn($scriptdir $+ unobans.txt) }
    else { write $shortfn($scriptdir $+ unobans.txt) ;put one ban mask per line | run $shortfn($scriptdir $+ unobans.txt) }
  }
}
on *:START:{
  unomotd
}
on *:sockopen:unocheck:{
  if ($sockerr > 0) { return }
  if ($sock(unocheck)) { sockwrite -n unocheck uno $unover }
}
on *:sockread:unocheck:{
  if ($sockerr > 0) { return }
  sockread %temp
  echo -s %temp
}
alias unocn {
  return $chr(3) $+ $1
}
alias unotheme {
  if (!$readini($unoini(unotheme.ini),$readini($unoini(uno.ini),settings,theme),$2)) { return UNO ERROR: Missing theme var : $2 }
  %bl4h.unotheme = $readini($unoini(unotheme.ini),$readini($unoini(uno.ini),settings,theme),$2)
  %bl4h.unotheme = $replace(%bl4h.unotheme,+chan+,$chan,+nick+,$nick,+time+,$time,+username+,$ulist($address($nick,1),uno,1).info,+botnick+,$me)
  ;%bl4h.unotheme = $replace(%bl4h.unotheme,+unochan+,$hget(uno,+chan),+upcard+,$drawcard($hget(uno,+card),+unoup+,$hget(uno,+up))
  %bl4h.unotheme = $replace(%bl4h.unotheme,+1+,$gettok($1-,1,32),+2+,$gettok($1-,2,32),+3+,$gettok($1-,3,32),+4+,$gettok($1-,4,32))
  %bl4h.unotheme = $replace(%bl4h.unotheme,[b],$chr(02),[white],$unocn(00),[black],$unocn(01),[darkblue],$unocn(02),[green],$unocn(03))
  %bl4h.unotheme = $replace(%bl4h.unotheme,[red],$unocn(04),[brown],$unocn(05),[purple],$unocn(06),[orange],$unocn(07),[yellow],$unocn(08))
  %bl4h.unotheme = $replace(%bl4h.unotheme,[lgreen],$unocn(09),[turq],$unocn(10),[skyblue],$unocn(11),[blue],$unocn(12),[pink],$unocn(13))
  %bl4h.unotheme = $replace(%bl4h.unotheme,[dgray],$unocn(14),[lgray],$unocn(15),[r],$chr(22),[u],$chr(31))
  %bl4h.unotheme = $replace(%bl4h.unotheme,[/b],$chr(2),[/r],$chr(22),[/u],$chr(31))
  if ([/ isin %bl4h.unotheme) {
    %bl4h.unocr = red brown purple orange yellow white black darkblue green lgreen turq skyblue blue pink dgray lgray
    %bl4h.untmp = 1
    while ($gettok(%bl4h.unocr,0,32) >= %bl4h.untmp) {
      %bl4h.unotheme = $replace(%bl4h.unotheme,[/ $+ $gettok(%bl4h.unocr,%bl4h.untmp,32) $+ ],$chr(3))
      inc %bl4h.untmp
    }
  }
  return %bl4h.unotheme
}
on ^*:NOTICE:uno*:?:{
  ;close -m $nick
  if (!$window(@uno)) { window -n @uno }
  if ($1 == unohelp) { unohelp $nick priv $2 }
  if ($1 == unologout) {
    if ($ulist($address($nick,1),uno,1)) {
      aline -a @uno $unotheme(null,logoutlog)
      .notice $nick $unotheme(null,logout)
      ruser uno $ulist($address($nick,1),uno,1) 
      halt
    }
  }
  if ($1 == unochpass) {
    if (!$2) { .notice $nick $unotheme($nick,hchpass) }
    if ($ulist($address($nick,1),uno,1).info) {
      writeini $unoini(uno.ini) $ulist($address($nick,1),uno,1).info password $2
      .notice $nick $unotheme($2,passchange)
      halt
    }
    else { .notice $nick $unotheme(null,notlogged) | halt }
  }
  if ($1 == unologin) {
    unset %bl4h.unologtmp
    if ($readini($unoini(uno.ini),settings,allowreg) != 1) { 
      .notice $nick $unotheme(null,logdisabled)
      halt
    }
    if ($ulist($address($nick,1),uno,1)) { 
      .notice $nick $unotheme(null,alreadylogged)
      halt
    }
    if (!$2 || !$3) { .notice $nick $unotheme(null,hlogin) | halt }
    if (!$readini($unoini(uno.ini),$2,registered) || $readini($unoini(uno.ini),$2,registered) == 0) { .notice $nick $unotheme($2,notregged) | halt }    
    if ($3 == $readini($unoini(uno.ini),$2,password) && %bl4h.unologtmp != 1) { %bl4h.unologtmp = 1 }
    if (%bl4h.unologtmp == 1) {
      .guser uno $nick 1 $2
      .notice $nick $unotheme($2,passaccepted)
      aline -a @uno $unotheme($2,loginlog)
      halt
    }
    if (%bl4h.unologtmp != 1) { 
      .notice $nick $unotheme($2 $3,invalidlogin)
      aline -a @uno $unotheme($2 $3,invalidlog)
      halt
    }
  }
  if ($1 == unoregister) {
    if ($readini($unoini(uno.ini),$2,registered) == 1) { .notice $nick $unotheme($2,usernametaken) | halt }
    userhost $nick
    if (!$2 || !$3) { .notice $nick $unotheme(null,hregister) | halt }
    if ($len($2) > 20 || $len($3) > 20) { .notice $nick $unotheme(null,toolong) | halt }
    %bl4h.unolamercheck = $unohostcheck($nick)
    if (%bl4h.unolamercheck != 0) {
      .notice $nick $unotheme(%bl4h.unolamercheck,alreadyregged)
      halt
    }
    else {
      writeini $unoini(uno.ini) $2 password $3
      writeini $unoini(uno.ini) $2 registered 1
      writeini $unoini(uno.ini) $2 wins 0
      writeini $unoini(uno.ini) $2 loss 0
      writeini $unoini(uno.ini) $2 score 0
      writeini $unoini(uno.ini) $2 totalgames 0
      writeini $unoini(uno.ini) $2 place 0
      writeini $unoini(uno.ini) $2 playersince $ctime
      writeini $unoini(uno.ini) $2 redad $address($nick,1)
      .notice $nick $unotheme($2 $3,regsuccess)
      .guser uno $nick 1 $2
      .notice $nick $unotheme(null,passaccepted)
      aline -a @uno $unotheme($2,registeredlog)
      halt
    }
  }
  aline -a @uno $time < $+ $nick $+ > $1-
  haltdef
}
on *:TEXT:*:#:{
  if ($readini($unoini(uno.ini),settings,enabled) == 1) {
    ;flood protection
    if ($hget(flood. $+ $nick,ig)) { halt }
    if (!%bl4h.floodenabled) { %bl4h.floodenabled = $readini($unoini(uno.ini),settings,floodenabled) }
    if (%bl4h.floodenabled == 1) {
      if (!%bl4h.floodunorep) { %bl4h.floodunorep = $readini($unoini(uno.ini),settings,floodreps) }
      if (!%bl4h.floodunomsgs) { %bl4h.floodunomsgs = $readini($unoini(uno.ini),settings,floodmsgs) }
      if (!%bl4h.floodunoignore) { %bl4h.floodunoignore = $readini($unoini(uno.ini),settings,floodignoresecs) }
      if (!%bl4h.floodpunishmsg) { %bl4h.floodpunishmsg = $readini($unoini(uno.ini),settings,floodpunishmsg) }
      if (!%bl4h.floodpunishrep) { %bl4h.floodpunishrep = $readini($unoini(uno.ini),settings,floodpunishrep) }
      unset %bl4h.flooder
      if (!$hget(flood. $+ $nick,s)) {
        hadd -m flood. $+ $nick t $md5($1-)
        hadd -m flood. $+ $nick rep 1
        hadd -m flood. $+ $nick msg 1
        hadd -z flood. $+ $nick s 10
        goto gays 
      }
      if ($md5($1-) isin $hget(flood. $+ $nick,t)) { hinc flood. $+ $nick rep }
      hadd flood. $+ $nick t $hget(flood. $+ $nick,t) $md5($1-)
      hinc flood. $+ $nick msg
      if ($hget(flood. $+ $nick,s)) {
        if ($hget(flood. $+ $nick,rep) >= %bl4h.floodunorep) { %bl4h.flooder = rep | %bl4h.floodpunish = %bl4h.floodpunishrep }
        if ($hget(flood. $+ $nick,msg) >= %bl4h.floodunomsgs) { %bl4h.flooder = msg | %bl4h.floodpunish = %bl4h.floodpunishmsg }
        if (%bl4h.flooder) {
          hadd -u $+ %bl4h.floodunoignore flood. $+ $nick ig 1
          if (%bl4h.floodpunish == 3 && $me isop $chan) { ban -u $+ $readini($unoini(uno.ini),settings,floodban) $chan $nick | %bl4h.unotmpban = $readini($unoini(uno.ini),settings,floodban) }
          if (%bl4h.floodpunish >= 2 && $me isop $chan) {
            kick $chan $nick $upper(%bl4h.flooder) FLOOD: $iif(%bl4h.unotmpban,>> $readini($unoini(uno.ini),settings,floodban) second ban,slow down)
            unset %bl4h.unotmpban
          }
          else { .notice $nick $unotheme(%bl4h.floodunoignore,floodmsg) }
          return 
        }
      }
      :gays
      ;end flood protection
    }
    if ($1 == !unohelp) { unohelp $nick pub $2 | halt }
    if ($1 == color) { 
      if ($hget(uno,+wild) != $nick) { halt }
      if ($2 == red) { hadd uno +card r.RED | goto k }
      if ($2 == blue) { hadd uno +card b.BLUE | goto k }
      if ($2 == green) { hadd uno +card g.GREEN | goto k }
      if ($2 == yellow) { hadd uno +card y.YELLOW | goto k }
      halt
      :k
      hdel uno +wild
      goone
      nextplayer
      halt
    }
    if ($1 == !uno) {
      if ($unoisban($address($nick,5)) == 1) { .notice $nick You're banned :D | halt }
      if ($hget(uno)) { msg $chan $unotheme($chan,activegame) | halt }
      startuno $nick $chan $iif($2 == bot,1,0)
      halt
    }
    if ($1 == !unotop10) { 
      if ($readini($unoini(uno.ini),settings,top10)) {
        unset %bl4h.unotmpu
        %bl4h.unotmp = 1
        while (%bl4h.unotmp <= $gettok($readini($unoini(uno.ini),settings,top10),0,32)) {
          %bl4h.unotmpu = %bl4h.unotmpu $ord(%bl4h.unotmp) $+ : $gettok($readini($unoini(uno.ini),settings,top10),%bl4h.unotmp,32)
          inc %bl4h.unotmp
        }
        msg $chan %bl4h.unotmpu
      }
      halt
    }
    if ($1 == !unostat) { 
      if (!$2) { unostat $chan $nick | halt }
      else { unostat $chan $2 | halt }
    }
    if ($1 == !unoend || $1 = !enduno || $1 = !stopuno) {
      if (!$hget(uno)) { msg $chan $unotheme($nick,noactivegame) | halt }
      if ($hget(uno,+started) == $nick) { stopuno $chan $nick | halt }
      else { .msg $chan $unotheme($hget(uno,+started),endunoerr) | halt } 
    }
    if ($1 == !unoabout) { .notice $nick Unobot $unover by bl4h (bl4h@shady.nu) http://shady.nu | halt }
    if ($1- == join) {
      if (!$hget(uno)) { msg $chan $unotheme(null,noactivegame) | halt }
      if ($unoingame($nick)) { .notice $nick $unotheme(null,alreadyplaying) | halt }
      userhost $nick
      if ($unoisban($address($nick,5)) == 1) { .notice $nick You're banned :D | halt }
      if ($readini($unoini(uno.ini),settings,allowreg) == 1) {
        if ($ulist($address($nick,1),uno,1)) { .notice $nick $unotheme(null,playingas) }
        if (!$ulist($address($nick,1),uno,1)) { 
          .notice $nick $unotheme(null,notplayingas)
          .notice $nick $unotheme(null,hregistersuggest)
        }
      }
      setupplayer $nick
      halt
    }
    if ($1 == count) { unocount | halt }
    if ($1 == order || $1 == turns) {
      if ($hget(uno,+turn)) { msg $chan Up: $gettok($unoorder,1,32) Next: $gettok($unoorder,2-,32) $+  }
    }
    if ($1 == !unoremove) {
      if ($unoingame($nick)) { 
        .notice $nick You may not join this current game again.
        hadd uno +nojoin $hget(uno,+nojoin) $address($nick,2)
        unoremplayer $nick
        halt 
      }
    }
    if ($hget(uno,+wild)) { msg $hget(uno,+chan) $unotheme($hget(uno,+wild),wildwait) | halt }
    if ($1 == play) {
      if ($hget(uno,+up) != $nick) { .notice $nick $unotheme($nick,notyourturn) | halt }
      playcard $nick $2-
      halt
    }
    if ($1 == pass) {
      if (!$hget(uno)) { .notice $nick $unotheme($nick,noactivegame) | halt }
      if ($hget(uno,+up) != $nick) { .notice $nick $unotheme(null,notyourturn) | halt }
      if (!%bl4h.unodraw) { .notice $hget(uno,+up) $unotheme(null,mustdraw) | halt }
      goone
      nextplayer
      halt
    }
    if ($1 == draw) {
      if (!$hget(uno)) { .notice $nick $unotheme($nick,noactivegame) | halt }
      if ($hget(uno,+up) != $nick) { .notice $nick $unotheme(null,notyourturn) | halt }
      if (%bl4h.unodraw == 1) { .notice $nick $unotheme(null,passorplay) | halt }
      givecards $hget(uno,+up) 1
      %bl4h.unodraw = 1
      .notice $hget(uno,+up) $unotheme(null,passorplay)
      halt
    }
  }
}
alias unoisban {
  %bl4h.unotmp = 1
  while (%bl4h.unotmp <= $gettok($hget(uno,+nojoin),0,32)) {
    if ($gettok($hget(uno,+nojoin),%bl4h.unotmp,32) iswm $1) { return 1 }
    inc %bl4h.unotmp
  }
  if ($exists($shortfn($scriptdir $+ unobans.txt))) {
    %bl4h.unotmp = 1
    while (%bl4h.unotmp <= $lines($shortfn($scriptdir $+ unobans.txt))) {
      if ($read($shortfn($scriptdir $+ unobans.txt),%bl4h.unotmp) iswm $1) { return 1 }
      inc %bl4h.unotmp
    }
  }
  return 0
}
alias playcard {
  %bl4h.unoply = $hascard($1,$2-)
  if (%bl4h.unoply != 0) {
    hadd uno +card $upper(%bl4h.unoply)
    removecard $hget(uno,+up) $upper(%bl4h.unoply)
    if ($gettok($hget(uno,$1),0,45) == 1) { msg $hget(uno,+chan) $unotheme($hget(uno,+up),hasuno) }
    if (!$gettok($hget(uno,$1),0,45)) {
      if (%bl4h.unoply == W.D.F) { givecards $gettok($unoorder,2,32) 4 }
      if ($gettok(%bl4h.unoply,2,46) == dt) { givecards $gettok($unoorder,2,32) 2 }
      msg $hget(uno,+chan) $unotheme($hget(uno,+up),unowin)
      msg $hget(uno,+chan) Duration: $duration($calc($ctime - $hget(uno,+time)))
      unoscore $hget(uno,+up)
      stopuno $hget(uno,+chan) $hget(uno,+up)
      halt
    }
    if (%bl4h.unoply == W.D.F) {
      hadd uno +wild $hget(uno,+up)
      goone
      givecards $hget(uno,+up) 4
      msg $hget(uno,+chan) $unotheme($hget(uno,+up),drawfour)
      if ($hget(uno,+up) == $me) { msg $hget(uno,+chan) $unobotmad }
      if ($hget(uno,+wild) == $me) {
        hadd uno +card $unobc(WILD)
        msg $hget(uno,+chan) I choose color $gettok($hget(uno,+card),2,46)
        hdel uno +wild
        nextplayer 
        halt
      }
      msg $hget(uno,+chan) $unotheme($hget(uno,+wild),choosecolor)
      halt
    }
    if (%bl4h.unoply == W) {
      hadd uno +wild $hget(uno,+up)
      goone
      if ($hget(uno,+wild) == $me) {
        hadd uno +card $unobc(WILD)
        msg $hget(uno,+chan) I choose color $gettok($hget(uno,+card),2,46)
        hdel uno +wild
        nextplayer 
        halt
      }
      msg $hget(uno,+chan) $unotheme($hget(uno,+wild),choosecolor)
      halt
    }
    if ($gettok(%bl4h.unoply,2,46) == r) {
      if ($hget(uno,+rot) == inc) { hadd uno +rot dec | msg $hget(uno,+chan) $unotheme(null,reverseback) | goto poo }
      if ($hget(uno,+rot) == dec) { hadd uno +rot inc | msg $hget(uno,+chan) $unotheme(null,reversefwd) }
      :poo
      if ($gettok($hget(uno,+players),0,32) == 2) { nextplayer | halt }
    }
    if ($gettok(%bl4h.unoply,2,46) == dt) {
      goone
      msg $hget(uno,+chan) $unotheme($hget(uno,+up),drawtwo)
      if ($hget(uno,+up) == $me) {
        if ($rand(1,3) == 2) { msg $hget(uno,+chan) $unobotmad }
      }
      givecards $hget(uno,+up) 2
    }
    if ($gettok(%bl4h.unoply,2,46) == s) {
      goone
      msg $hget(uno,+chan) $unotheme($hget(uno,+up),skipped)
    }
    goone
    nextplayer
  }
}
alias goone {
  if ($hget(uno,+rot) == inc) {
    if ($gettok($hget(uno,+players),0,32) == $hget(uno,+turn)) { hadd uno +turn 1 }
    else { hinc uno +turn }
  }
  if ($hget(uno,+rot) == dec) {
    if ($hget(uno,+turn) == 1) { hadd uno +turn $gettok($hget(uno,+players),0,32) }
    else { hdec uno +turn }
  }
  hadd uno +up $gettok($hget(uno,+players),$hget(uno,+turn),32)
  unosendn
}
alias unoorder {
  %bl4h.unototal = $gettok($hget(uno,+players),0,32)
  %bl4h.unopos = $hget(uno,+turn)
  %bl4h.unotmp = $hget(uno,+turn)
  %bl4h.unoorder = $gettok($hget(uno,+players),$hget(uno,+turn),32)
  if ($hget(uno,+rot) == inc) { inc %bl4h.unotmp }
  if ($hget(uno,+rot) == dec) { dec %bl4h.unotmp }
  while (%bl4h.unotmp != %bl4h.unopos) {
    if (%bl4h.unotmp != 0) { %bl4h.unoorder = %bl4h.unoorder $gettok($hget(uno,+players),%bl4h.unotmp,32) }
    if ($hget(uno,+rot) == inc) { inc %bl4h.unotmp }
    if ($hget(uno,+rot) == dec) { dec %bl4h.unotmp }
    if (%bl4h.unotmp <= 0) { 
      if ($hget(uno,+rot) == inc) { %bl4h.unotmp = 1 }
      if ($hget(uno,+rot) == dec) { %bl4h.unotmp = %bl4h.unototal }
    }
    if (%bl4h.unotmp > %bl4h.unototal) { %bl4h.unotmp = 1 }
  }
  return %bl4h.unoorder
}
alias removecard {
  unset %bl4h.unohi
  unset %bl4h.unopoo                     
  %bl4h.unotmp = 1
  %bl4h.unocards = $hget(uno,$1)
  %bl4h.unotot = $gettok(%bl4h.unocards,0,45)
  while (%bl4h.unotot >= %bl4h.unotmp) {
    if (!%bl4h.unohi && $gettok(%bl4h.unocards,%bl4h.unotmp,45) == $2) { set %bl4h.unohi 1 | inc %bl4h.unotmp }
    else { %bl4h.unopoo = %bl4h.unopoo $+ - $+ $gettok(%bl4h.unocards,%bl4h.unotmp,45) | inc %bl4h.unotmp } 
  }
  hadd uno $1 %bl4h.unopoo
}
alias unobotthink {
  %bl4h.unobotthink = *evil-grin*.. You'll-pay-for-that... woooot.. Dum-de-dum.. hehe.. Oh-boy.. hrm.. Lets-see-here..  uh.. Hmm,-you're-good.. Decisions-decisions.. Ahah!-... Eeny-Meeny-Miney-Moe.. LOL.. Oh-dear.. Errr.. Ah-me-brain!-...
  return $replace($gettok(%bl4h.unobotthink,$rand(1,$gettok(%bl4h.unobotthink,0,32)),32),$chr(45),$chr(32))
}
alias unobotmad {
  %bl4h.unobotthink = ARRGH! This-is-getting-annoying! RATS! *sigh* You're-getting-on-my-nerves->:/ dfasdfjhweuryaeuwysadjkf I'm-steamed. BAH
  return $replace($gettok(%bl4h.unobotthink,$rand(1,$gettok(%bl4h.unobotthink,0,32)),32),$chr(45),$chr(32))
}
alias unosendn {
  if ($readini($unoini(uno.ini),settings,idlewarn) > 0) {
    if (!$1) { .timerunoidle 1 $readini($unoini(uno.ini),settings,idlewarn) /unosendn warn }
    if ($1 == warn) { 
      .notice $hget(uno,+up) $unotheme($readini($unoini(uno.ini),settings,idleremove),idlewarnplayer)
      .timerunoidle 1 $readini($unoini(uno.ini),settings,idleremove) /unoremplayer $hget(uno,+up)
    } 
  }
}
alias nextplayer { 
  unset %bl4h.unodraw
  msg $hget(uno,+chan)  $+ $hget(uno,+up) up: $drawcards($hget(uno,+card)) 
  if ($hget(uno,+up) == $me) {
    unobotbrain
    return
  }
  if ($gettok($hget(uno,+players),0,32) > 2) { .notice $hget(uno,+up) Next: $replace($gettok($unoorder,2-,32),$chr(32),$chr(44) $chr(32)) }
  .notice $hget(uno,+up) $drawcards($hget(uno,$hget(uno,+up)))
}

alias unobotplay {
  if (!%bl4h.unohold) {
    %bl4h.unohold = 1
    if ($rand(1,4) == 2) { msg $hget(uno,+chan) $unobotthink }
    .timer 1 $1 unobotplay $2-
    halt
  }
  unset %bl4h.unohold
  msg $hget(uno,+chan) play $replace($2-,$chr(46),$chr(32))
  playcard $me $2-
  halt
}
alias unobc {
  if ($1 == c) { return $count($hget(uno,$me),$2 $+ .) }
  if ($1 == n) { return $count($hget(uno,$me),. $+ $2) }
  if ($1 == r) { 
    %bl4h.unoinc = 1
    %bl4h.unocrds = $hget(uno,$me)
    while ($gettok(%bl4h.unocrds,0,45) >= %bl4h.unoinc) {
      if ($gettok($gettok(%bl4h.unocrds,%bl4h.unoinc,45),1,46) == $2) { return $gettok(%bl4h.unocrds,%bl4h.unoinc,45) }
      inc %bl4h.unoinc
    }
  }
  if ($1 == wild) {
    %bl4h.unocol = $iif($count($hget(uno,$me),G.) > $count($hget(uno,$me),Y.),G $count($hget(uno,$me),G.),Y $count($hget(uno,$me),Y.))
    %bl4h.unocol = $iif($gettok(%bl4h.unocol,2,32) > $count($hget(uno,$me),B.),%bl4h.unocol,B $count($hget(uno,$me),B.))
    %bl4h.unocol = $iif($gettok(%bl4h.unocol,2,32) > $count($hget(uno,$me),R.),%bl4h.unocol,R $count($hget(uno,$me),R.))
    return $gettok(%bl4h.unocol,1,32) $+ . $+ $replace($gettok(%bl4h.unocol,1,32),r,RED,y,YELLOW,b,BLUE,g,GREEN)
  }
  if ($1 == best) {
    %bl4h.unoinc = 1
    %bl4h.unocrds = $hget(uno,$me)
    %bl4h.unowow = 0 0
    while ($gettok(%bl4h.unocrds,0,45) >= %bl4h.unoinc) {
      if ($gettok($gettok(%bl4h.unocrds,%bl4h.unoinc,45),2,46) == $2) {
        if ($count($hget(uno,$me),$gettok($gettok(%bl4h.unocrds,%bl4h.unoinc,45),1,46) $+ .) > $gettok(%bl4h.unowow,2,32)) { 
          %bl4h.unowow = $gettok(%bl4h.unocrds,%bl4h.unoinc,45) $count($hget(uno,$me),$gettok($gettok(%bl4h.unocrds,%bl4h.unoinc,45),1,46) $+ .)
        }
      }
      inc %bl4h.unoinc
    }
    return $gettok(%bl4h.unowow,1,32)
  }
}
alias unobotbrain {
  if ($unobc(c,$gettok($hget(uno,+card),1,46)) > 0) {
    if ($count($hget(uno,unobot),$gettok($hget(uno,+card),1,46) $+ .S) > 0) {
      unobotplay $rand(2,5) play $gettok($hget(uno,+card),1,46) S
      halt
    }
    if ($count($hget(uno,unobot),$gettok($hget(uno,+card),1,46) $+ .DT) > 0) {
      unobotplay $rand(2,5) play $gettok($hget(uno,+card),1,46) DT
      halt
    }
    unobotplay $rand(2,5) play $unobc(r,$gettok($hget(uno,+card),1,46))
    halt
  }
  if ($unobc(n,$gettok($hget(uno,+card),2,46)) > 0) {
    unobotplay $rand(2,5) play $replace($unobc(best,$gettok($hget(uno,+card),2,46)),$chr(46),$chr(32))
    halt
  }
  if ($count($hget(uno,$me),W) > 0) {
    unobotplay $rand(2,5) play $iif($count($hget(uno,$me),W.D) > 0,WD4,W)
    halt
  }
  if (%bl4h.unodraw != 1) {
    describe $hget(uno,+chan) draws a card
    givecards $hget(uno,+up) 1
    set %bl4h.unodraw 1
    .timer 1 1 unobotbrain
    halt
  }
  if ($rand(1,5) == 2) { msg $hget(uno,+chan) $unobotmad }
  goone
  nextplayer
}
alias hascard {
  %bl4h.unoinc = 1
  %bl4h.unocrds = $hget(uno,$1)
  %bl4h.unocart = $replace($2-,w,W,wild,W,wd4,W.D.F,wdf,W.D.F,w d 4,W.D.F,w d f,W.D.F)
  %bl4h.unocart = $replace(%bl4h.unocart,$chr(32),$chr(46))
  while ($gettok(%bl4h.unocrds,0,45) >= %bl4h.unoinc) {
    if ($gettok(%bl4h.unocrds,%bl4h.unoinc,45) == %bl4h.unocart) { 
      if ($gettok(%bl4h.unocart,1,46) == $gettok($hget(uno,+card),1,46) || $gettok(%bl4h.unocart,2,46) == $gettok($hget(uno,+card),2,46) || %bl4h.unocart == W || %bl4h.unocart == W.D.F) {
        return %bl4h.unocart
      }
    }
    inc %bl4h.unoinc
  }
  return 0
}
alias makedeck {
  hmake unocards 500
  %bl4h.unotmp = 1
  %bl4h.unotmp2 = 1
  %bl4h.unotimes = 1
  while (%bl4h.unotmp <= 9) {
    if (%bl4h.unotmp2 > 4) { break }
    hadd unocards $gettok(G R B Y,%bl4h.unotmp2,32) $+ . $+ %bl4h.unotmp 2
    inc %bl4h.unotmp
    if (%bl4h.unotmp > 9) { set %bl4h.unotmp 1 | inc %bl4h.unotmp2 }
  }
  hadd unocards R.0 1
  hadd unocards G.0 1
  hadd unocards B.0 1
  hadd unocards Y.0 1
  hadd unocards R.DT 2
  hadd unocards G.DT 2
  hadd unocards B.DT 2
  hadd unocards Y.DT 2
  hadd unocards G.R 2
  hadd unocards R.R 2
  hadd unocards B.R 2
  hadd unocards Y.R 2
  hadd unocards G.S 2
  hadd unocards R.S 2
  hadd unocards Y.S 2
  hadd unocards B.S 2
  hadd unocards W.D.F 4
  hadd unocards W 4
}
alias stopuno {
  .timeruno* off
  msg $hget(uno,+chan) $unotheme($2,stopuno)
  unset %bl4h.uno*
  hfree -w uno*
}
alias startuno {
  unset %bl4h.uno*
  hfree -w uno*
  hmake uno
  hadd uno +started $1
  hadd uno +turn 1
  hadd uno +chan $2
  hadd uno +rot inc
  hadd uno +color $readini($unoini(uno.ini),settings,color)
  if ($3 == 1) { hadd uno +bot 1 }
  makedeck
  msg $2 $unotheme($1,unostart) $iif($hget(uno,+bot),$unotheme(null,unostartbot),)
  .timeruno 1 30 begingame $2
}
alias begingame {
  if (!$gettok($hget(uno,+players),0,32)) { stopuno $1 $me | halt }
  if ($gettok($hget(uno,+players),0,32) == 1) { hadd uno +bot 1 }
  if ($hget(uno,+bot) == 1) { setupplayer $me }
  if ($gettok($hget(uno,+players),0,32) >= 2) {
    msg $hget(uno,+chan) Playing this round: $hget(uno,+players)
    %bl4h.unofirst = $hfind(unocards, *, $rand(1,$hfind(unocards, *, 0, w)), w)
  }
  ;er remind me to fix this below
  if ($gettok(%bl4h.unofirst,1,46) == W) { 
    hdec unocards %bl4h.unofirst
    %bl4h.unofirst = r.RED
    goto eh
  }
  hdec unocards %bl4h.unofirst
  :eh
  hadd uno +card %bl4h.unofirst
  hadd uno +time $ctime
  if ($hget(unocards,%bl4h.unofirst) == 0) { hdel unocards %bl4h.unofirst }
  hadd uno +up $gettok($hget(uno,+players),$hget(uno,+turn),32)
  nextplayer
}
alias setupplayer {
  if ($hget(uno,$1)) { halt }
  hadd uno +players $hget(uno,+players) $1
  hadd uno $1
  msg $hget(uno,+chan) $unotheme($1,willplay)
  givecards $1 7
}
alias givecards {
  if ($hget(uno,+up) == $1) { unset %bl4h.unodraw }
  %bl4h.unotmp = 1
  unset %bl4h.unocard*
  while (%bl4h.unotmp <= $2) {
    if (!$hget(unocards,0).item) { msg $hget(uno,+chan) $unotheme(null,shuffledeck) | hfree unocards | makedeck }
    %bl4h.unocard = $hfind(unocards, *, $rand(1,$hfind(unocards, *, 0, w)), w)
    %bl4h.unocardz = %bl4h.unocardz $+ - $+ %bl4h.unocard
    hdec unocards %bl4h.unocard 
    if ($hget(unocards,%bl4h.unocard) == 0) { hdel unocards %bl4h.unocard }
    inc %bl4h.unotmp
  }
  hadd uno $1 $hget(uno,$1) $+ %bl4h.unocardz
  if ($1 == $me) { return }
  .notice $1 You drew: $drawcards(%bl4h.unocardz)
}
alias drawcards {
  unset %bl4h.unofix.*
  unset %bl4h.unofix
  %bl4h.unototcar = $gettok($1-,0,45)
  %bl4h.unotmpp = 1
  while (%bl4h.unotmpp <= %bl4h.unototcar) {
    if ($left($gettok($1-,%bl4h.unotmpp,45),1) == W) {
      if ($gettok($1-,%bl4h.unotmpp,45) == W.D.F) {
        if ($hget(uno,+color) == 1) {
          %bl4h.unofix = %bl4h.unofix 0[8,1W12D0440]
        }
        if ($hget(uno,+color) == 0) {
          %bl4h.unofix = %bl4h.unofix [W D F]
        }
        inc %bl4h.unotmpp 
      }
      if ($gettok($1-,%bl4h.unotmpp,45) == W) {
        if ($hget(uno,+color) == 1) {
          %bl4h.unofix = %bl4h.unofix 0[8,1W12I04L9D0]
        }
        if ($hget(uno,+color) == 0) {
          %bl4h.unofix = %bl4h.unofix [WILD]
        }
        inc %bl4h.unotmpp 
      }
    }
    else {
      if ($hget(uno,+color) == 1) {
        if ($left($gettok($1-,%bl4h.unotmpp,45),1) == r) { %bl4h.unofix.r = %bl4h.unofix.r $+ 0[4,01 $+ $chr(32) $+ $gettok($gettok($1-,%bl4h.unotmpp,45),2,46) $+ $chr(32) $+ 0] }
        if ($left($gettok($1-,%bl4h.unotmpp,45),1) == b) { %bl4h.unofix.b = %bl4h.unofix.b $+ 0[12,01 $+ $chr(32) $+ $gettok($gettok($1-,%bl4h.unotmpp,45),2,46) $+ $chr(32) $+ 0] }
        if ($left($gettok($1-,%bl4h.unotmpp,45),1) == y) { %bl4h.unofix.y = %bl4h.unofix.y $+ 0[8,01 $+ $chr(32) $+ $gettok($gettok($1-,%bl4h.unotmpp,45),2,46) $+ $chr(32) $+ 0] }
        if ($left($gettok($1-,%bl4h.unotmpp,45),1) == g) { %bl4h.unofix.g = %bl4h.unofix.g $+ 0[9,01 $+ $chr(32) $+ $gettok($gettok($1-,%bl4h.unotmpp,45),2,46) $+ $chr(32) $+ 0] }
      }
      if ($hget(uno,+color) == 0) {
        %bl4h.unofix = %bl4h.unofix $+ $chr(91) $+ $left($gettok($1-,%bl4h.unotmpp,45),1) $+ $chr(32) $+ $gettok($gettok($1-,%bl4h.unotmpp,45),2,46) $+ $chr(93)
      }
      inc %bl4h.unotmpp 
    }
  }
  %bl4h.unofix = %bl4h.unofix $+ %bl4h.unofix.r $+ %bl4h.unofix.b $+ %bl4h.unofix.y $+ %bl4h.unofix.g
  return %bl4h.unofix
}
alias unoscore {
  %bl4h.unoscore = 0
  %bl4h.unotmp = 1
  while ($gettok($hget(uno,+players),0,32) >= %bl4h.unotmp) {
    if ($gettok($hget(uno,+players),%bl4h.unotmp,32) == $1) { inc %bl4h.unotmp }
    %bl4h.unotmp2 = 1
    while (%bl4h.unotmp2 <= $gettok($hget(uno,$gettok($hget(uno,+players),%bl4h.unotmp,32)),0,45)) {
      %bl4h.unocrd = $gettok($gettok($hget(uno,$gettok($hget(uno,+players),%bl4h.unotmp,32)),%bl4h.unotmp2,45),2,46)
      %bl4h.unocrd2 = $gettok($gettok($hget(uno,$gettok($hget(uno,+players),%bl4h.unotmp,32)),%bl4h.unotmp2,45),1,46)
      if (%bl4h.unocrd2 == W) { inc %bl4h.unoscore 50 }
      if (%bl4h.unocrd == S) { inc %bl4h.unoscore 20 }
      if (%bl4h.unocrd == R) { inc %bl4h.unoscore 20 }
      if (%bl4h.unocrd == DT) { inc %bl4h.unoscore 20 }
      if (%bl4h.unocrd isnum) { inc %bl4h.unoscore %bl4h.unocrd }
      inc %bl4h.unotmp2
    }
    inc %bl4h.unotmp
  }
  %bl4h.unotmp3 = 1
  while ($gettok($hget(uno,+players),0,32) >= %bl4h.unotmp3) {
    if ($gettok($hget(uno,+players),%bl4h.unotmp3,32) == $1) { inc %bl4h.unotmp3 }
    else {
      if ($gettok($hget(uno,+players),%bl4h.unotmp3,32) == $me) { goto lame }
      if ($ulist($address($gettok($hget(uno,+players),%bl4h.unotmp3,32),1),uno,1)) {
        if ($readini($unoini(uno.ini),settings,allowreg) == 1) {
          %bl4h.unosloss = $calc($readini($unoini(uno.ini),$ulist($address($gettok($hget(uno,+players),%bl4h.unotmp3,32),1),uno,1).info,loss) + 1)
          %bl4h.unoswin = $readini($unoini(uno.ini),$ulist($address($gettok($hget(uno,+players),%bl4h.unotmp3,32),1),uno,1).info,wins)
          writeini $unoini(uno.ini) $ulist($address($gettok($hget(uno,+players),%bl4h.unotmp3,32),1),uno,1).info loss %bl4h.unosloss
          writeini $unoini(uno.ini) $ulist($address($gettok($hget(uno,+players),%bl4h.unotmp3,32),1),uno,1).info totalgames $calc(%bl4h.unosloss + %bl4h.unoswin)
          writeini $unoini(uno.ini) $ulist($address($gettok($hget(uno,+players),%bl4h.unotmp3,32),1),uno,1).info lastgame $ctime
        }      
      }
      :lame
      msg $hget(uno,+chan) $gettok($hget(uno,+players),%bl4h.unotmp3,32) $+ : $drawcards($hget(uno,$gettok($hget(uno,+players),%bl4h.unotmp3,32)))
      inc %bl4h.unotmp3
    }
  }
  msg $hget(uno,+chan) $unotheme($1 %bl4h.unoscore,endscore)
  if ($1 == $me) { parseunotop | goto skip }
  if ($readini($unoini(uno.ini),settings,allowreg) == 1) {
    if ($ulist($address($1,1),uno,1)) {
      %bl4h.unoscoretot = $calc($readini($unoini(uno.ini),$ulist($address($1,1),uno,1).info,score) + %bl4h.unoscore)
      %bl4h.unoscorewins = $calc($readini($unoini(uno.ini),$ulist($address($1,1),uno,1).info,wins) + 1)
      %bl4h.unoscoreloss = $readini($unoini(uno.ini),$ulist($address($1,1),uno,1).info,loss)
      writeini $unoini(uno.ini) $ulist($address($1,1),uno,1).info totalgames $calc(%bl4h.unoscorewins + %bl4h.unoscoreloss)
      writeini $unoini(uno.ini) $ulist($address($1,1),uno,1).info score %bl4h.unoscoretot
      writeini $unoini(uno.ini) $ulist($address($1,1),uno,1).info wins %bl4h.unoscorewins
      writeini $unoini(uno.ini) $ulist($address($1,1),uno,1).info lastgame $ctime
      parseunotop
      msg $hget(uno,+chan) $1 ( $+ $ulist($address($1,1),uno,1).info $+ ):  $+ %bl4h.unoscoretot points $+  < $+ %bl4h.unoscorewins wins / %bl4h.unoscoreloss losses> Place:04 $ord($readini($unoini(uno.ini),$ulist($address($1,1),uno,1).info,place))
    }
    else { .notice $1 $unotheme($1,mustreg) }
  }
  :skip
}
alias unocount {
  unset %bl4h.unocount
  %bl4h.unoscore = 0
  %bl4h.unotmp = 1
  while ($gettok($hget(uno,+players),0,32) >= %bl4h.unotmp) {
    %bl4h.unotmp2 = 1
    %bl4h.unonick = $gettok($hget(uno,+players),%bl4h.unotmp,32)
    while (%bl4h.unotmp2 <= $gettok($hget(uno,$gettok($hget(uno,+players),%bl4h.unotmp,32)),0,45)) {
      inc %bl4h.unotmp2
    }
    set %bl4h.unocount %bl4h.unocount %bl4h.unonick $+ : $calc(%bl4h.unotmp2 - 1)
    inc %bl4h.unotmp
  }
  msg $hget(uno,+chan) %bl4h.unocount
}
alias unostat {
  if ($ulist($address($2,1),uno,1).info) { %bl4h.unotmp = $ulist($address($2,1),uno,1).info }
  if (!$ulist($address($2,1),uno,1).info) { %bl4h.unotmp = $2 }
  if ($readini($unoini(uno.ini),%bl4h.unotmp,totalgames)) {
    if ($readini($unoini(uno.ini),%bl4h.unotmp,place) == 1) { msg $1 %bl4h.unotmp is $1 $+ 's 8U12N4O master! }
    if ($readini($unoini(uno.ini),%bl4h.unotmp,place) == 2 || $readini($unoini(uno.ini),%bl4h.unotmp,place) == 3) { msg $1 %bl4h.unotmp is a top 3 player! }
    msg $1  $+ %bl4h.unotmp $+ :  $readini($unoini(uno.ini),%bl4h.unotmp,score) $+  < $+ $readini($unoini(uno.ini),%bl4h.unotmp,wins) $+ W/ $+ $readini($unoini(uno.ini),%bl4h.unotmp,loss) $+ L $+ > Place:4 $ord($readini($unoini(uno.ini),%bl4h.unotmp,place))
  }
  else { msg $1  $+ $2 $+  no such user/no games played }
}
alias unohelp {
  if ($2 == pub && !$3) { 
    .notice $1 For official uno rules visit: http://hometown.aol.com/babso00001/unorules.html
    .notice $1 Use /notice $me unohelp for private commands.
    .notice $1 Commands: !uno , !unoremove , !unoend , join , play , draw , pass , order , count , !unostat , !unotop10, !unoabout
    .notice $1 Type !unohelp <command> for help on a specific command
    return
  }
  if ($2 == priv && !$3) {
    .notice $1 You must register a username to have your scores saved.
    .notice $1 Commands: unoregister , unologin , unochpass , unologout
    .notice $1 Use unohelp <command> for help on a specific command
    return
  }
  if ($readini($unoini(unohelp.ini),help,$3) != $null) { .notice $nick $readini($unoini(unohelp.ini),help,$3) }
  else { .notice $nick No help on that command }
}
alias unoingame {
  %bl4h.unod = 1
  while ($gettok($hget(uno,+players),0,32) >= %bl4h.unod) {
    if ($gettok($hget(uno,+players),%bl4h.unod,32) == $1) { return 1 }
    inc %bl4h.unod
  }
  return 0
}
alias unohtmlscore {
  parseunotop
  %bl4h.unotmp = 1
  write -c unotop10.html
  write unotop10.html <html>
  write unotop10.html <!-- Generated by unobot $unover ( http://shady.nu ) -->
  write unotop10.html <head><title>UNO! Top 10 players</title></head>
  write unotop10.html <STYLE id=default type=text/css> .tabel $chr(123) BORDER-RIGHT: $readini($unoini(uno.ini),settings,htmlborder) 2px solid; BORDER-TOP: $readini($unoini(uno.ini),settings,htmlborder) 2px solid; BORDER-LEFT: $readini($unoini(uno.ini),settings,htmlborder) 2px solid; BORDER-BOTTOM: $readini($unoini(uno.ini),settings,htmlborder) 2px solid $chr(125) 
  write unotop10.html .tdb $chr(123) BORDER-BOTTOM: $readini($unoini(uno.ini),settings,htmlborder) 2px solid; BORDER-RIGHT: $readini($unoini(uno.ini),settings,htmlborder) 2px solid; $chr(125) </style>
  write unotop10.html <body bgcolor=" $+ $readini($unoini(uno.ini),settings,htmlbackground) $+ " text=" $+ $readini($unoini(uno.ini),settings,htmltext) $+ ">
  write unotop10.html <center><table width="70%" class=tabel><tr><td class=tdb>Place</td><td class=tdb>User</td><td class=tdb>Wins</td><td class=tdb>Loss</td><td class=tdb>Score</td></tr>
  if ($readini($unoini(uno.ini),settings,top10)) {
    while (%bl4h.unotmp <= $gettok($readini($unoini(uno.ini),settings,top10),0,32)) {
      %bl4h.unotmpu = $gettok($readini($unoini(uno.ini),settings,top10),%bl4h.unotmp,32)
      write unotop10.html <tr><td> $ord(%bl4h.unotmp) </td><td> %bl4h.unotmpu </td>
      write unotop10.html <td> $readini($unoini(uno.ini),%bl4h.unotmpu,wins) </td><td> $readini($unoini(uno.ini),%bl4h.unotmpu,loss) </td>
      write unotop10.html <td><b> $readini($unoini(uno.ini),%bl4h.unotmpu,score) </b></td></tr>
      inc %bl4h.unotmp
    }
    write unotop10.html </table><br><br><a href="http://shady.nu/?x=mirc">Unobot $unover </a></center></html>
    run unotop10.html
  }
}
alias parseunotop {
  %bl4h.parsetmp = 1
  %bl4h.parsetotal = $ini($unoini(uno.ini),0)
  if ($ini($unoini(uno.ini),0) > 101 && $hget(uno,+chan)) { msg $hget(uno,+chan) Calculating... }
  while (%bl4h.parsetmp <= %bl4h.parsetotal) {
    window -n @sorting
    if ($ini($unoini(uno.ini),%bl4h.parsetmp) == settings) { goto skip }
    if ($readini($unoini(uno.ini),settings,topcalc) == 1) { aline @sorting $calc($readini($unoini(uno.ini),$ini($unoini(uno.ini),%bl4h.parsetmp),score) / $readini($unoini(uno.ini),$ini($unoini(uno.ini),%bl4h.parsetmp),totalgames)) $ini($unoini(uno.ini),%bl4h.parsetmp) }
    if ($readini($unoini(uno.ini),settings,topcalc) == 2) { aline @sorting $readini($unoini(uno.ini),$ini($unoini(uno.ini),%bl4h.parsetmp),score) $ini($unoini(uno.ini),%bl4h.parsetmp) }
    :skip
    inc %bl4h.parsetmp
  }
  filter -eutc 1 32 @sorting @sorting
  %bl4h.parsetmp = 1
  if ($readini($unoini(uno.ini),settings,top10)) { remini $unoini(uno.ini) settings top10 }
  while (%bl4h.parsetmp <= $line(@sorting,0)) {
    writeini $unoini(uno.ini) $gettok($line(@sorting,%bl4h.parsetmp),2,32) place %bl4h.parsetmp
    if (%bl4h.parsetmp <= 10) { writeini $unoini(uno.ini) settings top10 $readini($unoini(uno.ini),settings,top10) $gettok($line(@sorting,%bl4h.parsetmp),2,32) }
    :error
    reseterror
    inc %bl4h.parsetmp
  }
  close -@ @sorting
}
on *:NICK:{
  if ($unoingame($nick)) {
    hadd uno +players $hget(uno,+players) $newnick
    hadd uno $newnick $hget(uno,$nick)
    if ($hget(uno,+up) == $nick) { hadd uno +up $newnick }
    if ($hget(uno,+wild) == $nick) { hadd uno +wild $newnick }
    if ($hget(uno,+started) == $nick) { hadd uno +started $newnick }
    unodelplayer $nick
  }
}
on *:JOIN:#:{
  if ($unoingame($nick) && $chan == $hget(uno,+chan)) {
    msg $hget(uno,+chan) WB $nick $+ , Game is still on! Its $hget(uno,+up) $+ 's turn.
  }
}
alias unodelplayer {
  unset %bl4h.unop
  %bl4h.unol = 1
  %bl4h.unone = $gettok($unoorder,2,32)
  while (%bl4h.unol <= $gettok($hget(uno,+players),0,32)) {
    if ($gettok($hget(uno,+players),%bl4h.unol,32) != $1) { %bl4h.unop = %bl4h.unop $gettok($hget(uno,+players),%bl4h.unol,32) }
    inc %bl4h.unol
  }
  hdel uno $1
  hadd uno +players %bl4h.unop
  if ($hget(uno,+wild) == $1) { hdel uno +wild | hadd uno +card r.RED }
  if ($hget(uno,+started) == $1) { hadd uno +started $gettok($hget(uno,+players),1,32) }
  if ($hget(uno,+up) == $1) {
    hadd uno +up %bl4h.unone
    hadd uno +turn $findtok($hget(uno,+players),%bl4h.unone,1,32)
    nextplayer 
  }
}
alias unoremplayer {
  if ($gettok($hget(uno,+players),0,32) > 2) {
    unodelplayer $1
    msg $hget(uno,+chan) $1 has been removed from the game!
  }
  else { 
    stopuno $hget(uno,+chan) $1 
  }
}
on *:QUIT:{
  if ($unoingame($nick)) {
    unoremplayer $nick
  }
}
dialog unouser {
  title "Uno users"
  size -1 -1 142 126
  option dbu
  list 1, 6 10 50 88, size vsbar
  ;button "ADD", 2, 6 104 23 12
  box "Group Box", 3, 2 2 58 120
  button "DEL", 4, 34 104 21 12
  edit "", 5, 88 12 50 10
  edit "", 6, 88 28 22 10
  edit "", 7, 116 28 22 10
  text "Pass:", 8, 66 14 19 8
  text "W/L", 9, 66 30 19 8
  button "Apply change", 10, 94 66 37 12
  edit "", 11, 88 44 50 10
  text "Score:", 12, 66 46 21 8
}
alias unodref {
  %tmp = 1
  did -r unouser 1
  while (%tmp <= $ini($unoini(uno.ini),0)) {
    if ($ini($unoini(uno.ini),%tmp) != settings) { did -a unouser 1 $ini($unoini(uno.ini),%tmp) }
    inc %tmp
  }
  if (%tmp <= 2) { 
    did -a unouser 1 [No Users yet]
    did -b unouser 10,4
  }
}
alias unodiag {
  if ($dialog($1)) { dialog -v $1 | halt }
  dialog -m $1 $1
}
alias unohostcheck {
  %tmp2 = $address($1,1)
  %tmp = 1
  while (%tmp <= $ini($unoini(uno.ini),0)) {
    if ($readini($unoini(uno.ini),$ini($unoini(uno.ini),%tmp),redad) iswm %tmp2) { return $ini($unoini(uno.ini),%tmp) }
    inc %tmp
  }
  return 0
}
dialog unothemeedit {
  title "Unobot Theme Editor"
  size -1 -1 196 68
  option dbu
  list 1, 4 4 54 44, size vsbar
  edit "", 2, 66 10 120 10, autohs
  combo 3, 2 52 60 50, drop
  button "Save", 4, 70 28 37 12, flat
  button "Preview", 5, 108 28 37 12, flat
  button "Convert", 6, 146 28 37 12, flat
}
on *:DIALOG:*:*:*:{
  if ($dname == unothemeedit) {
    if ($devent == init) {
      %tmp = 1
      while ($ini($unoini(unotheme.ini),0) >= %tmp) {
        did -a unothemeedit 3 $ini($unoini(unotheme.ini),%tmp)
        inc %tmp
      }

    }
    if ($devent = sclick) {
      if ($did == 3) { 
        if ($did(3).seltext) {
          did -r unothemeedit 1
          %tmp = 1
          while ($ini($unoini(unotheme.ini),$did(3).seltext,0) >= %tmp) {
            did -a unothemeedit 1 $ini($unoini(unotheme.ini),$did(3).seltext,%tmp)
            inc %tmp
          }
        }
      }
      if ($did = 1 && $did(1).seltext) {
        did -ra unothemeedit 2 $readini($unoini(unotheme.ini),$did(3).seltext,$did(1).seltext)
      }
      if ($did = 5 && $did(1).seltext && $did(2).text) {
        if (!$window(@prev)) { window @prev }
        aline -a @prev $unotheme(TEST1 TEST2 TEST3 TEST4,$did(1).seltext)
      }
    }
  }
  if ($dname == unoman) {
    if ($devent == sclick || $devent == init) {
      if ($did == 11) { unodiag unouser }
      if ($did == 13) { unodiag unoabout }
      if ($did == 12) { unodiag unomisc }
      if ($did == 3) { writeini $unoini(uno.ini) settings enabled 1 }
      if ($did == 4) { writeini $unoini(uno.ini) settings enabled 0 }
      if ($did == 6) { writeini $unoini(uno.ini) settings color 1 }
      if ($did == 7) { writeini $unoini(uno.ini) settings color 0 }
      if ($did == 9) { writeini $unoini(uno.ini) settings allowreg 1 }
      if ($did == 10) { writeini $unoini(uno.ini) settings allowreg 0 }
      if ($readini($unoini(uno.ini),settings,enabled) == 1) { did -e unoman 4 | did -b unoman 3 }
      else { did -e unoman 3 | did -b unoman 4 }
      if ($readini($unoini(uno.ini),settings,allowreg) == 1) { did -e unoman 10 | did -b unoman 9 }
      else { did -e unoman 9 | did -b unoman 10 }
      if ($readini($unoini(uno.ini),settings,color) == 1) { did -e unoman 7 | did -b unoman 6 }
      else { did -e unoman 6 | did -b unoman 7 }
    }
  }
  if ($dname == unoabout) {
    if ($devent == sclick) {
      if ($did == 3) { run http://shady.nu }
      if ($did == 4) { run mailto:bl4h@shady.nu }
    }
  }
  if ($dname == unouser) {
    if ($devent == init) {
      unodref
    }
    if ($devent == sclick) {
      if ($did == 1) {
        did -r unouser 5,6,7,11
        did -a unouser 5 $readini($unoini(uno.ini),$did(1).seltext,password)
        did -a unouser 6 $readini($unoini(uno.ini),$did(1).seltext,wins)
        did -a unouser 7 $readini($unoini(uno.ini),$did(1).seltext,loss)
        did -a unouser 11 $readini($unoini(uno.ini),$did(1).seltext,score)
      }
      if ($did == 10) {
        if (!$did(1).seltext) { %tmp = $input(No username selected!,o,Fail) | halt }
        if ($did(5).text) { writeini $unoini(uno.ini) $did(1).seltext password $did(5).text }
        if ($did(6).text isnum) { writeini $unoini(uno.ini) $did(1).seltext wins $did(6).text }
        if ($did(7).text isnum) { writeini $unoini(uno.ini) $did(1).seltext loss $did(7).text }
        if ($did(11).text isnum) { writeini $unoini(uno.ini) $did(1).seltext score $did(11).text }
        %tmp = $input(Applied,o,Applied)
      }
      if ($did = 4 && $did(1).seltext) {
        %tmp = $?!="DELETE $did(1).seltext $+ ?"
        if (%tmp == $true) { remini $unoini(uno.ini) $did(1).seltext }     
        unodref
      }
    }
  }
  if ($dname == unomisc) {
    if ($devent == init) {
      unset %bl4h.flood*
      did -i unomisc 5,8 1 ignore
      did -i unomisc 5,8 2 kick
      did -i unomisc 5,8 3 ban+kick
      did -i unomisc 12 1 Score / games played
      did -i unomisc 12 2 Score only
      did -c unomisc 12 $readini($unoini(uno.ini),settings,topcalc)
      did -c unomisc 5 $iif($readini($unoini(uno.ini),settings,floodpunishmsg),$readini($unoini(uno.ini),settings,floodpunishmsg),1)
      did -c unomisc 8 $iif($readini($unoini(uno.ini),settings,floodpunishrep),$readini($unoini(uno.ini),settings,floodpunishrep),1)
      did -a unomisc 2 $iif($readini($unoini(uno.ini),settings,floodmsgs),$readini($unoini(uno.ini),settings,floodmsgs),5)
      did -a unomisc 10 $iif($readini($unoini(uno.ini),settings,floodreps),$readini($unoini(uno.ini),settings,floodreps),3)
      did -a unomisc 17 $iif($readini($unoini(uno.ini),settings,idlewarn),$readini($unoini(uno.ini),settings,idlewarn),60)
      did -a unomisc 19 $iif($readini($unoini(uno.ini),settings,idleremove),$readini($unoini(uno.ini),settings,idleremove),120)
      did -a unomisc 22 $iif($readini($unoini(uno.ini),settings,floodban),$readini($unoini(uno.ini),settings,floodban),30)   
      if ($readini($unoini(uno.ini),settings,floodenabled) != $null) {
        if ($readini($unoini(uno.ini),settings,floodenabled) == 1) { did -c unomisc 24 }
        else { did -b unomisc 5,8,2,10 }   
      }
    }
    if ($devent == sclick) {
      if ($did == 24) {
        if ($did(unomisc,24).state == 1) { writeini $unoini(uno.ini) settings floodenabled 1 | did -e unomisc 5,8,2,10 }
        else { writeini $unoini(uno.ini) settings floodenabled 0 | did -b unomisc 5,8,2,10 }
      }
      if ($did == 21) {
        if ($did(unomisc,2).text isnum && $did(unomisc,10).text isnum && $did(unomisc,17).text isnum && $did(unomisc,19).text isnum && $did(unomisc,22).text isnum) {
          writeini $unoini(uno.ini) settings floodpunishmsg $did(unomisc,5).sel
          writeini $unoini(uno.ini) settings floodpunishrep $did(unomisc,8).sel
          writeini $unoini(uno.ini) settings topcalc $did(unomisc,12).sel
          writeini $unoini(uno.ini) settings floodmsgs $did(unomisc,2).text
          writeini $unoini(uno.ini) settings floodreps $did(unomisc,10).text
          writeini $unoini(uno.ini) settings idlewarn $did(unomisc,17).text
          writeini $unoini(uno.ini) settings idleremove $did(unomisc,19).text
          writeini $unoini(uno.ini) settings floodban $did(unomisc,22).text
          %tmp = $input(Saved,o,Saved)
        }
        else { %tmp = $input(invalid numbers,o,error) }
      }
    }
  }
}
alias unoini {
  return " $+ $shortfn($scriptdir $+ $1) $+ "
}
dialog unoman {
  title "Unobot Manager"
  size -1 -1 148 82
  option dbu notheme
  icon $shortfn($mircexe), 18
  box "Settings", 1, 2 4 144 56
  text "Uno On/Off:", 2, 8 14 39 8
  button "ON", 3, 60 12 37 12, disable
  button "OFF", 4, 104 12 37 12, disable
  text "Card coloring:", 5, 8 30 35 8
  button "ON", 6, 60 28 37 12, disable
  button "OFF", 7, 104 28 37 12, disable
  text "Registration:", 8, 8 48 35 8
  button "ON", 9, 60 44 37 12, disable
  button "OFF", 10, 104 44 37 12, disable
  button "User Manager", 11, 2 66 37 12, flat
  button "Misc Settings", 12, 54 66 37 12, flat
  button "About", 13, 108 66 37 12, flat
}
dialog unomisc {
  title "Unobot"
  size -1 -1 144 162
  option dbu
  box "Flood settings", 1, 2 2 140 62
  edit "", 2, 58 12 14 10
  text "Lines in 10 seconds", 3, 74 14 53 8
  combo 5, 6 12 36 35, size drop
  text "after", 6, 44 14 13 8
  combo 8, 6 32 36 35, size drop
  text "after", 9, 44 34 13 8
  edit "", 10, 58 32 14 10
  text "Repeats in 10 seconds", 11, 74 34 59 8
  box "Timer settings", 16, 2 66 140 50
  edit "", 17, 106 74 24 10
  text "Seconds before idle player is warned:", 18, 8 76 91 8
  edit "", 19, 106 88 24 10
  text "After warning, player is removed after:", 20, 8 90 91 8
  button "Save", 21, 56 146 37 12
  edit "", 22, 106 102 24 10
  text "Flood ban time in seconds:", 23, 34 104 67 8
  check "Enabled?", 24, 46 50 46 10
  box "Misc", 4, 2 118 140 24
  text "Top 10 by:", 7, 10 128 31 8
  combo 12, 60 126 60 32, drop
}
dialog unoabout {
  title "Unobot"
  size -1 -1 132 30
  option dbu notheme
  icon $shortfn($mircexe), $rand(1,21)
  icon 1, 4 4 15 15, $shortfn($mircexe), $rand(1,21)
  text Unobot $unover, 2, 30 4 97 10
  link "http://shady.nu", 3, 30 18 40 8
  link "bl4h@shady.nu", 4, 76 18 50 8

Comments

Sign in to comment.
JoKabua   -  May 24, 2012

ty

 Respond  
Wizjany   -  May 24, 2012

I haven't been on this site forever lol, don't even use mirc anymore..

open notepad
copy/paste the text of my earlier comment
save as... navigate to your mirc/scripts folder
name the file "UNOTHEME.ini" and hit save

 Respond  
JoKabua   -  May 24, 2012

Or put this in my remote mirc..

 Respond  
JoKabua   -  May 24, 2012

On Wizjany comment say "if you make a file called UNOTHEME.ini and put this in there, the script will work..."

he mean make a new folder and put in the front desktop screen?

 Respond  
JoKabua   -  May 24, 2012

how can i create the file/ i did that and doesn't work.. can you step by step pls..

 Respond  
MoMy   -  May 20, 2012

@JoKabua
The command for started is !uno.
To make it work you need to create a file UNOTHEME.ini into mirc dir -> scripts and add the text of Wizjany (the comment above)

 Respond  
JoKabua   -  May 18, 2012

How you start this uno? what is the command?

 Respond  
blackvenomm666   -  Jun 18, 2011

maybe someone can edit this to make it so if only one person wants to play the bot will play? that would be cool

 Respond  
loves.enough   -  Mar 04, 2011

i am added UNOTHEME.ini in script folder and load but dosnot work
which commnads are to start ????

 Respond  
Warriorii   -  Aug 22, 2010

where can i get the UNOTHEME.INI.... I don't find it on this site
http://shady.nu

 Respond  
Warriorii   -  Aug 22, 2010

Hmmm i can't seem to get it to start

 Respond  
jackster35-1   -  Aug 13, 2010

The bottom of the script ain't there

 Respond  
loves.enough   -  Aug 06, 2010

how can i creat this game and play in the chat room or channel
can u guide me plz
can i put in remote ??

 Respond  
satya87   -  Jan 11, 2009

works good except for one small bug..

when u are playing with just the bot..and u part the channel..the bot doesnt automatically end the game after 120 seconds..so basically noone else can stop the game except for the user who parted..and if the user doesnt come back then noone can start a new game..so basically u have to restart the bot..it wud be nice to fix that..and also to add an option where anyone higher than half oops can execute the end commands..

also it wud be nice to implement how many wins and losses each user has in top 10 besides there name :)

 Respond  
Felix2003   -  Jan 01, 2009

tested and works perfectly :) thank you

 Respond  
Wizjany   -  Jul 30, 2008

you need a file \"UNOTHEME.ini\" which contains some stuff that it needs...

if you make a file called UNOTHEME.ini and put this in there, the script will work...

;colors: red brown purple orange yellow white black darkblue dgreen lgreen turq skyblue blue pink dgray lgray
;effects: [u] = underline [b] = bold [r] = reverse

[default]
;info notices to users
logdisabled=Sorry, nickname registration and login are disabled.
notregged=No such user: **+1+**. Type **/notice +botnick+ unoregister <username> <password>**
notlogged=You are not logged in.
alreadylogged=You are alreadly logged in under **+username+**. Type **unologout** to logout. (/notice +botnick+ unologout)
logout=You are now logged out of account +username+
passchange=Password for **+username+** changed to **+1+**
passaccepted=**[green]Password accepted.**[/green] You are now logged in.
invalidlogin=**[red]Invalid password.**[/red]
toolong=Username and password must contain 20 characters or less each.
usernametaken=Sorry, [b]+1+[b] is already registered. To login: /notice +botnick+ unologin <password>
alreadyregged=Sorry, it looks as if you registered the username **+1+**. Only one username per user is allowed due to abuse. If this is wrong, contact the owner of the bot.
regsuccess=**+1+** registered to you with the password **+2+**
floodmsg=You\'re flooding me. *ignores your commands for +1+ seconds*
activegame=An Uno game is already active! Type **join** to join the game
endunoerr=Only **+1+** can end the current game! Use **!unoremove** to leave the game
noactivegame=No active games! Type **!uno** to start a round.
alreadyplaying=You\'re already playing this round.
notplayinground=You\'re not in this game. Type **join** to play
notyourturn=It isnt your turn...chill.
playingas=Your score will be saved under the username **+username+**
notplayingas=You are [red]NOT[/red] logged in. Your score will not be saved.
mustdraw=Draw a card first! Type **draw**
passorplay=You must **pass** or **play**
wildwait=Waiting for **+1+** to chose a color!
hasuno=**+1+ has [yellow]U[/yellow][blue]N[/blue][red]O[/red]!**
unowin=**[red]+1+[/red] [green]WINS[/green] [yellow]U[/yellow][blue]N[/blue][red]O[/red]!**
drawtwo=**+1+ [purple]DRAWS TWO[/purple] cards and is [green]SKIPPED[/green]**
drawfour=**+1+ [red]DRAWS FOUR[/red] cards.**
skipped=**+1+ is [green]SKIPPED[/green]**
choosecolor=Choose a color **+1+**. Type color red, color blue, color yellow, or color green.
reverseback=**<- [blue]REVERSE[/blue]**
reversefwd=**[blue]REVERSE[/blue] ->**
idlewarnplayer=You have **+1+** seconds before you are removed from the game!
idlewarnchan=**+1+** will be removed from the game if they dont play their turn within **+2+** seconds.
stopuno=The current game has been **ENDED** by **+1+**
endscore=Points this game +1+: **[red]+2+[/red]**
mustreg=To have your scores saved by the bot, you must login or register. Type **/notice +botnick+ unohelp for more info.**
unostart=+1+ wants to play Uno! Type **join** in the channel to join the game. Game will start in 30 seconds.
unostartbot=[red]The bot will be playing this round.[/red]
willplay=**+1+** will play!
shuffledeck=**[red]SHUFFLING DECK!**[/red]

;help notices to users
hchpass=Usage: unochpass <new password>
hlogin=Usage: unologin <username> <password>
hregister=Usage: unoregister <username> <password>
hregistersuggest=Login or register. For help **/notice +botnick+ unohelp**

;log @uno window
logoutlog=+time+ <+nick+> logged **[orange]OUT[/orange]** of account +username+
loginlog=+time+ <+nick+> logged **[green]IN**[/green] to account **+username+**
invalidlog=+time+ <+nick+> tried [red]INVALID[/red] password for account **+1+** using pass **+2+**
registeredlog=+time+ <+nick+> [purple]REGISTERED[/purple] account **+1+**
 Respond  
AHBARAR   -  Jul 30, 2008

Why Dont U Add A Screen Shoot Will Make More Users Have A Look At It >:) Will try It Now Now Just Busy Sms my friends

 Respond  
JonB_   -  Jul 30, 2008

Tell me what you think!!!

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.