On nick

From Scriptwiki
Jump to: navigation, search

The on NICK event triggers when a user changes nickname while on the same channel as you.

on <level>:NICK:<commands>

In this event, $nick holds the old nickname and $newnick the new one. Note that $nick is not in your ial anymore, while if you changed nick, $me is your old nick.

Example

on *:NICK: {
 echo -a $nick is now knows as $newnick 
}

This example would just echo every nickchange to the active window.

If you want to echo it to every common channel (e.g. for changing mIRC's standard layout), you could use the following:

on ^*:NICK: {
 ; we want to halt mIRC's default output
 haltdef
 var %i = 1
 ; lets loop through all common channels
 while (%i <= $comchan($newnick,0)) {
  ; actually echo it to the channel
  echo -t $comchan($newnick,%i) $nick has just changed his nick to $newnick
  ; increase looping-variable
  inc %i
 }
}