mIRC Home    About    Download    Register    News    Help

Print Thread
#178634 13/06/07 06:51 AM
Joined: Jun 2007
Posts: 5
U
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
U
Joined: Jun 2007
Posts: 5
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
    }
  }

Joined: Dec 2002
Posts: 503
B
Fjord artisan
Offline
Fjord artisan
B
Joined: Dec 2002
Posts: 503
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.

Bekar #178637 13/06/07 07:40 AM
Joined: Jun 2007
Posts: 5
U
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
U
Joined: Jun 2007
Posts: 5
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 ?

Last edited by UberGamer; 13/06/07 07:47 AM.
Joined: Dec 2002
Posts: 503
B
Fjord artisan
Offline
Fjord artisan
B
Joined: Dec 2002
Posts: 503
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
  }



Link Copied to Clipboard