Hello,

This is one of the handy aliases I wrote for myself, directly copied from the file. The comment says pretty well what it does. More explanataions after the code...

Code:
/*
* KICKBAN selected users from the userlist
* in the active channel window, with optional reason,
* taking care of webchat users,
* collecting upto four channel modes in a single line,
* and de-opping chanops
*
*/
alias kbchan {
  if (($me !isop #) && ($me !ishop #)) {
    return
  }

  var %snick = $snick(#, 0)
  var %banstr
  var %cmdstr
  var %sign
  var %fix

  while (%snick > 0) {
    if (%fix != $null) {
      %cmdstr = +b
      %banstr = %fix
      %sign = +
    }

    ; Deop if opped
    if ($snick(#, %snick) isop #) {
      %cmdstr = %cmdstr $+ -o
      %banstr = %banstr $snick(#, %snick)
      if (%sign != -) { %sign = - }
    }
    elseif ($snick(#, %snick) ishop #) {
      %cmdstr = %cmdstr $+ -h
      %banstr = %banstr $snick(#, %snick)
      if (%sign != -) { %sign = - }
    }

    ; Ban
    if (html.chat isin $address($snick(#, %snick), 4)) {
      %fix = $remove($address($snick(#, %snick), 3), .html.chat)
    }
    elseif (mibbit.com isin $address($snick(#, %snick), 4)) {
      %fix = $remove($address($snick(#, %snick), 3), .mibbit.com)
    }
    else {
      %fix = $address($snick(#, %snick), 2)
    }

    if ($len($remove(%cmdstr,+,-)) < 4) {
      if (%sign != +) {
        %cmdstr = %cmdstr $+ +
        %sign = +
      }
      %cmdstr = %cmdstr $+ b
      %banstr = %banstr %fix
      %fix = $null
    }

    dec %snick
    if (($len($remove(%cmdstr,+,-)) < 4) && (%snick > 0)) {
      continue
    }

    mode # %cmdstr %banstr

    %cmdstr = $null
    %banstr = $null
    %sign = $null
  }
  if (%fix != $null) {
    mode # +b %fix
  }

  ; Kick
  %snick = $snick(#, 0)
  while (%snick > 0) {
    kick # $snick(#, %snick) $1-
    dec %snick
  }
}



The issue is that sometimes $address does not return the value it should - it returns nothing. Checkpoint used with the %fix variable shows sometimes it is empty. Sometimes it isn't. I've had similar issues with $address in other, simpler aliases. Here is an example output of kickban-ing three nicknames, two of which chanops. The first time (16:14) the alias fails and the server treats the command by putting nick!*@* banmasks because the corresponding parameter for (some of) the +b modes is missing.
The second time (16:16) the same alias in the same situation works just fine, as it does most of the time:

|16:14:02| * Varadin sets mode: +bb HEX!*@* Dev!*@*
|16:14:02| * Varadin sets mode: +b *!*@0xDEADBEAF.0xFF
|16:14:02| * SeenServ was kicked by Varadin (test)
|16:14:02| * HEX was kicked by Varadin (test)
|16:14:02| * Dev was kicked by Varadin (test)
|16:16:40| * Varadin sets mode: +b-o+b-o *!*@services.bg HEX *!*@imagine.dragons Dev
|16:16:40| * Varadin sets mode: +b *!*@0xDEADBEAF.0xFF
|16:16:40| * SeenServ was kicked by Varadin (test)
|16:16:40| * HEX was kicked by Varadin (test)
|16:16:40| * Dev was kicked by Varadin (test)

Tested on mIRC 6.35 and mIRC 7.32