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.
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 <your message>
}
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.