;uno by bl4h (ic3yt3a@yahoo.com) ;http://bl4h.myhawkee.com 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 { %tmpmsg = $?!="Do you want to enable user registration? $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." if (%tmpmsg == $true) { writeini uno.ini settings allowreg 1 } if (%tmpmsg == $false) { writeini uno.ini settings allowreg 0 } if ($readini(uno.ini,settings,enabled) == $null) { writeini uno.ini settings enabled 1 } echo -a *** Uno setup complete echo -a *** Change Uno settings with channel or status window menus } alias unover { return beta } alias unomotd { if (!$sock(unocheck)) { sockopen unocheck bl4h.mine.nu 4646 } } menu status,channel,menubar { Uno .$submenu($unoset($1)) } alias unoset { if ($1 == begin) { return } if ($1 == 1) { if ($readini(uno.ini,settings,enabled) == 1) { return Turn bot OFF:/writeini uno.ini settings enabled 0 } else { return Turn bot ON:/writeini uno.ini settings enabled 1 } } if ($1 == 2) { if ($readini(uno.ini,settings,allowreg) == 1) { return Turn registration OFF:/writeini uno.ini settings allowreg 0 } else { return Turn registration ON:/writeini uno.ini settings allowreg 1 } } if ($1 == end) { return } } 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 :nextread sockread %temp if ($sockbr == 0) return if (%temp == $null) return echo -s %temp goto nextread } on *:TEXT:uno*:?:{ close -m $nick if (!$window(@uno)) { window -n @uno } if ($1 == unologout) { if ($ulist($address($nick,2),uno,1)) { aline -a @uno $time < $+ $nick $+ > logged out of account $ulist($address($nick,2),uno,1).info $+  ruser uno $ulist($address($nick,2),uno,1) .msg $nick You have been logged out. halt } } if ($1 == unologin) { if ($readini(uno.ini,settings,allowreg) != 1) { .msg $nick Sorry, nickname registration and login are disabled. halt } if ($ulist($address($nick,2),uno,1)) { .msg $nick You are alreadly logged in under  $+ $ulist($address($nick,2),uno,1).info $+ . Type unologout to logout. (/msg $me unologout) halt } if (!$2 || !$3) { .msg $nick Usage: unologin | halt } if (!$readini(uno.ini,$2,registered) || $readini(uno.ini,$2,registered) == 0) { .msg $nick That nickname isnt registered. Type /msg $me unoregister  | halt } if ($3 == $readini(uno.ini,$2,password)) { .guser uno $nick 2 $2 .msg $nick 3Password accepted. You are now logged in under $2 $+ . aline -a @uno $time < $+ $nick $+ > logged 3IN to account $2 $+  halt } if ($3 != $readini(uno.ini,$2,password)) { .msg $nick Invalid password. aline -a @uno $time < $+ $nick $+ > tried 4INVALID password for account $2 $+  halt } } if ($1 == unoregister) { if ($readini(uno.ini,$2,registered) == 1) { .msg $nick Sorry, that nickname is already registered. To login: /msg $me unologin | halt } else { if (!$2 || !$3) { .msg $nick Usage: unoregister | halt } else { writeini uno.ini $2 password $3 writeini uno.ini $2 registered 1 writeini uno.ini $2 wins 0 writeini uno.ini $2 loss 0 writeini uno.ini $2 score 0 writeini uno.ini $2 playersince $ctime .msg $nick  $+ $2 $+  registered with the password  $+ $3 $+  .guser uno $nick 2 $2 .notice $nick 3You are now logged in. aline -a @uno $time < $+ $nick $+ > 7REGISTERED account $2 $+  halt } } } aline -a @uno $time < $+ $nick $+ > $1- } on *:TEXT:*:#:{ ;flood protection if ($hget(flood. $+ $nick,ig)) { halt } %bl4h.floodunomsgs = 3 %bl4h.floodunosec = 4 ;length of ignore in seconds %bl4h.floodunoignore = 10 if (!$hget(flood. $+ $nick,s)) { hadd -m flood. $+ $nick t $1 hadd -m flood. $+ $nick times 1 hadd -z flood. $+ $nick s %bl4h.floodunosec goto gays } if ($hget(flood. $+ $nick,times) >= %bl4h.floodunomsgs && $hget(flood. $+ $nick,s)) { hadd -u $+ %bl4h.floodunoignore flood. $+ $nick ig 1 .notice $nick You're flooding me. *ignores your commands for %bl4h.floodunoignore seconds* halt } if ($1 == $hget(flood. $+ $nick,t)) { hinc flood. $+ $nick times } :gays ;end flood protection if ($1 == !unohelp) { unohelp $nick $2 } 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 nextplayer } if ($hget(uno,+wild)) { msg $hget(uno,+chan) Waiting for  $+ $hget(uno,+wild) $+  to chose a color! | halt } if ($1 == !uno) { if ($readini(uno.ini,settings,enabled) == 1) { if ($hget(uno)) { msg # An Uno game is already active! Type !unoend to end the game | halt } startuno $nick $chan } else { msg # Sorry, uno is disabled. Try later. } } if ($1 == !unostat) { unostat # $2 } if ($1 == count && $hget(uno)) { unocount } if ($1 == !unoend || $1 = !enduno || $1 = !stopuno) { stopuno # $nick } if ($1 == !unoabout) { .notice $nick Unobot $unover by bl4h (ic3yt3a@yahoo.com) http://bl4h.myhawkee.com } if ($1 == join && $hget(uno)) { userhost $nick if ($readini(uno.ini,settings,allowreg) == 1) { if ($ulist($address($nick,2),uno,1)) { .notice $nick Your score will be saved under the username  $+ $ulist($address($nick,2),uno,1).info $+  } if (!$ulist($address($nick,2),uno,1)) { .notice $nick You are 4NOT logged in. Your score will not be saved. .notice $nick To register type: /msg $me unoregister  } } hadd uno +chan $chan setupplayer $nick } if ($1 == play && $hget(uno) && ($hget(uno,+up) == $nick )) { unset %bl4h.unodraw playcard $chan $nick $1- } if ($1 == pass) { if ($hget(uno,+up) != $nick) { .notice $nick It isnt your turn. | halt } if (!%bl4h.unodraw) { .notice $hget(uno,+up) Draw a card first! Type draw | halt } unset %bl4h.unodraw goone nextplayer } if ($1 == draw) { if ($hget(uno,+up) != $nick) { .notice $nick It isnt your turn. | halt } givecards $hget(uno,+up) 1 .notice $hget(uno,+up) Type pass to pass. set %bl4h.unodraw 1 } } alias playcard { if ($hget(uno,+up) != $2) { .notice $2 It isnt your turn. | halt } %bl4h.unoply = $hascard($1,$2,$4-) if (%bl4h.unoply != 0) { hadd uno +card $upper(%bl4h.unoply) removecard $hget(uno,+up) $upper(%bl4h.unoply) if ($gettok($hget(uno,$2),0,45) == 1) { msg $hget(uno,+chan)  $+ $hget(uno,+up) $+  has 8U12N4O! } if (!$gettok($hget(uno,$2),0,45)) { msg $hget(uno,+chan) 4 $+ $hget(uno,+up) $+  3WINS 8U12N4O! 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)  $+ $hget(uno,+up) $+  4DRAWS FOUR cards. msg $hget(uno,+chan) Chose a color $hget(uno,+wild) $+ . Type color red, color blue, color yellow, or color green $+ . halt } if (%bl4h.unoply == W) { hadd uno +wild $hget(uno,+up) goone msg $hget(uno,+chan) Chose a color $hget(uno,+wild) $+ . Type color red, color blue, color yellow, or color green $+ . halt } if ($gettok(%bl4h.unoply,2,46) == r) { if ($hget(uno,+rot) == inc) { hadd uno +rot dec | msg $hget(uno,+chan) <- 12REVERSE } else { hadd uno +rot inc | msg $hget(uno,+chan) 12REVERSE -> } } goone if ($gettok(%bl4h.unoply,2,46) == dt) { msg $hget(uno,+chan)  $+ $hget(uno,+up) 4DRAWS TWO cards and is 3SKIPPED givecards $hget(uno,+up) 2 goone } if ($gettok(%bl4h.unoply,2,46) == s) { msg $hget(uno,+chan)  $+ $hget(uno,+up) is 3SKIPPED 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) return } 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 nextplayer { msg $hget(uno,+chan) 4 $+ $hget(uno,+up) is up msg $hget(uno,+chan) Top card: $drawcards($hget(uno,+card)) .notice $hget(uno,+up) $drawcards($hget(uno,$hget(uno,+up))) } alias hascard { %bl4h.unoinc = 1 %bl4h.unocrds = $hget(uno,$2) %bl4h.unocart = $replace($3-,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 = 0 %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 0 | inc %bl4h.unotmp2 } } hadd unocards G.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 { if (!$hget(uno)) { msg $1 There is no active game. Type !uno to start a new game. | halt } msg $hget(uno,+chan) The current game has been ENDED by $2  unset %bl4h.uno* hfree -w uno* } alias startuno { unset %bl4h.uno* hfree -w uno* hmake uno hadd uno +turn 1 hadd uno +chan $2 hadd uno +rot inc makedeck msg $2 $1 wants to play Uno! Type join in the channel to join the game. Game will start in 30 seconds .timeruno 1 30 begingame $2 } alias begingame { if ($gettok($hget(uno,+players),0,32) < 2 || !$gettok($hget(uno,+players),0,32)) { msg $hget(uno,+chan) Uno requires 2 players! | stopuno $1 $me | halt } msg $hget(uno,+chan) Playing this round: $hget(uno,+players) %bl4h.unofirst = $hfind(unocards, *, $rand(1,$hfind(unocards, *, 0, w)), w) hadd uno +card %bl4h.unofirst hadd uno +time $ctime hdec unocards %bl4h.unofirst 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)  $+ $1 $+  has been added to the current game givecards $1 7 } alias givecards { %bl4h.unotmp = 1 unset %bl4h.unocard* while (%bl4h.unotmp <= $2) { if (!$hget(unocards,0).item) { msg $hget(uno,+chan) 4SHUFFLING DECK! | 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 .notice $1 You drew: $drawcards(%bl4h.unocardz) } alias drawcards { %bl4h.unototcar = $gettok($1-,0,45) %bl4h.unotmp = 1 unset %bl4h.unofix while (%bl4h.unotmp <= %bl4h.unototcar) { if ($left($gettok($1-,%bl4h.unotmp,45),1) == W) { if ($gettok($1-,%bl4h.unotmp,45) == W.D.F) { %bl4h.unofix = %bl4h.unofix 8,1W12D0440,0 | inc %bl4h.unotmp } if ($gettok($1-,%bl4h.unotmp,45) == W) { %bl4h.unofix = %bl4h.unofix 8,1W12I04L9D0,0 | inc %bl4h.unotmp } } else { %bl4h.unofix = %bl4h.unofix $+ 0[ $+ $replace($left($gettok($1-,%bl4h.unotmp,45),1),G,9,R,4,B,12,Y,8) $+ ,01 $+ $chr(32) $+ $gettok($gettok($1-,%bl4h.unotmp,45),2,46) $+ $chr(32) $+ 0] inc %bl4h.unotmp } } 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) if (%bl4h.unocrd == D) { inc %bl4h.unoscore 50 } if (%bl4h.unocrd == 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 ($ulist($address($gettok($hget(uno,+players),%bl4h.unotmp3,32),2),uno,1)) { if ($readini(uno.ini,settings,allowreg) == 1) { %bl4h.unosloss = $calc($readini(uno.ini,$ulist($address($gettok($hget(uno,+players),%bl4h.unotmp3,32),2),uno,1).info,loss) + 1) %bl4h.unoswin = $readini(uno.ini,$ulist($address($gettok($hget(uno,+players),%bl4h.unotmp3,32),2),uno,1).info,wins) writeini uno.ini $ulist($address($gettok($hget(uno,+players),%bl4h.unotmp3,32),2),uno,1).info loss %bl4h.unosloss writeini uno.ini $ulist($address($gettok($hget(uno,+players),%bl4h.unotmp3,32),2),uno,1).info totalgames $calc(%bl4h.unosloss + %bl4h.unoswin) writeini uno.ini $ulist($address($gettok($hget(uno,+players),%bl4h.unotmp3,32),2),uno,1).info lastgame $ctime } } 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) Points this game $1 $+ :4 %bl4h.unoscore if ($readini(uno.ini,settings,allowreg) == 1) { if ($ulist($address($1,2),uno,1)) { %bl4h.unoscoretot = $calc($readini(uno.ini,$ulist($address($nick,2),uno,1).info,score) + %bl4h.unoscore) %bl4h.unoscorewins = $calc($readini(uno.ini,$ulist($address($nick,2),uno,1).info,wins) + 1) %bl4h.unoscoreloss = $readini(uno.ini,$ulist($address($nick,2),uno,1).info,loss) writeini uno.ini $ulist($address($nick,2),uno,1).info totalgames $calc(%bl4h.unoscorewins + %bl4h.unoscoreloss) writeini uno.ini $ulist($address($nick,2),uno,1).info score %bl4h.unoscoretot writeini uno.ini $ulist($address($nick,2),uno,1).info wins %bl4h.unoscorewins writeini uno.ini $ulist($address($nick,2),uno,1).info lastgame $ctime msg $hget(uno,+chan) $nick $+ 's Totals:  $+ %bl4h.unoscoretot points $+  < $+ %bl4h.unoscorewins wins / %bl4h.unoscoreloss losses> } else { .notice $1 To have your scores saved by the bot, you must register. Type /msg $me register  to register. } } } 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 ($readini(uno.ini,$2,score)) { msg $1  $+ $2 $+ :  $readini(uno.ini,$2,score) $+  < $+ $readini(uno.ini,$2,wins) $+ W/ $+ $readini(uno.ini,$2,loss) $+ L $+ > } else { msg $1  $+ $2 $+  no such user } } alias unohelp { if (!$2) { .notice $1 For official uno rules visit: http://hometown.aol.com/babso00001/unorules.html .notice $nick Commands: !uno , !unoend , join , play , draw , pass , count , !unostat , !unoabout .notice $nick Type !unohelp  for help on a specific command return } if ($readini(unohelp.ini,help,$2) != $null) { .notice $nick $readini(unohelp.ini,help,$2) } 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 } on *:NICK:{ if ($hget(uno)) { if ($unoingame($nick)) { %bl4h.unotmpplay = $hget(uno,+players) hadd uno +players $replace(%bl4h.unotmpplay,$nick $+ $chr(32),$newnick $+ $chr(32)) hadd uno $newnick $hget(uno,$nick) hdel uno $nick if ($hget(uno,+up) == $nick) { hadd uno +up $newnick } if ($hget(uno,+wild) == $nick) { hadd uno +wild $newnick } } } }