No offense, but I don't see the need of hash tables in your code, along with your alias. Removing the variable %i in your script will break the script and result an infinite loop. Why not just do this:
on *:JOIN:#: {
var %i = $nick(#,0)
while (%i) {
if ($istok(badnick1 badnick2 badnick3 badnick4,$nick(#,%i),32)) {
ban -k # $nick 2 please change nick (forbidden nick)
}
dec %i
}
}
and without the while loop:
on *:JOIN:#: {
var %badnick = badnick1 badnick2 badnick3 badnick4
if ($istok(%badnick,$nick,32)) { ban -k # $nick 2 please change nick (forbidden nick) }
}
on *:NICK: {
var %badnick = badnick1 badnick2 badnick3 badnick4
if ($istok(%badnick,$newnick,32)) { ban -k # $newnick 2 please change nick (forbidden nick) }
}
Also, I'm not clear on what you mean by first command and second command.