mIRC Homepage
Posted By: WarlockW get $network someone is on - - 17/10/05 08:08 PM
get the $network someone is on - from a different network?

trying to do a script that checks all networks i am on for a nick ..

and then gives me the $network that nick is on
so i can msg that nick ..

Any Ideas ?

Thanks ..
Posted By: hixxy Re: get $network someone is on - - 17/10/05 08:20 PM
Add them to your notify list with /notify <nick> then type //scid -at1 if ($notify(<nick>).ison) echo -s $!network
Posted By: WarlockW Re: get $network someone is on - - 17/10/05 08:39 PM
hmmm ..
cant seem to make it work ..

adds it to the notifi

but it does not echo ..

Not really what i need but may beable to make work smile

ideas ?
Posted By: HAMM3R Re: get $network someone is on - - 18/10/05 01:47 AM
Maybe something like this:
Code:
alias netcheck { 
  if ($1) { 
    scid -at1 whois $1 
    set %netcheck.total $scon(0) 
    set %netcheck.whois $1
  } 
  else { 
    echo -a ** Please specify the nick to scan for
  } 
}
raw 312:*: {
  if (%netcheck.whois) { 
    echo -a %netcheck.whois is connected to $network 
    if ($scid == %netcheck.total) {
      unset %netcheck.total | unset %netcheck.whois 
    }
  }
}


Good luck.
smile
Posted By: WarlockW Re: get $network someone is on - - 18/10/05 01:59 AM
thats cool ..

yea works well .. but need something that after it finds the person it msg them some text ..
Posted By: HAMM3R Re: get $network someone is on - - 18/10/05 02:11 AM
You want to mesage the same person the same text on all the networks they're on? shocked
Posted By: HAMM3R Re: get $network someone is on - - 18/10/05 02:15 AM
I'd suggest you didnt, but if that's what you really want, try this:
Code:
alias netcheck { 
  if ($1) { 
    scid -at1 whois $1 
    set %netcheck.total $scon(0) 
    set %netcheck.whois $1
  } 
  else { 
    echo -a ** Please specify the nick to scan for
  } 
}
raw 312:*: {
  if (%netcheck.whois) { 
    echo -a %netcheck.whois is connected to $network
 [color:red]   msg $2 blah blah blah[/color] 
    if ($scid == %netcheck.total) {
      unset %netcheck.total | unset %netcheck.whois 
    }
  }
}
Posted By: Rand Re: get $network someone is on - - 18/10/05 03:18 PM
An alternative to HAMM3R's version:

Code:
alias fnickmsg {
  var %nick = $1 , %i = 1
  while ($scon(%i).server) { 
    var %scon = $scon(%i)
    set %search. [ $+ [ %scon ] ] on
    scid %scon ison %nick
    inc %i
  }
}
raw 303:*:{
  var %nick = $2
  if (%search. [ $+ [ $cid ] ]) {
    if (%nick) { 
      echo -at3g %nick is connected to $+($scid($cid).network,.) Sending message.
      .msg %nick whatever
      unset %search. [ $+ [ $cid ] ]
    }
    haltdef
  }
}


I'm always iffy about using scid -a, as it doesn't take into consideration if you're connected to a server or not. (yay for not connected to server messages?)

Good luck with the script.
Posted By: WarlockW Re: get $network someone is on - - 18/10/05 04:58 PM

Thanks Guys Works Get !
Posted By: HAMM3R Re: get $network someone is on - - 18/10/05 06:41 PM
Quote:
I'm always iffy about using scid -a, as it doesn't take into consideration if you're connected to a server or not.


That's what the -t1 switch is for. From the help file:

The -tM switch limits the command to being performed only on servers with a certain connection status, where M is an or'd value of 1 = server connected, 2 = not connected...

So, the -t1 switch makes the command only execute on servers that you are connected to.
Posted By: Rand Re: get $network someone is on - - 19/10/05 01:42 AM
Wow, haha. I must have been really tired last night.

I remember looking at the /help /scid section, and somehow I managed to completely overlook the -tM.

