mIRC Homepage

Sockets Help

Posted By: Gamersad

Sockets Help - 09/06/04 06:51 AM

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


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
Posted By: Online

Re: Sockets Help - 09/06/04 05:52 PM

Try this script.
Posted By: Mjolnir

Re: Sockets Help - 10/06/04 04:07 AM

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
Posted By: Online

Re: Sockets Help - 10/06/04 09:27 AM

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.
Posted By: Mjolnir

Re: Sockets Help - 10/06/04 04:09 PM

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
Posted By: Online

Re: Sockets Help - 10/06/04 04:27 PM

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
Posted By: Mjolnir

Re: Sockets Help - 10/06/04 04:33 PM

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
Posted By: Mjolnir

Re: Sockets Help - 10/06/04 05:38 PM

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...
 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?
Posted By: Online

Re: Sockets Help - 10/06/04 08:55 PM

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
Posted By: Mjolnir

Re: Sockets Help - 10/06/04 09:26 PM

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
© 2020 mIRC Discussion Forums