on *:start: {
if (!$hget(NewGameData)) {
hmake NewGameData 100
if ($isfile($+(",$scriptdir\NewGameData.hsh"))) { hload NewGameData $+(",$scriptdir\NewGameData.hsh") }
}
if (!$hget(OldGameData)) {
hmake OldGameData 100
if ($isfile($+(",$scriptdir\OldGameData.hsh"))) { hload OldGameData $+(",$scriptdir\OldGameData.hsh") }
}
.timerGameData 0 3600 GameData
}
; Socket Stuff
alias GameData {
if ($hget(OldGameData)) { hfree OldGameData }
if ($isfile($+(",$scriptdir\OldGameData.hsh"))) { .remove $+(",$scriptdir\OldGameData.hsh") }
if ($hget(NewGameData)) {
hsave NewGameData $+(",$scriptdir\NewGameData.hsh")
hfree NewGameData
}
hmake NewGameData 100
hmake OldGameData 100
if ($isfile($+(",$scriptdir\NewGameData.hsh"))) {
hload OldGameData $+(",$scriptdir\NewGameData.hsh")
hsave OldGameData $+(",$scriptdir\OldGameData.hsh")
}
sockopen GameData a.swirve.com 80
}
on *:sockopen:GameData: {
sockwrite -n $sockname GET /data/ranks.txt HTTP/1.0
sockwrite -n $sockname User-Agent: Mozilla/4.0 (compatible; MSIE 4.01; Windows NT)
sockwrite -n $sockname Host: a.swirve.com
sockwrite -n $sockname Accept-Language: en-us
sockwrite -n $sockname Accept-Encoding: gzip, deflate
sockwrite -n $sockname Accept: */* $+ $crlf $+ $crlf
}
on *:sockread:GameData: {
if ($sockerr) {
echo -a Error.
halt
}
else {
var %temptext
sockread %temptext
if (!%temptext) { hsave NewGameData $+(",$scriptdir\NewGameData.hsh") | halt }
tokenize 32 $gettok(%temptext,2-,41)
hadd NewGameData $gettok(%temptext,1,32) $gettok($gettok(%temptext,2-,32),1,40) 03§ $1 03§ $2 03§ $iif($5,$3 03§ $4 03§ $5,03§ $3 03§ $4)
}
}
; Trigger Stuff
on *:text:!who &:#yourchannel: {
if ($hget(NewGameData,$2)) {
msg $chan $2 $+ : $v1
}
else msg $chan No data on $2 $+ .
}
on *:text:!cpwho &:#yourchannel: {
if ($hget(OldGameData,$2) || $hget(NewGameData,$2)) {
if ($hget(OldGameData,$2) && $hget(NewGameData,$2)) {
msg $chan New Data for $2 $+ : $hget(NewGameData,$2)
msg $chan Old Data for $2 $+ : $hget(OldGameData,$2)
}
elseif ($hget(NewGameData,$2)) {
msg $chan New Data for $2 $+ : $hget(NewGameData,$2)
msg $chan Old Data for $2 $+ : N/A
}
else {
msg $chan New Data for $2 $+ : N/A
msg $chan Old Data for $2 $+ : $hget(OldGameData,$2)
}
}
else msg $chan No data on $2 $+ .
}
on *:input:#yourchannel: {
if ($1 == !who && $2) {
if ($hget(NewGameData,$2)) {
msg $chan $2 $+ : $v1
}
else msg $chan No data on $2 $+ .
}
elseif ($1 == !cpwho && $2) {
if ($hget(OldGameData,$2) || $hget(NewGameData,$2)) {
if ($hget(OldGameData,$2) && $hget(NewGameData,$2)) {
msg $chan New Data for $2 $+ : $hget(NewGameData,$2)
msg $chan Old Data for $2 $+ : $hget(OldGameData,$2)
}
elseif ($hget(NewGameData,$2)) {
msg $chan New Data for $2 $+ : $hget(NewGameData,$2)
msg $chan Old Data for $2 $+ : N/A
}
else {
msg $chan New Data for $2 $+ : N/A
msg $chan Old Data for $2 $+ : $hget(OldGameData,$2)
}
}
else msg $chan No data on $2 $+ .
}
}