mIRC Home    About    Download    Register    News    Help

Print Thread
need some help plz #145877 29/03/06 02:32 AM
Joined: Mar 2006
Posts: 19
A
adamb53 Offline OP
Pikka bird
OP Offline
Pikka bird
A
Joined: Mar 2006
Posts: 19
well i am the kind of person that needs guidding through something so can some1 tell me if this is even close to being right so far, i dont want some1 to give me the script but to tell me if what i am doing is right:

/sockopen hpcomp runescape.com 80

on *:sockopen:hpcomp:{
sockwrite -n $sockname GET /lang/en/aff/runescape/hiscorepersonal.ws?user1= HTTP/1.1
sockwrite -n $sockname Host: runescape.com $+ $crlf $+ $crlf
}
on *:sockread:hpcomp:{
if ($sockerr) {
echo -a Error.
halt
}
else {
var %temptext
sockread %temptext
; handling here
}
}

i forgot to add that this is going to call the hp stats from runescape.com

Last edited by adamb53; 29/03/06 02:48 AM.
Re: need some help plz #145878 29/03/06 04:27 AM
Joined: Oct 2005
Posts: 1,741
G
genius_at_work Offline
Hoopy frood
Offline
Hoopy frood
G
Joined: Oct 2005
Posts: 1,741
That code looks like it should work. A couple things though:

You should use HTTP/1.0 in mIRC sockets, otherwise the server will send in bursts, and you will get strange numbers in your data.

To test if the connection is working, add an echo where you have:
; handling here.

Something like this:
echo 5 -s > %temptext

That should echo the entire contents of the website to the status window.

-genius_at_work

Re: need some help plz #145879 29/03/06 04:33 AM
Joined: Mar 2006
Posts: 19
A
adamb53 Offline OP
Pikka bird
OP Offline
Pikka bird
A
Joined: Mar 2006
Posts: 19
hmmm ok, i attempted to add some more and im starting to get confused and i think there is something wrong but ill post it:

Code:
/sockopen hpcomp runescape.com 80

on *:sockopen:hpcomp:{
  sockwrite -n $sockname GET /lang/en/aff/runescape/hiscorepersonal.ws?user1= $+ %user HTTP/1.0
  sockwrite -n $sockname Host: runescape.com $+ $crlf $+ $crlf
}
on *:sockread:hpcomp:{
  if ($sockerr) {
    echo -a Error.
    halt
  }
  else {
    var %temptext
    sockread %temptext
    echo 5 -s > %temptext
    if <span class="small text">Hitpoint stats: Starting Level: * , Current Level: * , Difference: *{
    echo -a -
    echo -a $htmlfree(%temptext)
  }
}
}
alias -l htmlfree {
; It's local because it won't be used by the command line, only this file.
; Local aliases avoid conflicting names.
var %x, %i = $regsub($1-,/(^[^<]*>|<[^>]*>|<[^>]*$)/g,$null,%x), %x = $remove(%x, )
return %x
}

alias hpcomp {
if ($2-) {
  set %user $2

  ; Variables to be used in the future URL are being set here!
  sockopen hpcomp runescape.com 80
}
else {
  echo -a You didn't specify a user and the info.
}
}

Re: need some help plz #145880 29/03/06 05:20 AM
Joined: Aug 2004
Posts: 7,252
R
RusselB Offline
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
You have an extra } at the end of your ON SOCKREAD event.

Re: need some help plz #145881 29/03/06 11:50 AM
Joined: Mar 2006
Posts: 19
A
adamb53 Offline OP
Pikka bird
OP Offline
Pikka bird
A
Joined: Mar 2006
Posts: 19
ok i fixed that, anything else wrong?

Code:
/sockopen hpcomp runescape.com 80

