All pastes #924175 Raw Edit

Untitled

public text v1 · immutable
·published 2008-03-01 03:38 UTC
rendered paste body
menu channel {
  Runescape Toolkit:/RunescapeToolkit
}
alias RunescapeToolkit { $iif(!$dialog(RunescapeToolkit).title,dialog -m RunescapeToolkit RunescapeToolkit) }
dialog RunescapeToolkit {
  title "Runescape Toolkit"
  size -1 -1 258 181
  option dbu

  tab "Stats/Combat Lookup", 500, -2 1 294 239
  list 1, 6 32 242 129, tab 500 size
  edit "", 2, 116 19 59 9, tab 500 center
  button "Lookup", 3, 178 19 31 9, tab 500
  text "Runescape Stats Lookup", 4, 6 19 62 8, tab 500
  text "User to look up:", 5, 74 19 39 8, tab 500

  tab "Price Lookup", 600
  list 6, 6 32 242 129, tab 600 size
  edit "", 7, 116 19 59 9, tab 600 center
  button "Lookup", 8, 178 19 31 9, tab 600
  text "Runescape Price Lookup", 9, 6 19 62 8, tab 600
  text "Item to look up:", 10, 74 19 39 8, tab 600

  tab "Quest Lookup", 700
  list 11, 6 32 242 129, tab 700 size
  button "Lookup Quest", 12, 125 18 38 12, tab 700
  button "Update Quests", 13, 205 18 42 12, tab 700
  button "List Quests", 14, 165 18 38 12, tab 700
  text "Runescape Quest Lookup", 15, 6 19 62 8, tab 700

  tab "News", 800
  list 16, 6 32 242 129, tab 800 size
  button "Read Selected", 17, 161 18 42 12, tab 800
  button "Retrieve latest", 18, 207 18 40 12, tab 800
  text "Runescape News Lookup", 19, 7 19 62 8, tab 800

  tab "Credits", 900
  list 20, 6 32 242 129, tab 900
  button "Exit", 21, 211 163 37 12, ok
}
alias -l setup.dll {
  dll $shortfn($scriptdirmdx.dll) SetMircVersion $version
  dll $shortfn($scriptdirmdx.dll) MarkDialog RunescapeToolkit
  dll $shortfn($scriptdirmdx.dll) SetControlMDX RunescapeToolkit $1 ListView report single grid > $shortfn($scriptdirviews.mdx)
  did -i $dname $1 1 headerdims $2-
}
alias -l dialog.cleanup {
  hfree RSToolkit
  .hmake RSToolkit 60
  $iif($dialog(RunescapeToolkit).title,hadd RSToolkit Start 1)
}
on *:dialog:RunescapeToolkit:init:*: {
  if ($hget(RSToolkit,Start)) {
    hfree RSToolkit
  }
  .hmake RSToolkit 60
  hadd RSToolkit Start 1
  setup.dll 1 75 55 120 110 120
  did -i $dname 1 1 headertext Skill $chr(9) Level $chr(9) Experience $chr(9) Rank $chr(9) EXP for Next Lvl
}
on *:dialog:RunescapeToolkit:close:*: {
  sockclose RSToolkit.stats
  sockclose RSToolkit.price
  sockclose RSToolkit.newsget
  sockclose RSToolkit.news
  sockclose RSToolkit.questupdate
  sockclose RSToolkit.quest
  hfree RSToolkit
}
alias a { 
  return $asc($1) 
}
on *:dialog:RunescapeToolkit:sclick:*: {
  if ($did = 600) {
    setup.dll 6 120 190 110 60
    did -i $dname 6 1 headertext Item $chr(9) Price $chr(9) Category $chr(9) F2P/P2P
  }
  if ($did = 700) {
    if (!$did(11)) {
      did -b $dname 11
      did -a $dname 11 Listing Quests:
      if ($read(Quest.txt)) {
        var %s = 1
        while ($read(Quest.txt,%s)) {
          did -a $dname 11 $gettok($read(Quest.txt,%s),1,64)
          inc %s
        }
      }
      else { did -a $dname 11 Please press the Update Quest button to retrieve the latest quests. }
      did -e $dname 11
    }
  }
  if ($did = 900) { 
    did -a $dname 20 Runescape Toolkit
    did -a $dname 20 $+($chr(77),$chr(97),$chr(100),$chr(101),$chr(32),$chr(98),$chr(121),$chr(58),$chr(32),$chr(74),$chr(121),$chr(97),$chr(110),$chr(103))
    did -a $dname 20 Questions or Comments find me on SwiftIRC in #Jyang.
    did -a $dname 20 $lf
    did -a $dname 20 Credits:
    did -a $dname 20 www.Zybez.net - Price and Quest parser
    did -a $dname 20 www.Runescape.com - Stats and News parser
  }
  if ($did = 3) { 
    if ($did(2)) && ($did(2) != Enter a username) {
      if ($len($did(2)) <= 12) { 
        did -r $dname 1
        hadd RSToolkit RSN $did(2)
        if ($sock(RSToolkit.stats)) sockclose RSToolkit.stats
        sockopen RSToolkit.stats hiscore.runescape.com 80
      }
    }
    else { did -ra $dname 10 Enter a username }
  }
  if ($did = 8) {
    if ($did(7)) && ($did(7) != No Item Specified) {
      hadd RSToolkit Item $did(7)
      did -r $dname 6
      if ($sock(RSToolkit.price)) sockclose RSToolkit.price
      sockopen RSToolkit.price www.zybez.net 80
    }
    else { did -a $dname 7 No Item Specified }
  }
  if ($did = 18) {
    did -r $dname 16
    if ($sock(RSToolkit.newsget)) sockclose RSToolkit.newsget
    sockopen RSToolkit.newsget news.runescape.com 80
  }
  if ($did = 17) {
    if ($did(16).seltext) {
      if ($hget(RSToolkit,$right($gettok($replace($did(16).seltext,$chr(32),$chr(95)),2,164),-1))) {
        hadd RSToolkit ID $ifmatch
        hdel RSToolkit NewsRead 1
        var %s = $did(16).seltext
        did -r $dname 16
        did -a $dname 16 Reading $+(%s,:)
        if ($sock(RSToolkit.news)) sockclose RSToolkit.news
        sockopen RSToolkit.news news.runescape.com 80
      }
    }
  }
  if ($did = 14) {
    did -r $dname 11
    did -a $dname 11 Listing Quests:
    if ($read(Quest.txt)) {
      var %s = 1
      while ($read(Quest.txt,%s)) {
        did -a $dname 11 $gettok($read(Quest.txt,%s),1,64)
        inc %s
      }
    }  
  }
  if ($did = 13) {
    did -ra $dname 11 Updating quests from Zybez Quest Database.
    did -b $dname 11
    if ($sock(RSToolkit.questupdate)) sockclose RSToolkit.questupdate
    sockopen RSToolkit.questupdate www.zybez.net 80
  }
  if ($did = 12) {
    if ($did(11).seltext) && ($did(11).seltext != $did(11,1)) {
      if ($read(Quest.txt,w,$+($did(11).seltext,*)),2,64) {
        hadd RSToolkit Quest $did(11).seltext
        did -ra $dname 11 Looking up: $chr(91) $+ $did(11).seltext $+ $chr(93) quest in the Zybez Database.
        if ($sock(RSToolkit.quest)) sockclose RSToolkit.quest
        sockopen RSToolkit.quest www.zybez.net 80
      }
      else { did -a $dname 11 Unable to find: $chr(91) $+ $did(11).seltext $+ $chr(93) $+ . Please update your Quests. }
    }
  }
}

