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.