You mixed up the names of your variables there - you should be checking and incrementing %i and %ii.

RusselB: As far as making it better there really isn't any good way in mIRC scripting. Either use the static method you've currently got or use a loop like genius_at_work's to make it simpler to alter later. Wims' is smaller and may be faster but it's highly unreadable and speed is irrelevant in that code in any case.