Looks like I misunderstood your question, sry.
However, this works for me:
on *:ban:#:{
var %x = 1
while ($ialchan($banmask,$chan,%x).nick) {
set -s %bnick $+ $ifmatch $banmask
inc %x
}
}
on *:unban:#:{
var %x = 1
while ($ialchan($banmask,$chan,%x).nick) {
unset -s $+(%,bnick,$ifmatch)
inc %x
}
}[00:37:17] * Horstl|Fortl sets mode: +b *o*!*@*
* Set %bnickHorstl|Fortl to *o*!*@*
* Set %bnickMaestro to *o*!*@*
[00:37:21] * Horstl|Fortl sets mode: -b *o*!*@*
* Unset %bnickHorstl|Fortl
* Unset %bnickMaestro