runescape script
Posted by Parasite-FT-
Saturday, October 23, 2004
Description: for frozen


;; Function: returns the xp needed at a specified level in runescape
;; Usage: $lvlxp(<level>)
alias lvlxp {
  var %A, %B, %C, %i = 1
  while (%i <= $1) {
    %A = $floor($calc(%C / 4))
    %B = $floor($calc(%i + 300 * 2^(%i / 7)))
    %C = $calc(%C + %B)
    inc %i
  }
  return %A
}

;; Function: gets data on runescape
;; Usage: /runescape <target> <type> <name of player>
alias runescape {
  %rs.chan = $1
  %rs.type = $2
  %rs.name = $3-
  sockclose runescape
  sockopen runescape hiscore.runescape.com 80
}
on *:sockopen:runescape: {
  sockwrite -n $sockname GET /aff/runescape/hiscorepersonal.cgi?username= $+ $replace(%rs.name,$chr(32),+) HTTP/1.1
  sockwrite -n $sockname Host: hiscore.runescape.com
  sockwrite -n $sockname Connection: close
  sockwrite -n $sockname
}
on *:sockread:runescape: {
  var %temp
  sockread %temp
  if (*class=c>*</a></td>* iswm %temp) {
    set %rs.subject $nohtml(%temp)
    %rs.capture = 1
  }
  elseif (%rs.capture) && ($nohtml(%temp)) {
    inc %rs.capture
    if (%rs.capture == 2) set %rs.rank. [ $+ [ %rs.subject ] ] $nohtml(%temp)
    elseif (%rs.capture == 3) set %rs.level. [ $+ [ %rs.subject ] ] $nohtml(%temp)
    elseif (%rs.capture == 4) set %rs.xp. [ $+ [ %rs.subject ] ] $nohtml(%temp)
    else unset %rs.capture
  }
}
on *:sockclose:runescape: {
  ;; give overall stats - level for each area
  if (%rs.type == overall) {
    var %i = 1, %results = Levels for %rs.name ::
    while ($var(%rs.level.*,%i)) {
      var %type = $gettok($ifmatch,3,46), %value = $var(%rs.level.*,%i).value
      %results = %results $+([^B],%type,[^B]:) %value :|:
      inc %i
    }
  }
  ;; give stats for each area (attack,defense,etc)
  else {
    var %lvlxp = $calc($lvlxp($calc(%rs.level. [ $+ [ %rs.type ] ] + 1)) - $remove(%rs.xp. [ $+ [ %rs.type ] ] ,$chr(44)) )
    var %firegiants = 192, %greaterdemon = 204, %axe = 104, %earthwarrior = 114
    var %stats = [^B] $+ %rs.type [^B]stats for %rs.name :: [^B]Rank:[^B] %rs.rank. [ $+ [ %rs.type ] ] :|: [^B]Level:[^B] %rs.level. [ $+ [ %rs.type ] ] :|: [^B]XP:[^B] %rs.xp. [ $+ [ %rs.type ] ] :|: [^B]XP required to level:[^B] %lvlxp
    var %monsters = Need to kill: $int($calc(%lvlxp / %firegiants)) Firegiants, $int($calc(%lvlxp /  %greaterdemon)) Greater Demons, $int($calc(%lvlxp / %axe)) Magic Axes, $int($calc(%lvlxp / %earthwarrior)) Earthwarriors
    var %results = %stats :: %monsters
  }
  msg %rs.chan %results
  unset %rs.*
}
=p
Posted by Fubar
Saturday, October 23, 2004 12:21pm PDT
you started helping pker on this but i finished the job
Submit a comment
Oops! You need to login or register before you can post a comment!

ebaum's world