In the last week or so, a script that I've had no problem whatsoever with started giving some odd errors for anybody that used it.
It's a RPG battle script, but the part that's messing up is the section of code that uses sockets to connect to my webpage and download a character's stats. Here's the code:
alias wave-grabstats {
:name
set -n %wavestorm-name $input(Please enter your player name,eoi,Wavestorm,%wavename)
set -n %wavename %wavestorm-name
if (!%wavestorm-name) { goto name }
:password
set -n %wavestorm-password $input(Please enter your password,poi,Wavestorm,%wavepassword)
set -n %wavepassword %wavestorm-password
if (!%wavestorm-password) { goto password }
if ($sock(wavestormgrab)) { sockclose wavestormgrab }
sockopen wavestormgrab www.wavestorm.info 80
display3 %wavechat Retrieving stats for %wavestorm-name $+ ...
set %wavestorm-sockettime 1
.timerwavestorm-sockettime 0 1 inc %wavestorm-sockettime 1
}
on *:sockopen:wavestormgrab: {
sockwrite -tn $sockname GET /Player2.php?data=get&player= $+ $replace(%wavestorm-name,$chr(32),$chr(37) $+ 20)
$+ &password= $+ $replace(%wavestorm-password,$chr(32),$chr(37) $+ 20) HTTP/1.1
sockwrite -tn $sockname Host: www.wavestorm.info $+ $crlf $+ $crlf
sockwrite -tn $sockname Connection: Keep-Alive
sockwrite -tn $sockname $crlf
}
on *:sockread:wavestormgrab: {
if ($sockerr) {
echo -a Error: Stats not retrieved! $sockerr
unset %wavestorm-name
unset %wavestorm-password
return
}
var %temptext
sockread %temptext
if ($left(%temptext,9) == $+(stats,$chr(61),yes)) {
set %wavestorm-grabstats 1
if ($hget(Player)) { hfree Player }
wavewindowreset
hmake Player 100
var %socktemp = 2
:socktemp
hadd -m Player $gettok($gettok(%temptext,%socktemp,126),1,61) $gettok($gettok(%temptext,%socktemp,126),2,61)
inc %socktemp 1
if (%socktemp <= $numtok(%temptext,126)) { goto socktemp }
}
elseif ($left(%temptext,9) == $+(stats,$chr(61),no1)) { set %wavestorm-grabstats 2 }
elseif ($left(%temptext,9) == $+(stats,$chr(61),no2)) { set %wavestorm-grabstats 3 }
elseif ($left(%temptext,9) == $+(stats,$chr(61),no3)) { set %wavestorm-grabstats 4 }
if (!%wavestorm-grabstats) { set %wavestorm-grabstats 5 }
}
on *:sockclose:wavestormgrab: {
.timerwavestorm-sockettime off
if (%wavestorm-sockettime == 1) { var %wavestorm-dummysocket = 1 second }
else { var %wavestorm-dummysocket = %wavestorm-sockettime seconds }
if (%wavestorm-grabstats == 1) {
display3 %wavechat Stats successfully retrieved! ( $+ %wavestorm-dummysocket $+ )
if (!window(@Wavestorm)) { wavewindow }
else { wavewindowreset }
if ($dialog(options)) { optionsrefresh }
}
elseif (%wavestorm-grabstats == 2) { display3 %wavechat Error:
The character %wavestorm-name does not exist. Stats not retrieved! ( $+ %wavestorm-dummysocket $+ ) }
elseif (%wavestorm-grabstats == 3) { display3 %wavechat Error:
Incorrect password. Stats not retrieved! ( $+ %wavestorm-dummysocket $+ ) }
elseif (%wavestorm-grabstats == 4) { display3 %wavechat Error:
Database down. Stats not retrieved! ( $+ %wavestorm-dummysocket $+ ) }
elseif (%wavestorm-grabstats == 5) { display3 %wavechat Error:
Incorrect webpage syntax. Stats not retrieved! ( $+ %wavestorm-dummysocket $+ ) }
unset %wavestorm-name
unset %wavestorm-password
unset %wavestorm-grabstats
unset %wavestorm-sockettime
}
I've manually split several of those lines (the GET statement, the error messages) so people reading this don't have to scroll right indefinitely, but they're all one line apiece. There's various aliases in there that I won't bother to explain in detail; they basically have to do with clearing and regenerating the associated custom window attached to this script after purging/getting stats. As you can see above, the script basically uses a socket to connect to the following link:
http://www.wavestorm.info/Player2.php?data=get&player=YOURNAME&password=YOURPASSWORDI'd give you a name and password to let you all test, but... you know. Anyways, what comes up on the page if you look at it in a web browser is something similar to the following:
PlayerStats
stats=yes~Gender=Male~Level=57~HealthPoints=5698~MagicPoints=564~AbilityPoints=15~CurrentExperience=384~
NeededExperience=29683~Credits=50039~Wavelength=4~Color=Blue~Weapon=2~Weaponname=Staff~Modifier=j~
Modifiera=1~Modifierb=1~Modifierc=1~Modifierd=1~Modifiere=1~Modifierf=1~Modifierg=1~Modifierh=1~Modifieri=1~
Modifierj=1~Wins=1~Losses=2~Item1=0~Item2=0~Item3=0~Item4=0~Item5=0~Item6=0~Item7=0~Item8=0~Item9=0~
Item10=0~Item11=0~Item12=0~Item13=0~Item14=0~Item15=0~Item16=0~Item17=0~Item18=0~Item19=0~Item20=0~
Item21=0~Item22=0~Item23=0~Item24=0~Item25=0~Item26=0~Item27=0~Item28=0~Item29=0~Item30=0~Item31=0~
Item32=0~Item33=0~Item34=0~Item35=0~Item36=0~Item37=0~Item38=0~Item39=0~Item40=0~Item41=0~Item42=0~
Item43=0~Item44=0~Item45=0~Item46=0~Item47=0~Item48=0~Item49=0~Item50=0~Item51=0~Item52=0~Item53=0~
Item54=0~Item55=0~Item56=0~Spell1=1~Spell2=1~Spell3=1~Spell4=1~Spell5=0~Spell6=0~Spell7=0
Once again, from "stats=yes" to "Spell7=1" is one line; I've just split it manually so as not to make everyone who views this page have to scroll right forever while reading. The script just uses tokens to seperate that entire bit into a hash table. Normally. And other sites, such as this
HTTP Request Viewer, also show a similarly fine layout, like this:
<HTML><HEAD><TITLE>Player·Stats</TITLE></HEAD><BODY><H1>Player·Stats</H1>(LF)
(LF)
stats=yes~Gender=Male~Level=57~HealthPoints=5698~MagicPoints=564~AbilityPoints=15~CurrentExperience=384~etc.(LF)
</BODY></HTML>
Now, the problem is mIRC. When you use the socket to connect, the information read is basically what's in the following text file.
http://www.wavestorm.info/Extra/socket.txtWhere did all those random letters and numbers come from? Is it a problem with mIRC or my code? I can't see it being a problem with the webpage, not when seperate viewers and browsers show it just fine.