on *:sockopen:hpcomp:{
  sockwrite -n $sockname GET /lang/en/aff/runescape/hiscorepersonal.ws?user1= $+ %user HTTP/1.0
  sockwrite -n $sockname Host: runescape.com $+ $crlf $+ $crlf
}
on *:sockread:hpcomp:{
  if ($sockerr) {
    echo -a Error.
    halt
  }
  else {
    var %temptext
    sockread %temptext
    echo 5 -s > %temptext
    if <span class="small text">Hitpoint stats: Starting Level: * , Current Level: * , Difference: *{
    echo -a -
    echo -a $htmlfree(%temptext)
  }
}
alias -l htmlfree {
  ; It's local because it won't be used by the command line, only this file.
  ; Local aliases avoid conflicting names.
  var %x, %i = $regsub($1-,/(^[^<]*>|<[^>]*>|<[^>]*$)/g,$null,%x), %x = $remove(%x, )
  return %x
}

alias hpcomp {
  if ($2-) {
    set %user $2

    ; Variables to be used in the future URL are being set here!
    sockopen hpcomp runescape.com 80
  }
  else {
    echo -a You didn't specify a user and the info.
  }
}

Re: need some help plz #145882 29/03/06 03:05 PM
Joined: Oct 2005
Posts: 1,741
G
genius_at_work Offline
Hoopy frood
Offline
Hoopy frood
G
Joined: Oct 2005
Posts: 1,741
Your /sockopen command should be within an alias, like this:

Code:
alias rune {
  if ($sock(hpcomp)) sockclose hpcomp
  sockopen hpcomp runescape.com 80
  .timer 1 5 sockclose hpcomp
  echo -at Connecting to runescape
}


To start the connection, you would type /rune

-genius_at_work

Re: need some help plz #145883 30/03/06 02:35 AM
Joined: Mar 2006
Posts: 19
A
adamb53 Offline OP
Pikka bird
OP Offline
Pikka bird
A
Joined: Mar 2006
Posts: 19
my finaly code is:

Code:
on *:sockopen:hpcomp:{
  sockwrite -n $sockname GET /lang/en/aff/runescape/hiscorepersonal.ws?user1= $+ %user HTTP/1.0
  sockwrite -n $sockname Host: runescape.com $+ $crlf $+ $crlf
}
on *:sockread:hpcomp:{
  if ($sockerr) {
    echo -a Error.
    halt
  }
  else {
    var %temptext
    sockread %temptext
    echo 5 -s > %temptext
    if <span class="small text"> Hitpoint stats: Starting Level: * , Current Level: * , Difference: *{
    echo -a -
    echo -a $htmlfree(%temptext)
  }
}
alias -l htmlfree {
  ; It's local because it won't be used by the command line, only this file.
  ; Local aliases avoid conflicting names.
  var %x, %i = $regsub($1-,/(^[^<]*>|<[^>]*>|<[^>]*$)/g,$null,%x), %x = $remove(%x, )
  return %x
}

alias hpcomp {
  if ($2-) {
    set %user $2

    ; Variables to be used in the future URL are being set here!
    sockopen hpcomp runescape.com 80
  }
  else {
    echo -a You didn't specify a user and the info.
  }
}

alias rune {
  if ($sock(hpcomp)) sockclose hpcomp
  sockopen hpcomp runescape.com 80
  .timer 1 5 sockclose hpcomp
  echo -at Connecting to runescape
}

but when i try to use it, it says:

[21:34:21] Connecting to runescape <--- in the active window
* /if: 'class="small' unknown operator (line 16, script13.ini) <--- in status window

Re: need some help plz #145884 30/03/06 03:30 AM
Joined: Aug 2004
Posts: 7,252
R
RusselB Offline
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
simply put a space on either side of the equals sign in that line. I don't know if it makes a difference or not, but in most of the coding for a comparison, a == is used, rather than =

Just make sure you have a space on either side of the == or the =

Re: need some help plz #145885 30/03/06 03:51 AM
Joined: Oct 2005
Posts: 1,741
G
genius_at_work Offline
Hoopy frood
Offline
Hoopy frood
G
Joined: Oct 2005
Posts: 1,741
I don't see any actual comparison in that if-statement. Your code is like this:

if (SOMETHING) {

Which always evaluates to true. It should have a comparison in it like this:

if (SOMETHING == SOMETHING) {

Or in your case,

if (*wild*string* iswm %variable) {

Code:
if (&lt;span class="small text"&gt; Hitpoint stats: Starting Level: * , Current Level: * , Difference: * iswm %temptext) {


-genius_at_work

Re: need some help plz #145886 30/03/06 04:24 AM
Joined: Mar 2006
Posts: 19
A
adamb53 Offline OP
Pikka bird
OP Offline
Pikka bird
A
Joined: Mar 2006
Posts: 19
ok my code:

Code:
/sockopen hpcomp runescape.com 80

on *:sockopen:hpcomp:{
  sockwrite -n $sockname GET runescape.com/lang/en/aff/runescape/hiscorepersonal.ws?user1= $+ %user HTTP/1.0
  sockwrite -n $sockname Host: runescape.com $+ $crlf $+ $crlf
}
on *:sockread:hpcomp:{
  if ($sockerr) {
    echo -a Error.
    halt
  }
  else {
    var %temptext
    sockread %temptext
    echo 5 -s &gt; %temptext
    if (&lt;span+class == "small text"&gt;Hitpoint stats: Starting Level: * , Current Level: * , Difference: * iswm %temptext){
    echo -a -
    echo -a $htmlfree(%temptext)
  }
}
alias -l htmlfree {
  ; It's local because it won't be used by the command line, only this file.
  ; Local aliases avoid conflicting names.
  var %x, %i = $regsub($1-,/(^[^&lt;]*&gt;|&lt;[^&gt;]*&gt;|&lt;[^&gt;]*$)/g,$null,%x), %x = $remove(%x,&amp;nbsp;)
  return %x
}

alias hpcomp {
  if ($2-) {
    set %user $2

    ; Variables to be used in the future URL are being set here!
    sockopen hpcomp runescape.com 80
  }
  else {
    echo -a You didn't specify a user and the info.
  }
}

alias rune {
  if ($sock(hpcomp)) sockclose hpcomp
  sockopen hpcomp runescape.com 80
  .timer 1 5 sockclose hpcomp
  echo -at Connecting to runescape
}


and it says:

[23:25:05] Connecting to runescape
-
HTTP/1.1 404 Not found
-
Content-type: text/html
-
Cache-control: no-cache
-
Pragma: no-cache
-
Expires: 0
-
Connection: Close
-
Content-length: 549
-
404 - Page not found404 - Page not foundSorry, the page you were looking for was not found.

Re: need some help plz #145887 30/03/06 04:36 AM
Joined: Oct 2005
Posts: 1,741
G
genius_at_work Offline
Hoopy frood
Offline
Hoopy frood
G
Joined: Oct 2005
Posts: 1,741
Obviously, that result means that the page you are trying to view doesn't exist. Find the correct URL, and change it in your code.

Also, your sockwrite GET line is incorrect. It should be something like this:

sockwrite -n $sockname GET lang/en/aff/runescape/hiscorepersonal.ws?user1= $+ %user HTTP/1.0

That is assuming that you have set %user as a global variable somewhere else before you opened the socket.

Your if iswm line also has a problem. At the end of the line, there should be a space between the ) and {, like this:

if (<span...%temptext) {

When you fix that, you will have a } bracket mismatch. Add another } after the second /echo command.

-genius_at_work

Last edited by genius_at_work; 30/03/06 04:39 AM.