Thanks for pointing that out.
Posted By: FiberOPtics Re: get $network someone is on - - 19/10/05 04:27 AM
There are a few problems with your code:

1. $scon(0) returns the total amount of server windows, even those where you are not connected in, so it is possible that if ($scid == %netcheck.total) is never $true, since you only do the whois on connected servers.

2. You cannot use $scid like that, it returns nothing. $scid takes a parameter which is not optional. Its parameter must be a number.

3. Even if you could use $scid like that there is a probable error in it. Even though the command /whois is reached to each connected server in order of the server windows (from first to last), that doesn't mean the response from the whois will return in that order. It's very well possible that you receive the whois response from the 3rd window first, or even from the last server window, depending on your lag or quickness of response of the server. In other words, your script might already unset the %whois variables before all responses have been received. When I did //scid -at1 ison $me, and parsed the 303, my first response was from the second server window, followed by the 1st, and then 3 and 4. A second time it was in the order: 2,3,4,1

4. Doing a whois just to know if someone is on a network is somewhat of an overhead. You can minimize the server load by doing an /ison <nick> and parse the raw 303, which returns only 1 line, in contrast with a whois which must return several lines from the server. I know, for the end user it won't make much difference, but it does for the servers.

5. In the raw 312, you are letting it trigger, and will only continue processing if (%netcheck.whois) is $true. That's not bad, but it can be improved. Because right now, even if the person does a regular whois for a nick, it will keep triggering this raw 312, and doing the if check each time. If you use #groups, and only enable them when using the /netcheck command, you will prevent the event from triggering if the group is off, thus the if check will only be done if you in fact issued the /netcheck command.

6.

Code:
alias netcheck { 
  set %ison.nick $$1  
  set %ison.total
  scon -at1 inc % $+ ison.total
  .enable #ison
  scid -at1 ison $1 
  .timernetcheck 1 5 netcheck.cleanup
}
 [color:red]  [/color] 
alias netcheck.cleanup {
  .timernetcheck off
  .disable #ison 
  unset %ison.*
}
 [color:red]  [/color] 
#ison off
raw 303:*:{
  if (%ison.total) {
    if ($2 == %ison.nick) {
      haltdef
      echo -a $2 is on $network 
      .msg $2 &lt;your message&gt;
    }
    dec %ison.total
    if (!%ison.total) netcheck.cleanup 
  }
}
#ison end


I've added a timer which will automatically finish the checking for the raw after 5 seconds. You can adjust this value to your liking. I do it for the reason in number 5, as I don't want that raw triggering when it's not necessary. If the results were returned before the timer triggered, the timer is automatically put off.

Posted By: Rand Re: get $network someone is on - - 19/10/05 05:07 AM
Pretty much the same concept as mine, cept mine uses a variable instead of a group, and a while loop instead of the -at1.

Didn't realise it til I re-read my code that the "unset" in my raw 303, would have to be dropped down beneath the next bracket (so that it's above the 'haltdef'.

Though, I suppose you could just change the "set" in mine to "set -u5"
Posted By: FiberOPtics Re: get $network someone is on - - 19/10/05 05:11 AM
Lol I didn't even notice you posted that version, it's indeed very similar. Though after checking now, I have the feeling HAMM3R didn't really pay attention to the important differences with our code versus his. Now he knows exactly why his method is less preferable.

Btw you don't need to use $scid($cid).network since the raw event is always returned on the network the ison was sent to, thus $network will always contain the right value.

One other detail: set %search. [ $+ [ %scon ] ] on <-- you don't ever need to specify evaluation brackets when setting a variable. set %search. $+ %scon will work in all cases. This is not the case for unsetting though, although it works in some occasions.
Posted By: HAMM3R Re: get $network someone is on - - 19/10/05 07:12 PM
Thanks for that extra info guys. I wasnt too knoledgable about the milti-network commands and identfiers before I started. I read over the help file briefly, and wrote the script accordingly. I guess I didnt pay enough attention to the descriptions of $scon etc. But thanks for pointing that out, i'll know better next time.
© mIRC Discussion Forums