mIRC Home    About    Download    Register    News    Help

Print Thread
Sockets Help #86051 09/06/04 06:51 AM
Joined: Jun 2003
Posts: 56
G
Gamersad Offline OP
Babel fish
OP Offline
Babel fish
G
Joined: Jun 2003
Posts: 56
Alright.. here is what we have going.. The popular game runescape has hiscores that are avalable on their website.. and we have it so you can type !stats <username> and the hiscores come up ONLY problem is it only displays the stats you can have. Not the actual level. Here is the code we have going so far

Code:

alias stat { set %rs.statname $1 | sockopen stat hiscore.runescape.com 80 }
alias -l htmlfree var %x, %i = $regsub($1-,/(^[^&lt;]*&gt;|&lt;[^&gt;]*&gt;|&lt;[^&gt;]*$)/g,$null,%x), %x = $remove(%x,&amp;nbsp;) | return %x
on *:text:!stats*:#: {
  if ($network == windfyre) {
    stat $2
  }
}
on *:SOCKOPEN:stat: {
  var %url = /aff/runescape/hiscorepersonal.cgi?username= %rs.statname
  sockwrite -n $sockname GET %url HTTP/1.1
  sockwrite -n $sockname Host: hiscore.runescape.com $+ $crlf $+ $crlf
}
on *:input:#: { if ($1 == !stats) { stat $2 } }
on *:SOCKREAD:stat: {
  if ($sockerr &gt; 0) { return } 
  var %temptext | sockread %temptext
  if (*Attack&lt;/a&gt;&lt;/td&gt; iswm %temptext) {
    %rs.attack = %rs.attack $htmlfree(%temptext)
    set %rs.msg %rs.msg %rs.attack 
  }
  


that there plus Defence and WoodCutting and all the other stats only displays This:

!Stats Shenwu
Shenwuu :: Overall Attack Defence Strength Hitpoints Magic Cooking Woodcutting Firemaking Mining

Where attack is it needs to display the Attack Level, and so on down the list..

Someone else who made a script like this but isnt realising his code keeps syaing something about isnum <-- should be used.. But he says he doesnt know how to script yet he jumped right into sockets *rolls eyes*

Please try to help me out smile


- Andrew Berquist, Windfyre Network
Re: Sockets Help #86052 09/06/04 05:52 PM
Joined: Dec 2002
Posts: 1,922
O
Online Offline
Hoopy frood
Offline
Hoopy frood
O
Joined: Dec 2002
Posts: 1,922

Re: Sockets Help #86053 10/06/04 04:07 AM
Joined: Jun 2004
Posts: 5
M
Mjolnir Offline
Nutrimatic drinks dispenser
Offline
Nutrimatic drinks dispenser
M
Joined: Jun 2004
Posts: 5
hey, that stats script works great, BUT it only shows the first 8 or 9 stats on the hiscores page, one guys stats look like this from his script:

Attack 45 Defence 41 Strength 45 Hitpoints 45 Ranged 30 Cooking 33 Woodcutting 45 Fletching 38 Firemaking 30 Crafting 42 Smithing 44 Mining 60

^--- 12 different stats

well the one that was posted at http://members.lycos.co.uk/onln/files/runspace-stats.txt turns out like this

Overall = 554; Attack = 45; Defence = 41; Strength = 45; Hitpoints = 45; Cooking = 33; Woodcutting = 45; Firemaking = 30; Mining = 60;

^--- only 9, although it does include the overall portion which is good, it seems like it is being limited in some way, as to only showing the top 9 stats or something like that

__________________________

Nevermind, i figured it out, i'm such a dunce sometimes

Last edited by Mjolnir; 10/06/04 04:31 AM.
Re: Sockets Help #86054 10/06/04 09:27 AM
Joined: Dec 2002
Posts: 1,922
O
Online Offline
Hoopy frood
Offline
Hoopy frood
O
Joined: Dec 2002
Posts: 1,922
I'm glad it works for you, and that you were able to locate %RS.collect and add more entries to capture as needed.

Feel free to play with the code and PM if you need further help.

Re: Sockets Help #86055 10/06/04 04:09 PM
Joined: Jun 2004
Posts: 5
M
Mjolnir Offline
Nutrimatic drinks dispenser
Offline
Nutrimatic drinks dispenser
M
Joined: Jun 2004
Posts: 5
where it has, say Overall = 544; Attack = 45; etc... how would you change the Overall's color and the 544's color individually, so say, Overall = 544 Attack = 45

Re: Sockets Help #86056 10/06/04 04:27 PM
Joined: Dec 2002
Posts: 1,922
O
Online Offline
Hoopy frood
Offline
Hoopy frood
O
Joined: Dec 2002
Posts: 1,922
There's a coupe of set %RS.info lines in the script.

Change the first one to,

set %RS.info %RS.info 12 $+ %attrib

and the other one to:

set %RS.info %RS.info =04 %a

Re: Sockets Help #86057 10/06/04 04:33 PM
Joined: Jun 2004
Posts: 5
M
Mjolnir Offline
Nutrimatic drinks dispenser
Offline
Nutrimatic drinks dispenser
M
Joined: Jun 2004
Posts: 5
ahhh, i knew it had something to do with the set %rs.info, but i forgot that there were 2 of them, and only set one :P thanks a lot, it's exactly what we needed, lol, might have more socket questions sometime in the future for ya :P

Re: Sockets Help #86058 10/06/04 05:38 PM
Joined: Jun 2004
Posts: 5
M
Mjolnir Offline
Nutrimatic drinks dispenser
Offline
Nutrimatic drinks dispenser
M
Joined: Jun 2004
Posts: 5
ahh, i seem to have come up with another question, a friend on the server i use, has a "background" bot, which runs in the background, very useful, i love it, i'm trying to make the background bot and the stats bot work together, and have

sockwrite -tn beowulf PRIVMSG $2 :Collecting stats for %RS.statname $+ ...

in the alias stat part.... that works fine, Beowulf sends that msg, but when i try to send the stats.... it doesn't work..... i replaced the on sockclose event with this...
Code:
 On *:sockclose:stat:{
  if %RS.info {
    sockwrite -tn beowulf PRIVMSG $2 :Stats for %RS.statname $+ : %rs.info  
  }
  else {
    sockwrite -tn beowulf PRIVMSG $2 :Couldn't find stats for %RS.statname
  }
  unset %RS.*
} 


but it won't work, Beowulf won't send the stats msg, i put an echo %RS.info above the sockwrite part, and it will echo it, i was wondering if it has to do with the on sockclose event, so it won't actually write to the other socket?

Re: Sockets Help #86059 10/06/04 08:55 PM
Joined: Dec 2002
Posts: 1,922
O
Online Offline
Hoopy frood
Offline
Hoopy frood
O
Joined: Dec 2002
Posts: 1,922
All you need is to find the set %RS.output line, and change it to:

set %RS.output sockwrite -tn beowulf PRIVMSG $2 :

To avoid the small space that precedes the message, locate the rest of the %RS.output lines and change them to:

%RS.output $+ Error contacting website.
%RS.output $+ Stats for %RS.statname $+ :
%RS.output $+ %RS.info

(You may want to re-download the script if you already made deep changes.)

I hope this wasn't too confusing laugh

Re: Sockets Help #86060 10/06/04 09:26 PM
Joined: Jun 2004
Posts: 5
M
Mjolnir Offline
Nutrimatic drinks dispenser
Offline
Nutrimatic drinks dispenser
M
Joined: Jun 2004
Posts: 5
i wasn't kidding when i said i was a dunce sometime, that shoulda been the easiest thing for me to solve, but thanks, it works perfectly now, and thanks for writing out that socket, it helped a lot