A Simple Mass Mode snippet
Usage:
/mass +|- o|v|b
alias mass {
if ($regex($1-,/^[+|-][o|v|b]$/)) {
var %a , %nicks
%a = 0
%nicks = $null
:nextnick
inc %a
if ($nick(#,%a) == $null) { if ($len(%nicks) > 0) .mode # $mid($1,1,1) $+ $str($mid($1,2,2),$gettok(%nicks,0,32)) %nicks | halt }
%nicks = %nicks $nick(#,%a)
if (6 // %a) { .mode # $mid($1,1,1) $+ $str($mid($1,2,2),$gettok(%nicks,0,32)) %nicks | %nicks = $null }
goto nextnick
}
else {
echo -a Specify A Correct Mode: [+|-] [o|v|b]
}
}
There's nothing wrong with napa's example. But it doesn't include a check for whether those who're given user modes or not.
You can use this one if you wish:
alias mass {
if ($me isop #) {
var %i 1,%p,%m $modespl,%mass
if (($$1 = +o) && (!$nick(#,0,o))) %p = $+(+,$str(o,%m))
elseif (($$1 = -o) && ($nick(#,0,o))) %p = $+(-,$str(o,%m))
elseif (($$1 = +v) && (!$nick(#,0,h))) %p = $+(+,$str(v,%m))
elseif (($$1 = -v) && ($nick(#,0,v))) %p = $+(-,$str(v,%m))
while $nick(#,%i) { if ($v1 != $me) { %mass = %mass $v1 }
if ($gettok(%mass,0,32) = %m) || ($nick(#,0) = %i) {
mode # %p %mass | %mass = "" } | inc %i } }
else { echo -a *** You're not opped in # *** }
}
You can add more modes with another elseif in the same format shown.
napa %a is set to 0 so while will not work. think
um yes you can use a while loop. this should do the same thing as ur\'s.
alias mass {
if ($me isop #) && ($regex($1-,/^[+-][ovb]$/)) {
var %a = $nick($chan,0), %o = 1
while (%o <= %a) {
var %m $addtok(%m,$nick($chan,%o),32), %m $remtok(%m,$me,32)
inc %o
}
mode $chan $left($1,1) $+ $str($right($1,1),%o) %m
}
}