mIRC Homepage
Posted By: UberGamer Help Sock open - 13/06/07 06:51 AM
Hello , im having sum troubles with my sockopen script
and it always give back server offline i know its online but still say offline


Code:
Code:

on *:text:@status*:#:{
  /sockopen socktest (myip) (myport)

  on *:sockopen:socktest: if $sockerr {
  /msg $chan Server Offline }
  {
    else { /msg $chan server online  
      sockclose $sockname
    }
  }
Posted By: Bekar Re: Help Sock open - 13/06/07 07:20 AM
Umm, you can't "Nest" events.

Code:
ON *:TEXT:@status*:#: {
  sockopen socketst <ip> <port>
}
ON *:SOCKOPEN:SOCKTEST: {
  if $sockerr {
    msg <some channel> Server offline
  }
  else {
    msg <some channel> Server online
    sockclose $sockname
  }
}

Of course, as it's no longer in the ON TEXT event, '$chan' has no meaning, so you need to set it to a variable or something outside first.. but that opens you up to a whole swag load of interesting concepts you'll have to consider (unless you want to hard-wire to a specific channel).

If you give us some more details on what you're trying to do, we could give you more help.
Posted By: UberGamer Re: Help Sock open - 13/06/07 07:40 AM
Thanks it helped A lot and saved me sum time
i have only been scripting for a short period of time
i hope that i will learn some more , i noticed that you're from Melbourne Australia , i live in Sydney Australia wink

but one thing even when the the server isnt online say normal HTTP
Apache port 80 it still says online ?
Posted By: Bekar Re: Help Sock open - 13/06/07 08:15 AM
Melbourne here..

Hrm..

In my tests, if the IP address doesn't exist, or the port doesn't open, then $sockerr = 3, so, perhaps the code should be:

Code:
  if ($sockerr != 0) {
    msg <chan> Server offline
  }
  else {
    msg <chan> Server online
    sockclose $sockname
  }

© mIRC Discussion Forums