This does it more efficiently by avoiding the need to loop through all the non-ops. Without testing, I don't know how the 512 limit is applied to messages when the target of the privmsg is a long list of nicks. I deleted one of the 0's from 00 since it's not needed, and that byte might be needed for the message.

I also changed so it won't send a message to yourself. I also .silenced the PRIVMSG so the display can be simplified to a single echo-to-self instead of potentially dozens of similar lines. The %flag is used to make sure that it doesn't echo-to-self more than once, and it won't echo if you're the only op/halfop.

The internal if() is less efficient, by forcing N loops to evaluate the if() each time. The only reason to keep the if() instead of letting the final while() handle everything is if the list of ops could be so long that it exceeds $maxlenl.

Note how my use of $nick() is more inclusive, as your original would not see nicks who had the & or ~ status without also having the @ or % status too. a=include all, rv=exclude voices and those with no status at all. $nick() lets you use the status symbol and the switch letters interchangeably, so using 'o' and '@' are interchangeable. The exception is prefix 'a' for level & since 'a' is already mapped to 'all nicks'.

Using this kind of alias should also be accompanied by checkboxing "own messages" in flood controls, for obvious reasions.

However, if your network supports the alternate target format, which I believe is indicated by the 005 numeric containing something similar to STATUSMSG=@%+ you should instead use a group target, since it's much more friendly to flood controls:

op1 { notice @% $+ $chan $1- }

For newer ircd's I've tested, @%#channel ignores everything in prefixes#channel except the lowest value status prefix, which makes it send out messages as if the target were %#channel, but the message is received by everyone at that status level plus everyone at a higher level. So, /notice +#channel would go to all ops and halfops too.

But I've used this at networks in the past where they would send out only to the targets listed, so +#channel would be seen only by voices, so all the @ops would voice themselves to make sure they could see the messages going to voices too.

If there's a prefix not listed in STATUSMSG= then you risk having the group notice seen by all, or seen by none, instead of going to the specific group.

One difference between sending mass notices like this vs using % $+ $chan is that the group notice is usually blocked from being used by someone who isn't at that level or higher, while there's no restriction against spamming a list of nicks.

Code
OP1 {
  var %i 1 , %target , %flag 0

  while ($nick($chan,%i,a,rv)) {
    if ($v1 == $me) { inc %i | continue }
    if (%flag) { echo $chan $+(-> @% $+ $chan) $1- | var %flag 0 }
    var %target $addtok(%target,$v1,44)
    if ($numtok(%target,44) == 5) {
      .privmsg $gettok(%target,1-5,44) 0,14 $1- 
      var %target
    }
    inc %i
  }
  while (%target != $null) {
    .privmsg $gettok(%target,1-5,44) 0,14 $1- 
    var %target $gettok(%target,6-,44)
  }
}