rendered paste bodymenu channel {
Quest Lookup:/questhelp
}
alias /questhelp { dialog -ma questhelp questhelp }
dialog questhelp {
title "Quest Help"
size -1 -1 320 140
option dbu
text "Quest Lookup By JYANG", 1, 5 123 35 16
list 2, 4 3 307 120, size hsbar
button "Ok", 3, 275 125 37 12, ok cancel
button "Update Quests", 4, 232 125 39 12
text "This script uses Zybez's Quest Database", 5, 42 123 58 16
button "Lookup Quest", 6, 114 125 37 12
button "List Quests", 7, 154 125 37 12
button "Help", 8, 194 125 37 12
}
on *:dialog:questhelp:init:0: {
did -b questhelp 2
did -ra questhelp 2 Listing Quests:
if ($read(Quest.txt)) {
var %s = 1
while ($read(Quest.txt,%s)) {
did -a questhelp 2 $gettok($read(Quest.txt,%s),1,64)
inc %s
}
}
else { did -a Questhelp 2 Please press the Update Quest button to retrieve the latest quests. }
did -e questhelp 2
}
on *:dialog:questhelp:sclick:*: {
if ($did == 6) {
if ($did(2).seltext) && ($did(2).seltext != $did(2,1)) {
if ($read(Quest.txt,w,$+($did(2).seltext,*)),2,64) {
set %quest $did(2).seltext
did -ra questhelp 2 Looking up: $chr(91) $+ $did(2).seltext $+ $chr(93) quest in the Zybez Database.
did -b questhelp 2
if ($sock(quest)) {
sockclose quest
}
sockopen quest zybez.net 80
}
else { did -a questhelp 2 Unable to find: $chr(91) $+ $did(2).seltext $+ $chr(93) $+ . Please update your Quests. }
}
}
if ($did == 7) {
did -b questhelp 2
did -ra questhelp 2 Listing Quests:
if ($read(Quest.txt)) {
var %s = 1
while ($read(Quest.txt,%s)) {
did -a questhelp 2 $gettok($read(Quest.txt,%s),1,64)
inc %s
}
}
else { did -a Questhelp 2 Please press the Update Quest button to retrieve the latest quests. }
did -e questhelp 2
}
if ($did == 4) {
did -ra questhelp 2 Updating all quests from Zybez Quest Database.
did -b questhelp 2
.remove quest.txt
if ($sock(questupdate)) {
sockclose questupdate
}
sockopen questupdate zybez.net 80
}
}
on *:sockopen:quest: {
sockwrite -n $sockname GET $gettok($read(Quest.txt,w,$+(%quest,*)),2,64) HTTP/1.1
sockwrite -n $sockname Host: zybez.net $+ $crlf $+ $crlf
}
on *:sockread:quest: {
if ($sockerr) { did -a questhelp 2 An error occured while looking up $did(questhelp,2).seltext $+ . Please try again later. | halt }
else {
var %sock
sockread %sock
did -z questhelp 2
if (!$htmlstrip(%sock)) || (< !isin %sock) { halt }
if (*href="javascript:history.go(-1)"><-- Go Back</a>* iswm %sock) { unset %quest.read }
if (%quest.read == 1) {
did -a questhelp 2 $htmlstrip(%sock)
}
if (*<td class="header">Start point:</td>* iswm %sock) { set %quest.read 1 }
}
}
on *:sockclose:quest: {
unset %quest
unset %quest.read
did -e questhelp 2
}
on *:sockopen:questupdate: {
sockwrite -n $sockname GET /quests.php HTTP/1.1
sockwrite -n $sockname Host: zybez.net $+ $crlf $+ $crlf
}
on *:sockread:questupdate: {
if ($sockerr) { did -a questhelp 2 An error occured while updating the quests. Please try again later. | halt }
else {
var %sock
sockread %sock
var %sock = $remove(%sock,(picture))
if (%read == 1) {
if (*/quests.php?id=* !iswm %sock) { halt }
tokenize 64 $replace($remove(%sock,<td class="tablebottom">,"tablebottom">,<a href=",</a></td>),">,@)
write quest.txt $2 $+ @ $+ $1
unset %read
}
if (*tr align="center"* iswm %sock) { set %read 1 }
}
}
on *:sockclose:questupdate: {
did -e questhelp 2
did -a questhelp 2 Listing Quests:
var %s = 1
while ($read(Quest.txt,%s)) {
did -a questhelp 2 $gettok($read(Quest.txt,%s),1,64)
inc %s
}
}