on *:sockopen:RSToolkit.stats: {
  sockwrite -n $sockname GET $+(/lang/en/aff/runescape/hiscorepersonal.ws?user1=,$hget(RSToolkit,RSN)) HTTP/1.1
  sockwrite -n $sockname Host: $+(hiscore.runescape.com,$crlf,$crlf)
}
on *:sockread:RSToolkit.stats: {
  if ($sockerr) || (!$sockname) did -a RunescapeToolkit 1 $chr(9) $chr(9) An error occured.
  else {
    var %sock
    sockread %sock
    if (*does not feature in the hiscores* iswm %sock) { 
      did -a RunescapeToolkit 1 $hget(RSToolkit,RSN) $chr(9) does $chr(9) not $chr(9) appear on the $chr(9) highscores.
      sockclose $sockname
      dialog.cleanup
    }
    if (*td align="left* iswm %sock) {
      hadd RSToolkit StatsCount 1
    }
    if ($htmlstrip(%sock)) {
      if ($hget(RSToolkit,StatsCount)) {
        if ($ifmatch = 1) { 
          hadd RSToolkit StatsSkills $hget(RSToolkit,StatsSkills) $htmlstrip(%sock)
          hadd RSToolkit StatsTemp $htmlstrip(%sock)
          hinc RSToolkit StatsCount
        }
        else {
          hadd RSToolkit $hget(RSToolkit,StatsTemp) $hget(RSToolkit,$hget(RSToolkit,StatsTemp)) $htmlstrip(%sock)
          if ($hget(RSToolkit,StatsCount) = 4) hdel RSToolkit StatsCount
        }
      }
    }
    if (*form action="hiscorepersonal.ws" method="POST" style="margin:0px;"* iswm %sock) {
      sockclose $sockname
      var %s = 1
      while (%s <= $numtok($hget(RSToolkit,StatsSkills),32)) {
        var %x = $gettok($hget(RSToolkit,StatsSkills),%s,32)
        if ($gettok($hget(RSToolkit,%x),2,32) = Ranked) hadd RSToolkit %x $str(N/A $chr(32),3)
        if (%x != Overall) && ($gettok($hget(RSToolkit,%x),2,32) != 99) {
          var %z = 1, %y = 0
          while (%z < $calc($gettok($hget(RSToolkit,%x),2,32) + 1)) {
            inc %y $calc(%z + 300 * (2 ^ (%z / 7)) / 4)
            inc %z
          }
          var %next = $bytes($calc($floor(%y) - $remove($gettok($hget(RSToolkit,%x),3,32),$chr(44))),b)
        }
        did -a RunescapeToolkit 1 %x $chr(9) $gettok($hget(RSToolkit,%x),2,32) $chr(9) $gettok($hget(RSToolkit,%x),3,32) $chr(9) $gettok($hget(RSToolkit,%x),1,32) $chr(9) $iif(%next,$v1,N/A)
        inc %s
      }
      var %a = $iif($gettok($hget(RSToolkit,Attack),2,32),$v1,1), %d = $iif($gettok($hget(RSToolkit,Defence),2,32),$v1,1), $&
        %s = $iif($gettok($hget(RSToolkit,Strength),2,32),$v1,1), %h = $iif($gettok($hget(RSToolkit,Hitpoints),2,32),$v1,10), $&
        %r = $iif($gettok($hget(RSToolkit,Ranged),2,32),$v1,1), %p = $iif($gettok($hget(RSToolkit,Prayer),2,32),$v1,1) , $&
        %m = $iif($gettok($hget(RSToolkit,Magic),2,32),$v1,1)
      var %base = $calc(((%d * 100) + (%h * 100) + ($iif($and(1,%p),$calc(%p - 1),%p) * 50)) / 400)
      var %melee = $calc(((%a * 130) + (%s * 130)) / 400)
      var %ranged = $calc($iif($and(1,%r),$calc(%r * 195 - 65),$calc(%r * 195)) / 400) 
      var %magic = $calc($iif($and(1,%m),$calc(%m * 195 - 65),$calc(%m * 195)) / 400)
      if (%melee > %ranger) && (%melee > %mage) var %combat = $calc(%melee + %base)
      if (%ranger > %melee) && (%ranger > %mage) var %combat = $calc(%ranger + %base)
      if (%mage > %melee) && (%mage > %ranger) var %combat = $calc(%mage + %base)
      else var %combat = $calc(%melee + %base)
      var %combat = $floor(%combat)
      did -i RunescapeToolkit 1 2 Combat $chr(9) %combat
      dialog.cleanup
    }
  }
}
on *:sockopen:RSToolkit.price: { 
  sockwrite -nt $sockname GET /priceguide.php?search_terms= $+ $replace($hget(RSToolkit,Item),$chr(32),$chr(43)) $+ &search_area=1&price_low=&price_high=&member=1&all_prices=1&sortby=name&sort=ASC&ppage=0 HTTP/1.1
  sockwrite -nt $sockname Host: www.zybez.net $+ $crlf $+ $crlf
}
on *:sockread:RSToolkit.price: {
  if ($sockerr) { did -a RunescapeToolkit 6 An error occured. }
  else {
    var %sock
    sockread %sock
    if ($hget(RSToolkit,PriceCount) = 1) {
      hadd RSToolkit Item $htmlstrip(%sock) 
      hinc RSToolkit PriceCount
    }
    elseif ($hget(RSToolkit,PriceCount) = 2) {
      hadd RSToolkit Price $htmlstrip(%sock) 
      hinc RSToolkit PriceCount
    }
    elseif ($hget(RSToolkit,PriceCount) = 3) hinc RSToolkit PriceCount
    elseif ($hget(RSToolkit,PriceCount) = 4) {
      did -a RunescapeToolkit 6 $hget(RSToolkit,Item) $chr(9) $hget(RSToolkit,Price) $chr(9) $htmlstrip(%sock) $chr(9) $iif($hget(RSToolkit,PriceMembers),$v1,F2P)
      hinc RSToolkit PriceCount
      hdel RSToolkit PriceMembers
    }
    if (*img src="/img/member.gif" alt="[M]"/* iswm %sock) hadd RSToolkit PriceMembers P2P
    if (*td class="tablebottom">http://www.zybez.net</td* iswm %sock) hadd RSToolkit PriceCount 1
    if (*<!-- Search Results: End -->* iswm %sock) { 
      sockclose $sockname
      dialog.cleanup
    }
    if (*Your search did not return any results* iswm %sock) did -a RunescapeToolkit 6 $hget(RSToolkit,Item) not found. 
  }
}
on *:sockopen:RSToolkit.news: {
  sockwrite -n $sockname GET $+(/newsitem.ws?id=,$hget(RSToolkit,ID)) HTTP/1.1
  sockwrite -n $sockname Host: $+(news.runescape.com,$crlf,$crlf)
}
on *:sockread:RSToolkit.news: {
  if ($sockerr) || (!$sockname) did -a RunescapeToolkit 16 An error occured while reading the Runescape news. Please try again later.
  else {
    var %sock
    sockread %sock
    if (*<div style="text-align: justify;">* iswm %sock) { hadd RSToolkit NewsRead 1 }
    if ($hget(RSToolkit,NewsRead)) {
      var %q = $htmlstrip(%sock)
      if ($len(%q) <= 80) { did -a RunescapeToolkit 16 %q }
      else {
        var %s = 1
        while (%s <= $numtok(%q,32)) {
          var %t = %t $gettok(%q,%s,32)
          if ($len(%t) >= 80) { did -a RunescapeToolkit 16 %t | unset %t }
          inc %s
        }
        if (%t) { did -a RunescapeToolkit 16 %t }
      }
    }
    if (*<div style="clear: both;"></div>* iswm %sock) { dialog.cleanup | sockclose $sockname }
  }
}
on *:sockopen:RSToolkit.newsget: {
  sockwrite -n $sockname GET /list.ws?cat=0&page=1 HTTP/1.1
  sockwrite -n $sockname Host: $+(news.runescape.com,$crlf,$crlf)
}
on *:sockread:RSToolkit.newsget: {
  if ($sockerr) || (!$sockname) did -a RunescapeToolkit 16 An error occured while retrieving the latest news. Please try again later.
  else {
    var %sock
    sockread %sock
    if (<td valign="top"><a href="newsitem.ws?id=*">*</td> iswm %sock) { 
      hadd RSToolkit News $htmlstrip(%sock)
      hadd RSToolkit $replace($htmlstrip(%sock),$chr(32),$chr(95)) $remove(%sock,<td valign="top"><a href="newsitem.ws?id=,">,</td>,$htmlstrip(%sock))
    }
    if (<td align="right" valign="top" style="color:black;">*</td> iswm %sock) did -a RunescapeToolkit 16 $htmlstrip(%sock) ¤ $hget(RSToolkit,News)
    if (*©* iswm %sock) { sockclose $sockname }
  }
}
on *:sockopen:RSToolkit.questupdate: {
  sockwrite -n $sockname GET /quests.php HTTP/1.1
  sockwrite -n $sockname Host: $+(www.zybez.net,$crlf,$crlf)
}
on *:sockread:RSToolkit.questupdate: {
  if ($sockerr) || (!$sockname) did -a RunescapeToolkit 11 An error occured while updating the quests. Please try again later.
  else {
    var %sock
    sockread %sock
    if ($hget(RSToolkit,QuestUpdateCount) = 1) {
      if (*/quests.php?id=* iswm %sock) {
        tokenize 64 $replace($remove(%sock,<td class="tablebottom">,"tablebottom">,<a href=",</a></td>),">,@)
        write quest2.txt $2 $+ @ $+ $1
        hdel RSToolkit QuestUpdateCount
      }
    }
    if (*tr align="center"* iswm %sock) hinc RSToolkit QuestUpdateCount
    if (*Content Copyright Notice* iswm %sock) {
      sockclose $sockname
      did -e RunescapeToolkit 11
      did -a RunescapeToolkit 11 Finished updating Quests from the Zybez database.
      .remove Quest.txt
      .rename Quest2.txt Quest.txt
      did -a RunescapeToolkit 11 Listing Quests:
      var %s = 1
      while ($read(Quest.txt,%s)) {
        did -a RunescapeToolkit 11 $gettok($read(Quest.txt,%s),1,64)
        inc %s
      }
      dialog.cleanup
    }
  }
}
on *:sockopen:RSToolkit.quest: {
  sockwrite -n $sockname GET $+(/,$gettok($read(Quest.txt,w,$+($hget(RSToolkit,Quest),*)),2,64)) HTTP/1.1
  sockwrite -n $sockname Host: $+(www.zybez.net,$crlf,$crlf)
}
on *:sockread:RSToolkit.quest: {
  if ($sockerr) || (!$sockname) did -a RunescapeToolkit 11 An error occured while looking up $did(questhelp,2).seltext $+ . Please try again later.
  else {
    var %sock
    sockread %sock
    did -z RunescapeToolkit 11
    if ((!$htmlstrip(%sock)) && (%sock)) || (< !isin %sock) halt
    if (*href="javascript:history.go(-1)">&lt;-- Go Back</a>* iswm %sock) { 
      dialog.cleanup 
      sockclose $sockname 
    }
    if ($hget(RSToolkit,Questcount) = 1) {
      var %q = $remove($htmlstrip(%sock),3038706,&raquo;,$+($chr(40),picture,$chr(41))))
      if ($len(%q) <= 80) { did -a RunescapeToolkit 11 %q }
      else {
        var %s = 1
        while (%s <= $numtok(%q,32)) {
          var %t = %t $gettok(%q,%s,32)
          if ($len(%t) >= 80) { did -a RunescapeToolkit 11 %t | unset %t }
          inc %s
        }
        if (%t) { did -a RunescapeToolkit 11 %t }
      }
    }
    if (*<td class="header">Start point:</td>* iswm %sock) { 
      did -a RunescapeToolkit 11 $remove($htmlstrip(%sock),3038706,&raquo;,$+($chr(40),picture,$chr(41))))
      hinc RSToolkit Questcount
    }
  }
}
alias htmlstrip { var %y = $regsub($1-,/(<[^>]+>)/g,$null,%x) | return $remove(%x,&nbsp;,&quot;) }