This 'fine' code as you put it is not fine, it has two main issues

if (%substring isincs $nickmode && $gettok(%string,2,32) !ison $2) goto loopend

When this if is true and it skips this current mode because the nickname you want to set a mode on/with is not on the channel, you're not updating %string (you're not updating the next parameter for the next mode taking a parameter) which would break the next mode with a parameter. Granted you were never in this situation so it works fine for you but then:

Code
if ($numtok(%parameters,32) == $modespl) {
        if ($me ison $2) || ($me ison $2) !mode $2 %modestring %parameters
        ; $iif(o isin $usermode || !$nick($2,$me,@&~%) ,cs mode $2 set %modestring %parameters,!mode $2 %modestring %parameters)
        %string = $mid($gettok(%string,1,32),$calc(%subindex + 1)) $gettok($hget(%name,%index),$calc(10 + 2) $+ -,32)
        hadd -m %name %index $iif($left(%string,1) !isin +-,%prefix) $+ %string
        goto end
 }
When you reach a number of modes (or number of parameters for modes, same thing) that is equal to the maximum number of modes the server allows per /mode command, you sends the current /mode and then /goto end, which exits the two nested loop and basically stop the processing of the modes for now and it will wait for the timer to retrigger to continue processing.
For this to work it must update the next mode and next parameter and save to the hash table, the next mode is correctly updated with the $mid, but the parameters of the modes are not updated properly with $gettok($hget(%name,%index),$calc(10 + 2) $+ -,32) aka $gettok($hget(%name,%index),12-,32), it should probably be $gettok(%string,2-,32) instead so %string = $mid($gettok(%string,1,32),$calc(%subindex + 1)) $gettok(%string,2-,32).
Another improvement is to use $unsafe on the parameter passed to /timer in order to not double evaluate the unknown content passed to it, avoiding exploits:
!.timer $+ %name -m 0 $iif($regml(putmode,1) isnum,$ifmatch,1400) putmode.exec $cid $unsafe($1)

Now kick are unrelated to /mode completely and therefore to $modespl, the maximum number of kicks in a single /kick command can be found in raw 005's KICK: token.
You probably don't want to mix kicks and /putmodes as they are probably unrelated server wise as well, so it's probably best to write a seperate function for it.
That being said, and it was requested many times, mIRC does not offer a way to access the various token of the raw 005, you'll have to write a script for it and then write a /putkick alias:

Code
Alias putkick {
  if (!$isid) {
    var %echo = !echo -acq $+ $iif($active == Status Window,e) info *
    if ($regex(putkick,$1,/^-t(\d+)/)) tokenize 32 $2-
     if ($2 == $null) %echo /putkick: insufficient parameters
     elseif  (!$nick($1,$me,~&@%)  && o !isin $usermode)  { %echo /putkick: you need to need to  be at least half-opped or have ircops access } 
    else {
      var %name = putkick. $+ $cid $+ . $+ $1
      hadd -m kick %name $hget(kick,%name) $2-
      if (!$timer(%name)) {
        !.timer $+ %name -m 0 $iif($regml(putkick,1) isnum,$ifmatch,1400) putkick.exec $cid $unsafe($1)
        !.echo -q $regex(putkick,reset,/reset/)
      }
    }
  }
}
alias putkick.exec {
  var %name = putmode. $+ $1 $+ . $+ $2,%nicks $hget(kick,%name)
  var %maxkick 4,%a 1,%tmp
  while ($gettok(%nicks,%a,32) {
    %tmp = %tmp $+ , $+ $ifmatch
    if ($numtok(%tmp,44) == %maxkick) {
      if ($me ison $2) kick $2 %tmp
      hadd kick %name $gettok(%nicks,$calc(%a + 1),32)
      if (!$hget(kick,%name)) {
      hdel kick %name
      .timer $+ %name off
      }
      return
    }
    hdel %name %index
    hinc %name current
    inc %index
  }
  if ($me ison $2) && (%tmp) {
    kick $2 %tmp
    hdel kick %name
    .timer $+ %name off
  }
}
This is untested.. I used 4 for the maximum kick per /kick, just use /putkick <channel> <nick nick1 nickN>


#mircscripting @ irc.swiftirc.net == the best mIRC help channel