|
Joined: Oct 2003
Posts: 34
Ameglian cow
|
OP
Ameglian cow
Joined: Oct 2003
Posts: 34 |
Hey everyone. I have this really weird problem with these sockets I'm making.. Check out my code, and then I'll explain.. alias striptags { var %x,%y = $regsub($1-,/(<[^>]+>)/g,$null,%x) | return %x }
alias stats {
set %stats.called.nick $me
set %stats.name $1-
sockopen stats secure2.runescape.com 80
}
on *:text:!stats*:* {
if ($left($2,1) == -) { set %stats.name $replace($3-,$chr(32),+) }
else { set %stats.name $replace($2-,$chr(32),+) }
if (($chan == #runescape && $network == Chat-Addict) || ($network == GameSurge && $chan != #stats)) { halt }
if ($sock(stats).status != $null) { notice $nick The stats script is currently in use. Try again.... now! | halt }
if ($len($remove(%stats.name,$chr(32))) > 12) { notice $nick Error: name too long. | halt }
if ($left($2,1) == -) {
if (e isin $2) { set %called.exp 1 }
if (r isin $2) { set %called.rank 1 }
}
set %stats.called.nick $nick
sockopen stats secure2.runescape.com 80
}
on *:sockopen:stats: {
sockwrite -nt stats GET /aff/runescape/mod/hiscore/hiscorepersonal.cgi?username= $+ %stats.name HTTP/1.1
sockwrite -nt stats Host: secure2.runescape.com
sockwrite stats $crlf
}
on *:sockread:stats: {
var %read
sockread %read
var %read $striptags(%read)
if (%read == &nbsp;) { set %counter 5 }
if (%counter != $null) {
if (%counter == 4) { set %currentstat %read }
if (%counter == 3) { set %stat. $+ %currentstat $+ . $+ rank %read }
if (%counter == 2) { set %stat. $+ %currentstat $+ . $+ level %read }
if (%counter == 1) { set %stat. $+ %currentstat $+ . $+ exp %read }
echo -s %read
dec %counter 1
}
}
on *:sockclose:stats: {
var %count 0
while %count < $var(%stat.*.level,0) {
inc %count 1
if (%count != 1) { set %message %message $chr(124) }
set %message %message $right($left($var(%stat.*.level,%count),$calc($len($var(%stat.*.level,%count))-6)),$calc($len($left($var(%stat.*.level,%count),$calc($len($var(%stat.*.level,%count))-6)))-6)) $+ : $eval($var(%stat.*.level,%count),2)
}
var %count 0
if (%called.exp == 1) {
while %count < $var(%stat.*.exp,0) {
inc %count 1
if (%count > 1) { set %message.exp %message.exp $chr(124) }
set %message.exp %message.exp $right($left($var(%stat.*.exp,%count),$calc($len($var(%stat.*.exp,%count))-4)),$calc($len($left($var(%stat.*.exp,%count),$calc($len($var(%stat.*.exp,%count))-6)))-4)) $+ : $eval($var(%stat.*.exp,%count),2)
}
}
notice %stats.called.nick Stats for 4 $+ $replace(%stats.name,+,$chr(32)) $+ : $replace(%message,Overall,Skill Total)
if (%called.exp == 1) { notice %stats.called.nick Experience for 4 $+ $replace(%stats.name,+,$chr(32)) $+ : %message.exp }
unset %message
unset %message.exp
unset %stats.called.nick
unset %stat.*
unset %counter
} The script is a !stats remote, to find highscores for runescape ( www.runescape.com). The problem is that it doesn't get the variables. Put the script in your remotes and see what I mean since it is hard to explain. Right now, as it is, it works fine. However, if you take out line 35 (echo -s %read) , it doesn't work. It just doesn't make sense, it works when I echo it, but not when I don't... It almost seems like a bug to me. Can anyone help?
|
|
|
|
Joined: Dec 2002
Posts: 102
Vogon poet
|
Vogon poet
Joined: Dec 2002
Posts: 102 |
var %read $striptags(%read)
Does the problem persist if you change that line above to:
var %read = $striptags(%read)
By definition /set does not require an equal sign to be used but /var does, so does a simple reassignment without either command:
%read = $striptags(%read)
- MIMP
|
|
|
|
Joined: Oct 2003
Posts: 34
Ameglian cow
|
OP
Ameglian cow
Joined: Oct 2003
Posts: 34 |
Unfortunately no, that doesn't solve the problem... I'll post something in a few minutes to explain what happens..
|
|
|
|
Joined: Oct 2003
Posts: 34
Ameglian cow
|
OP
Ameglian cow
Joined: Oct 2003
Posts: 34 |
Ok, check this out. For example, I will use the #1 player in the game (zezima).. now, here is my updated code alias striptags { var %x,%y = $regsub($1-,/(<[^>]+>)/g,$null,%x) | return %x }
alias stats {
set %stats.called.nick $me
set %stats.name $1-
sockopen stats secure2.runescape.com 80
}
on *:text:!stats*:* {
if ($left($2,1) == -) { set %stats.name $replace($3-,$chr(32),+) }
else { set %stats.name $replace($2-,$chr(32),+) }
if (($chan == #runescape && $network == Chat-Addict) || ($network == GameSurge && $chan != #stats)) { halt }
if ($sock(stats).status != $null) { notice $nick The stats script is currently in use. Try again.... now! | halt }
if ($len($remove(%stats.name,$chr(32))) > 12) { notice $nick Error: name too long. | halt }
if ($left($2,1) == -) {
if (e isin $2) { set %called.exp 1 }
if (r isin $2) { set %called.rank 1 }
}
set %stats.called.nick $nick
sockopen stats secure2.runescape.com 80
}
on *:sockopen:stats: {
sockwrite -nt stats GET /aff/runescape/mod/hiscore/hiscorepersonal.cgi?username= $+ %stats.name HTTP/1.1
sockwrite -nt stats Host: secure2.runescape.com
sockwrite stats $crlf
}
on *:sockread:stats: {
var %read
sockread %read
var %read = $striptags(%read)
if (%read == &nbsp;) { set %counter 5 }
if (%counter != $null) {
if (%counter == 4) { set %currentstat %read }
if (%counter == 3) { set %stat. $+ %currentstat $+ . $+ rank %read }
if (%counter == 2) { set %stat. $+ %currentstat $+ . $+ level %read }
if (%counter == 1) { set %stat. $+ %currentstat $+ . $+ exp %read }
echo -s %read
dec %counter 1
}
}
on *:sockclose:stats: {
if (%called.nolvls == $null) { get_lvls_message }
if (%called.exp == 1) { get_experience_message }
if (%called.rank == 1) { get_ranks_message }
if (%called.nolvls == $null) { notice %stats.called.nick Stats for 4 $+ $replace(%stats.name,+,$chr(32)) $+ : $replace(%message,Overall,Skill Total) }
if (%called.exp == 1) { notice %stats.called.nick Experience for 4 $+ $replace(%stats.name,+,$chr(32)) $+ : %message.exp }
if (%called.rank == 1) { notice %stats.called.nick Ranks for 4 $+ $replace(%stats.name,+,$chr(32)) $+ : %message.ranks }
unset %message
unset %message.ranks
unset %message.exp
unset %stats.called.nick
unset %stat.*
unset %counter
unset %called.*
}
alias get_experience_message {
var %count 0
while %count < $var(%stat.*.exp,0) {
inc %count 1
if (%count > 1) { set %message.exp %message.exp $chr(124) }
set %message.exp %message.exp $right($left($var(%stat.*.exp,%count),$calc($len($var(%stat.*.exp,%count))-4)),$calc($len($left($var(%stat.*.exp,%count),$calc($len($var(%stat.*.exp,%count))-6)))-4)) $+ : $eval($var(%stat.*.exp,%count),2)
}
}
alias get_lvls_message {
var %count 0
while %count < $var(%stat.*.level,0) {
inc %count 1
if (%count != 1) { set %message %message $chr(124) }
set %message %message $right($left($var(%stat.*.level,%count),$calc($len($var(%stat.*.level,%count))-6)),$calc($len($left($var(%stat.*.level,%count),$calc($len($var(%stat.*.level,%count))-6)))-6)) $+ : $eval($var(%stat.*.level,%count),2)
}
}
alias get_ranks_message {
var %count = 0
while %count < $var(%stat.*.rank,0) {
inc %count 1
if (%count != 1) { set %message.ranks %message.ranks $chr(124) }
set %message.ranks %message.ranks $right($left($var(%stat.*.rank,%count),$calc($len($var(%stat.*.rank,%count))-5)),$calc($len($left($var(%stat.*.rank,%count),$calc($len($var(%stat.*.rank,%count))-5)))-6)) $+ : $eval($var(%stat.*.rank,%count),2)
}
} Now, to see the problem i'm talking about, put that in your remotes, and get someone to type !stats -er zezima.. Right now, it works just as it is supposed to.. However, try removing line 35 (echo -s %read).. now get someone to use the exact same triggger.. The first time you'll get this: 2:00.21 PM | -> -foobot- Stats for zezima: Skill Total: 1,728 | Attack: 95 | Defence: 94 | Strength: 98 | Hitpoints: 96 | Ranged: 85 | Prayer: 68 | Magic: 99 | Cooking: 99 | Woodcutting: 99 | Fletching: 95 | Fishing: 99 | Firemaking: 99 | Crafting: 79 | Smithing: 99 | Mining: 99 | Herblore: 76 | Agility: 99 | Thieving: 95 | Runecrafting: 55 2:00.21 PM | -> -foobot- Experience for zezima: Overall: 173,973,091 | Attack: 9,015,905 | Defence: 7,963,670 | Strength: 12,301,708 | Hitpoints: 9,691,415 | Ranged: 3,260,371 | Prayer: 642,345 | Magic: 13,039,546 | Cooking: 13,810,836 | Woodcutting: 13,034,489 | Fletching: 9,268,202 | Fishing: 13,061,903 | Firemaking: 13,036,168 | Crafting: 1,914,523 | Smithing: 16,783,600 | Mining: 13,053,208 | Herblore: 1,390,221 | Agility: 13,034,464 | Thieving: 9,503,581 | Runecrafting: 166,936 2:00.21 PM | -> -foobot- Ranks for zezima: Overall: 1 | Attack: 149 | Defence: 108 | Strength: 272 | Hitpoints: 169 | Ranged: 144 | Prayer: 537 | Magic: 116 | Cooking: 78 | Woodcutting: 18 | Fletching: 19 | Fishing: 53 | Firemaking: 44 | Crafting: 233 | Smithing: 7 | Mining: 24 | Herblore: 192 | Agility: 7 | Thieving: 44 | Runecrafting: 46 It works perfectly.. but the second time, you'll get this: 2:00.58 PM | -> -foobot- Stats for zezima: Skill Total: 1,728 | Attack: 95 | Defence: 94 | Strength: 98 | Hitpoints: 96 | Ranged: 85 | Prayer: 68 | Magic: 99 | Cooking: 99 | Woodcutting: 99 | Fletching: 95 | Fishing: 99 | Firemaking: 99 | Crafting: 79 | Smithing: 99 | Mining: 99 | Herblore: 76 | Agility: 99 | Thieving: 95 | Runecrafting: 55 2:00.58 PM | -> -foobot- Experience for zezima: Overall: | Attack: | Defence: | Strength: | Hitpoints: | Ranged: | Prayer: | Magic: | Cooking: | Woodcutting: | Fletching: | Fishing: | Firemaking: | Crafting: | Smithing: | Mining: | Herblore: | Agility: | Thieving: | Runecrafting: 2:00.58 PM | -> -foobot- Ranks for zezima: Overall: 1 | Attack: 149 | Defence: 108 | Strength: 272 | Hitpoints: 169 | Ranged: 144 | Prayer: 537 | Magic: 116 | Cooking: 78 | Woodcutting: 18 | Fletching: 19 | Fishing: 53 | Firemaking: 44 | Crafting: 233 | Smithing: 7 | Mining: 24 | Herblore: 192 | Agility: 7 | Thieving: 44 | Runecrafting: 46 it doesn't get the experience variables unless i have that echo in there.. I don't understand it..
|
|
|
|
Joined: Oct 2003
Posts: 8
Nutrimatic drinks dispenser
|
Nutrimatic drinks dispenser
Joined: Oct 2003
Posts: 8 |
Try the following:
alias striptags {
var %x, %y = $regsub($1-,/(<[^>]+>)/g,$null,%x)
return %x
}
alias stats {
set %stats.called.nick $me
set %stats.name $1-
sockopen stats secure2.runescape.com 80
}
on *:text:!stats*:* {
if ( ($chan == #runescape && $network == Chat-Addict) || ($network == GameSurge && $chan != #stats) ) {
return
}
else if ($sock(stats).status != $null) {
notice $nick The stats script is currently in use. Try again.... now!
return
}
else {
$iif( ($left($2,1) == $chr(45)), set %stats.name $replace($3-,$chr(32),+), set %stats.name $replace($2-,$chr(32),+) )
if ( $len(%stats.name) > 12) {
notice $nick Error: name too long.
return
}
else {
if ($left($2,1) == -) {
if (e isin $2) {
set %called.exp 1
}
if (r isin $2) {
set %called.rank 1
}
}
set %stats.called.nick $nick
sockopen stats secure2.runescape.com 80
}
}
}
on *:sockopen:stats:{
sockwrite -nt stats GET /aff/runescape/mod/hiscore/hiscorepersonal.cgi?username= $+ %stats.name HTTP/1.0
sockwrite -nt stats Host: secure2.runescape.com
sockwrite -nt stats User-Agent: Mozilla Compatible
sockwrite -nt stats Connection: Close
sockwrite stats $crlf
}
on *:sockread:stats:{
if ($sockerr > 0) {
notice $nick Error: Try again later.
}
:nextread
var %read
sockread -f %read
if ($sockbr == 0) {
return
}
var %read = $striptags(%read)
if (%read == &nbsp;) {
set %counter 5
}
if (%read == $null) {
goto nextread
}
else if (%counter != $null) {
if (%counter == 4) {
set %currentstat %read
}
else if (%counter == 3) {
set %stat. $+ %currentstat $+ . $+ rank %read
}
else if (%counter == 2) {
set %stat. $+ %currentstat $+ . $+ level %read
}
else if (%counter == 1) {
set %stat. $+ %currentstat $+ . $+ exp %read
}
dec %counter 1
}
goto nextread
}
on *:sockclose:stats:{
if (%called.nolvls == $null) {
get_lvls_message
}
if (%called.exp == 1) {
get_experience_message
}
if (%called.rank == 1) {
get_ranks_message
}
if (%called.nolvls == $null) {
notice %stats.called.nick Stats for 4 $+ $replace(%stats.name,+,$chr(32)) $+ : $replace(%message,Overall,Skill Total)
}
if (%called.exp == 1) {
notice %stats.called.nick Experience for 4 $+ $replace(%stats.name,+,$chr(32)) $+ : %message.exp
}
if (%called.rank == 1) {
notice %stats.called.nick Ranks for 4 $+ $replace(%stats.name,+,$chr(32)) $+ : %message.ranks
}
unset %message
unset %message.ranks
unset %message.exp
unset %stats.called.nick
unset %stat.*
unset %counter
unset %called.*
}
alias get_experience_message {
var %count 0
while %count < $var(%stat.*.exp,0) {
inc %count 1
if (%count > 1) {
set %message.exp %message.exp $chr(124)
}
set %message.exp %message.exp $right($left($var(%stat.*.exp,%count),$calc($len($var(%stat.*.exp,%count))-4)),$calc($len($left($var(%stat.*.exp,%count),$calc($len($var(%stat.*.exp,%count))-6)))-4)) $+ : $eval($var(%stat.*.exp,%count),2)
}
}
alias get_lvls_message {
var %count 0
while %count < $var(%stat.*.level,0) {
inc %count 1
if (%count != 1) {
set %message %message $chr(124)
}
set %message %message $right($left($var(%stat.*.level,%count),$calc($len($var(%stat.*.level,%count))-6)),$calc($len($left($var(%stat.*.level,%count),$calc($len($var(%stat.*.level,%count))-6)))-6)) $+ : $eval($var(%stat.*.level,%count),2)
}
}
alias get_ranks_message {
var %count = 0
while %count < $var(%stat.*.rank,0) {
inc %count 1
if (%count != 1) {
set %message.ranks %message.ranks $chr(124)
}
set %message.ranks %message.ranks $right($left($var(%stat.*.rank,%count),$calc($len($var(%stat.*.rank,%count))-5)),$calc($len($left($var(%stat.*.rank,%count),$calc($len($var(%stat.*.rank,%count))-5)))-6)) $+ : $eval($var(%stat.*.rank,%count),2)
}
}
And your Strip function needs fixing up: <a href="hiscoreuser.cgi?username=z ezima&category=4" class=c>Hitpoints <a href="hiscoreuser.cgi?username=zezima&category=18" clas s=c>Thieving Other than those two the rest seemed to be stripped fine and all worked. Enjoy
|
|
|
|
|