All pastes #263112 Raw Edit

Something

public text v1 · immutable
·published 2006-12-01 05:01 UTC
rendered paste body
alias c1 { 
  if (%defaultcolor) {
    return $+($chr(3), $+ %defaultcolor $+ ,$1-) 
  }
  else {
    return $+($chr(3),04,$1-)
  }
}
alias c2 { return $+($chr(3),01,$1-) }
on *:START: {
  makecolors
}

on 1400:text:!fixtable:#:{
  makecolors
}

on $*:text:/^[!@]setcolor*/Si:*: {
  set %compare.display1 $iif($left($1,1) == @,msg $chan,notice $nick)
  set %compare.display2 $iif($left($1,1) == @,msg $chan,notice $nick) 
  writeini DefRSN.ini colors $mask($fulladdress,3) $format($2)
  set %defaultcolor $format($2)
  set %literal $hget(colors,%defaultcolor)
  %compare.display1 Your default color is now $c1(%literal)
}
on $*:text:/^[!@]compare*/Si:*: {
  if (!$2) { notice $nick Syntax: !compare Skill User1 User2 }
  elseif ($sock(Compare)) {
    .sockclose Compare
  }
  set %compare.display1 $iif($left($1,1) == @,msg $chan,notice $nick)
  set %compare.display2 $iif($left($1,1) == @,msg $chan,notice $nick)
  set %compare.chan $chan
  set %compare.nick $nick
  if ($2 != $getskill($2)) {
    %compare.display1 The syntax is $c1(!/@ compare skill user1 user2).
    halt
  }

  if (!$4) {
    if ($readini(DefRSN.ini,RSNs,$mask(($fulladdress),3))) {
      set %compare.user1 $ifmatch
    }
    elseif ($readini(DefRSN.ini,RSNs,$nick)) {       
      set %compare.user1 $ifmatch
    }
    set %compare.user2 $3
  }
  else {
    set %compare.user1 $3
    set %compare.user2 $4
    set %compare.skill $getskill($2)
  }
  set %compare.skill $getskill($2)
  sockopen Compare www.o-ss.net 80
}
on *:SOCKOPEN:Compare: {
  sockwrite -nt $sockname GET $+(/parsers/compare.php?user1= $+ %compare.user1 $+ &user2= $+ %compare.user2 $+ &skill= $+ %compare.skill $+ ) HTTP/1.1
  sockwrite -nt $sockname Host: www.o-ss.net
  sockwrite -nt $sockname $crlf $crlf
}
on *:SOCKREAD:Compare:{
  if ($sockerr) {
    msg $chan ERROR: $sockname $+ . Code: $Sockerr
    halt
  }
  else {
    var %templine
    sockread %templine
    if (*END* iswm %templine) {
      set %compare.user1lvl $gettok(%templine,1,32)
      set %compare.user2lvl $gettok(%templine,2,32)
      set %compare.dif $gettok(%templine,4,32)
      set %compare.xp $gettok(%templine,5,32)
      %compare.display1 $c2($chr(91)) $c1(COMPARE) $c2($chr(93)) $c1(%compare.user1) $c2(is level) $c1(%compare.user1lvl) $c2(and) $c1(%compare.user2) $c2(is level) $c1(%compare.user2lvl)
      %compare.display2 $c2($chr(91)) $c1(COMPARE) $c2($chr(93)) $c2(Difference in levels is:) $c1(%compare.dif) $c2(and difference in XP is:) $c1($bytes(%compare.xp,b))
      sockclose Define
    }
  }
}

alias -l getskill {
  if ($1 == 0) || ($regex($1,/^(st|(skill)?total|overall)$/Si)) return Overall
  elseif ($1 == 1) || ($regex($1,/^at(t|k|tack)$/Si)) return Attack
  elseif ($1 == 2) || ($regex($1,/^def(en[cs]e)?$$/Si)) return Defence
  elseif ($1 == 3) || ($regex($1,/^str(ength)?$/Si)) return Strength
  elseif ($1 == 4) || ($regex($1,/^hp|hit(s|points?)?$/Si)) return Hitpoints
  elseif ($1 == 5) || ($regex($1,/^range(r|d|ing)?$/Si)) return Ranged
  elseif ($1 == 6) || ($regex($1,/^Pray(er)?$$/Si)) return Prayer
  elseif ($1 == 7) || ($regex($1,/^mag(e|ic)$$/Si)) return Magic
  elseif ($1 == 8) || ($regex($1,/^cook(ing)?$/Si)) return Cooking
  elseif ($1 == 9) || ($regex($1,/^wc|wood(cut(ting)?)?$/Si)) return Woodcutting
  elseif ($1 == 10) || ($regex($1,/^fletch(ing)?$/Si)) return Fletching
  elseif ($1 == 11) || ($regex($1,/^fish(ing)?$/Si)) return Fishing
  elseif ($1 == 12) || ($regex($1,/^(fire|fm)(make?(ing)?|ing)?$/Si)) return Firemaking
  elseif ($1 == 13) || ($regex($1,/^craft(ing)?$/Si)) return Crafting
  elseif ($1 == 14) || ($regex($1,/^(smith|smelt)(ing)?$/Si)) return Smithing
  elseif ($1 == 15) || ($regex($1,/^min(e|ing)?$/Si)) return Mining
  elseif ($1 == 16) || ($regex($1,/^herb(law|lore)?$/Si)) return Herblore
  elseif ($1 == 17) || ($regex($1,/^agil(ity)?$/Si)) return Agility
  elseif ($1 == 18) || ($regex($1,/^(th(ei|ie)[fv](e|ing)?)$/Si)) return Thieving
  elseif ($1 == 19) || ($regex($1,/^slay(er|ing)?$/Si)) return Slayer
  elseif ($1 == 20) || ($regex($1,/^rc|runecraft(ing|er)?$/Si)) return Runecraft
  elseif ($1 == 21) || ($regex($1,/^farm(er|ing)?$/Si)) return Farming
  elseif ($1 == 22) || ($regex($1,/^con(struct|struction)?$/Si)) return Construction
  elseif ($1 == 23) || ($regex($1,/^hunt(er|ing)?$/Si)) return Hunter
}

alias -l format {
  if ($1 < 10) {
    return 0 $+ $1
  }
  else { return $1 }
}

alias -l makecolors {
  hmake colors 16
  hadd colors 00 white 
  hadd colors 01 black
  hadd colors 02 dark-blue
  hadd colors 03 green
  hadd colors 04 red
  hadd colors 05 maroon
  hadd colors 06 purple
  hadd colors 07 orange
  hadd colors 08 yellow
  hadd colors 09 light green
  hadd colors 10 turquoise
  hadd colors 11 cyan
  hadd colors 12 blue
  hadd colors 13 magenta
  hadd colors 14 gray
  hadd colors 15 light gray
  hadd colors 15 light gray