For the same reasons as seen in this thread https://forums.mirc.com/ubbthreads.php/topics/270488/ you need to properly parse the mode and their parameters, currently your code has a lot of logical issue because of that, if it works most of the time (ignoring the speed issue), it will break for a lot of rawmode being set.
Here is an untested attempt:

Code
ON *:RAWMODE:#:{
  var %takepara $remove($gettok($chanmodes,1-3,44),$chr(44)),%i 1,%j 2,%set +
  while ($mid($1,%i,1)) {
    var %t $v1
    if (%t == +) %set = +
    elseif (%t == -) %set = -
    elseif (%t isincs $nickmode) inc %j
    elseif (%t isincs %takepara) {
      if (%t isincs beIq) {
        var %banmask $eval($chr(36) $+ %j,2)
        if (~quiet:?* iswm %banmask) %banmask = $mid(%banmask,8)   
        elseif (~?:?* iswm %banmask) %banmask = $mid(%banmask,4)
        elseif (?:?* iswm %banmask) %banmask = $mid(%banmask,3)
        if ($ialchan(%banmask,$chan,0)) {
          var %n $v1,%m %n,%user user,%is is,%word $replacexcs(%set $+ %t,+b,Banned,-b,UNBanned,+I,Invited,-I,UNInvited,+e,Exempted,-e,UNExempted,+q,MuteBanned,-q,UN-MuteBanned)
          if (%m > 1) {
            %user = users
            %is = are
          }
          while (%n) var %bl %bl $ialchan(%banmask,$chan,%n).nick,%n %n - 1
          var %r $regsubex(%bl,/(\S+)/g,(\n) \t)
          var %k 1
          while ($gettok(%bl,%k,32)) {
            if ($query($v1)) echo -t $v1 *** ( $+ %m %user $+ ) %is %word : %r
            inc %k
          }
          echo -t $chan *** ( $+ %m %user $+ ) %is %word : %r
          unset %bl
        }
      }
      inc %j
    }
    inc %i
  }
}


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