$wildsite will be $null if you're not in an event that fills that identifier with data.
In order to save your loop from having to resolve the address mask each time through the loop, it would be better to use a variable to hold that data.
alias clonekick {
var %reason = -CloneKick- | ; Kick reason template
| ;
if #* iswm $1 && $2 ison $1 { | ; /clonekick #Channel CloneNick blah blah
var %chan = $1 | ; %chan = #Channel
var %nick = $2 | ; %nick = CloneNick
%reason = %reason $3- | ; %reason = (-CloneKick- blah blah)
} | ;
elseif $1 ison $active { | ; /clonekick CloneNick Begone, schizophrenic!
var %chan = $active | ; %chan = active window
var %nick = $1 | ; %nick = CloneNick
%reason = %reason $2- | ; %reason = (-CloneKick- Begone, schizophrenic!)
} | ;
else return | ; If no matching condition, halt
| ;
var %wildsite = $address(%nick, 2) | ; *!*@host.domain
var %i = 1 | ; Loop index
| ;
while $ialchan(%wildsite, %chan, %i).nick { | ; While there are more clones
kick %chan $ifmatch %reason | ; kick a clone
inc %i | ; move on to the next one
}
}
/clonekick #mIRC clonenick1 blah blah blah4
/clonekick clonenick1 Begone, you schizophrenic escapee!