on *:SOCKOPEN:gunbound:{
  if ($sockerr > 0) { echo -ts Connection Error. }
  else {
    sockwrite -tn gunbound GET /rank/rank_s.asp?search_id= $+ %gunbound.nick HTTP/1.1
    sockwrite -tn gunbound Host: www.gunbound.net
    sockwrite -tn gunbound Accept: */*
    sockwrite -tn gunbound Referer: www.gunbound.net/rank/rank_s.asp?search_id=
    sockwrite -tn gunbound User-Agent: Mozilla/4.0 (compatible; MSIE 5.00; Windows 98)
    sockwrite -tn gunbound Pragma: no-cache
    sockwrite -tn gunbound Cache-Control: no-cache
    sockwrite -tn gunbound Connection: close
    sockwrite -tn gunbound $crlf 
  }
}
on *:text:!rank*:#:{
  if ($2 == $null) { msg # syntax: !rank <Username> | return }
  else {
    write -c gunbound.txt 
    set %gunbound.nick $2
    set %gunbound.chan $chan
    .sockclose gunbound
    sockopen gunbound www.gunbound.net 80
  }
}
on *:SOCKREAD:gunbound:{   
  sockread %gunbound
  write gunbound.txt %gunbound
  .timergn 1 1 dis.res
}
alias dis.res {
  set %i 0
  while (%i <= $lines(gunbound.txt)) { 
    if (*no*data*found* iswm $read(gunbound.txt,%i)) { msg %gunbound.chan No data found for %gunbound.nick | return }
    inc %i
  }
  set %gunbound.1 $replace($read(gunbound.txt,520),<td width="61" align="center">,-)
  set %gunbound.2 $replace($read(gunbound.txt,524),<td width="100" align="center">,-,</td>,-)
  set %gunbound.3 $replace($read(gunbound.txt,525),<td width="186" align="center" height="20">,-,</td>,-)
  if (*rank_15.gif* iswm $read(gunbound.txt,522)) { set %gunbound.4 Double Stone Hammer }
  elseif (*rank_-4.* iswm $read(gunbound.txt,522)) { set %gunbound.4 Silver Dragon }
  elseif (*rank_-3.* iswm $read(gunbound.txt,522)) { set %gunbound.4 Red Dragon }
  elseif (*rank_-2.* iswm $read(gunbound.txt,522)) { set %gunbound.4 Blue Dragon }
  elseif (*rank_-1.* iswm $read(gunbound.txt,522)) { set %gunbound.4 Diamond Wand }
  elseif (*rank_0.* iswm $read(gunbound.txt,522)) { set %gunbound.4 Red Wand }
  elseif (*rank_1.* iswm $read(gunbound.txt,522)) { set %gunbound.4 Blue Wand }
  elseif (*rank_2.* iswm $read(gunbound.txt,522)) { set %gunbound.4 Purple Wand }
  elseif (*rank_3.* iswm $read(gunbound.txt,522)) { set %gunbound.4 Golden Double Sided Axe+ }
  elseif (*rank_4.* iswm $read(gunbound.txt,522)) { set %gunbound.4 Golden Double Sided Axe }
  elseif (*rank_5.* iswm $read(gunbound.txt,522)) { set %gunbound.4 Silver Double Sided Axe+ }
  elseif (*rank_6.* iswm $read(gunbound.txt,522)) { set %gunbound.4 Silver Double Sided Axe }
  elseif (*rank_7.* iswm $read(gunbound.txt,522)) { set %gunbound.4 Sided Double Axe+ }
  elseif (*rank_8.* iswm $read(gunbound.txt,522)) { set %gunbound.4 Sided Double Axe }
  elseif (*rank_9.* iswm $read(gunbound.txt,522)) { set %gunbound.4 Double Golden Axe }
  elseif (*rank_10.* iswm $read(gunbound.txt,522)) { set %gunbound.4 Golden Axe }
  elseif (*rank_11.* iswm $read(gunbound.txt,522)) { set %gunbound.4 Double Silver Axe }
  elseif (*rank_12.* iswm $read(gunbound.txt,522)) { set %gunbound.4 Silver Axe }
  elseif (*rank_13.* iswm $read(gunbound.txt,522)) { set %gunbound.4 Double Metal Axe }
  elseif (*rank_14.* iswm $read(gunbound.txt,522)) { set %gunbound.4 Metal Axe }
  elseif (*rank_16.* iswm $read(gunbound.txt,522)) { set %gunbound.4 Stone Hammer }
  elseif (*rank_17.* iswm $read(gunbound.txt,522)) { set %gunbound.4 Double Wood Hammer }
  elseif (*rank_18.* iswm $read(gunbound.txt,522)) { set %gunbound.4 Wood Hammer }
  elseif (*rank_19.* iswm $read(gunbound.txt,522)) { set %gunbound.4 Chicken }
  else { unset %gunbound.4 }
  set %gunbound.5 $replace($read(gunbound.txt,523),<td width="70" align="center">,-,</td>,-)
  msg %gunbound.chan 5Gunbound Rank User: $remove(%gunbound.2,-) $+ , Level: $remove(%gunbound.4,-) $+ , GP: $remove(%gunbound.3,-) $+ , Rank: $remove(%gunbound.1,-) $+ , Guild: $remove(%gunbound.5,-) $+
}