my mistake, i initalized %x not %i at the beginning

alias opx {
if ($chr(35) isin $active) {
/set -u0 %i 1
while (%i <= $nick($active, 0)) {
if ($nick !isop $active) && ($level($address($nick($active, %i), 5)) == x) {
/set -u0 %opnick %opnick $nick($active, %i)
}
if ($numtok(%opnicks, 32) == $modespl) || (%i == $nick($active, 0)) {
/mode $active $+(+,$str(o, $modespl)) %opnick
/unset %opnick
}
/inc -u0 %i
}
}
}

See if that doesn't help