mIRC Homepage
Posted By: moshkin What is wrong with this script? - 13/05/08 03:54 PM
Its for a game, there is a ranking of your stats on the game on www.runehead.com/clans/ml.php?clan=tbl_admin&skill=Attack&sort=lvl
I want a person to be able to check there rank on that site. Im pretty sure I went about it the wrong way, any help would be appreciated.
and could someone explain how the script identifies what line to use, because im using a socket creator at the moment as im still learning how to make a proper socket.
Code:
 on *:text:!tatt*:#: {
  if ($sock(Attack)) .sockclose Attack
  set %chan $chan
  set %nick $nick
  set %attackname $2
  sockopen Attack www.runehead.com 80
}
on *:SOCKOPEN:Attack: {
  sockwrite -nt $sockname GET /clans/ml.php?clan=tbl_admin&skill=Attack&sort=lvl HTTP/1.1
  sockwrite -nt $sockname Host: www.runehead.com
  sockwrite -nt $sockname $crlf
}
on *:SOCKREAD:Attack: {
  if ($sockerr) {
    msg %chan Socket Error: $sockname $+ . Error code: $sockerr Please inform $me of this error message.
    halt
  }
  else {
    var %sockreader
    sockread %sockreader
    if (*%attackname* iswm %sockreader ) {
      set %Attacklvl $nohtml(%sockreader)
      msg %chan The att lvl of %attackname is: %Attacklvl
      unset %chan
      unset %nick
      sockclose Attack
    }
  }
}
Posted By: Lpfix5 Re: What is wrong with this script? - 13/05/08 03:57 PM
Well without testing I see immediately you do not contain your sockname in the sockread event

you wrote overall instead of Attack, Attack would be the socket name to "read"
Posted By: moshkin Re: What is wrong with this script? - 13/05/08 03:59 PM
Sorry, noticed that too, just changed it and it still didnt work.
Posted By: Lpfix5 Re: What is wrong with this script? - 13/05/08 05:27 PM
Originally Posted By: moshkin
Its for a game, there is a ranking of your stats on the game on www.runehead.com/clans/ml.php?clan=tbl_admin&skill=Attack&sort=lvl
I want a person to be able to check there rank on that site. Im pretty sure I went about it the wrong way, any help would be appreciated.
and could someone explain how the script identifies what line to use, because im using a socket creator at the moment as im still learning how to make a proper socket.
Code:
 on *:text:!tatt*:#: {
  if ($sock(Attack)) .sockclose Attack
  set %chan $chan
  set %nick $nick
  set %attackname $2
  sockopen Attack www.runehead.com 80
}
on *:SOCKOPEN:Attack: {
  sockwrite -nt $sockname GET /clans/ml.php?clan=tbl_admin&skill=Attack&sort=lvl HTTP/1.1
  sockwrite -nt $sockname Host: www.runehead.com
  sockwrite -nt $sockname $crlf
}
on *:SOCKREAD:Attack: {
  if ($sockerr) {
    msg %chan Socket Error: $sockname $+ . Error code: $sockerr Please inform $me of this error message.
    halt
  }
  else {
    var %sockreader
    sockread %sockreader
    if (*%attackname* iswm %sockreader ) {
      set %Attacklvl $nohtml(%sockreader)
      msg %chan The att lvl of %attackname is: %Attacklvl
      unset %chan
      unset %nick
      sockclose Attack
    }
  }
}


Moshkin

A) Im not sure how your $nohtml() is parsing data
B) You are trying to find a word match which is fine
C) in the sockred command you are trying to retrieve the attack levels of the word match.

However, if you dump the HTML raw youll notice that the levels are on a different line then the actual nick of person, therefore you need to either make a regex routine (i dont wanna go there) or store temporarly to file the information so you can retrieve it I.E: I used .txt file with $read command.

Here is the code

Code:
on *:text:!tatt*:#: {
  if ($sock(Attack)) .sockclose Attack
  set %att.c $chan
  set %att.name $$2
  .remove atttemp.txt
  sockopen Attack www.runehead.com 80
  .timer 1 3 /attax
}
on *:SOCKOPEN:Attack: {
  sockwrite -nt $sockname GET /clans/ml.php?clan=tbl_admin&skill=Attack&sort=lvl HTTP/1.1
  sockwrite -nt $sockname Host: www.runehead.com
  sockwrite -nt $sockname $crlf
}
on *:SOCKREAD:Attack: {
  if ($sockerr) {
    msg %chan Socket Error: $sockname $+ . Error code: $sockerr Please inform $me of this error message.
    halt
  }
  else {
    var %f | sockread %f
    .write atttemp.txt $nhtml(%f)
  }
}

alias attax {
  noop $read(atttemp.txt,w,$+(*, %att.name ,*))
  var %x = $readn
  msg %att.c The att lvl of %attackname is: Attack Rank: $read(atttemp.txt,$calc(%x + 1)) Attack Level: $read(atttemp.txt,$calc(%x + 2)) Attack XP: $read(atttemp.txt,$calc(%x + 3))
}

alias -l nhtml { return $remove($regsubex($1-,/(&nbsp;|&deg;|^[^<]*>|<[^>]*>|<[^>]|&nbsp;*$)/g,),$chr(9)) }
Posted By: Lpfix5 Re: What is wrong with this script? - 13/05/08 05:33 PM
I just want to put a side note, (mirc forum aint letting me edit)

that whenever you want to see how the data is dumped echo it back to you in this example

var %f | sockread %f
echo -a $nhtml(%f)

you would see that the ranks are on different lines
© mIRC Discussion Forums