|
Joined: Jul 2004
Posts: 169
Vogon poet
|
OP
Vogon poet
Joined: Jul 2004
Posts: 169 |
code is in alias
op { if (# == $null) { .echo You must use this command in a channel window. | halt } | if ($me !isop #) { .echo You're not a channel operator! | halt } | .raw -q mode # +oooooo $1 $2 $3 $4 $5 $6 if ($7 != $null) { .raw -q mode # +oooooo $7 $8 $9 $10 $11 $12 } | if ($13 != $null) { .raw -q mode # +oooooo $13 $14 $15 $16 $17 $18 } | if ($19 != $null) { .raw -q mode # +oooooo $19 $20 $21 $22 $23 $24 } if ($25 != $null) { .raw -q mode # +oooooo $25 $26 $27 $28 $29 $30 } | if ($31 != $null) { .echo -a $timestamps $+ %icon You can only use this command to a max of 30 users. | halt } } voice { if (# == $null) { .echo You must use this command in a channel window. | halt } | .raw -q mode # +vvvvvv $1 $2 $3 $4 $5 $6 if ($7 != $null) { .raw -q mode # +vvvvvv $7 $8 $9 $10 $11 $12 } | if ($13 != $null) { .raw -q mode # +vvvvvv $13 $14 $15 $16 $17 $18 } | if ($19 != $null) { .raw -q mode # +vvvvvv $19 $20 $21 $22 $23 $24 } if ($25 != $null) { .raw -q mode # +vvvvvv $25 $26 $27 $28 $29 $30 } | if ($31 != $null) { .echo -a $timestamps $+ %icon You can only use this command to a max of 30 users. | halt } } deop { if (# == $null) { .echo You must use this command in a channel window. | halt } | if ($me !isop #) { .echo You're not a channel operator! | halt } | .raw -q mode # -oooooo $1 $2 $3 $4 $5 $6 if ($7 != $null) { .raw -q mode # -oooooo $7 $8 $9 $10 $11 $12 } | if ($13 != $null) { .raw -q mode # -oooooo $13 $14 $15 $16 $17 $18 } | if ($19 != $null) { .raw -q mode # -oooooo $19 $20 $21 $22 $23 $24 } if ($25 != $null) { .raw -q mode # -oooooo $25 $26 $27 $28 $29 $30 } | if ($31 != $null) { .echo -a $timestamps $+ %icon You can only use this command to a max of 30 users. | halt } } devoice { if (# == $null) { .errorecho You must use this command in a channel window. | halt } | if ($me !isop #) { .echo You're not a channel operator! | halt } | .raw -q mode # -vvvvvv $1 $2 $3 $4 $5 $6 if ($7 != $null) { .raw -q mode # -vvvvvv $7 $8 $9 $10 $11 $12 } | if ($13 != $null) { .raw -q mode # -vvvvvv $13 $14 $15 $16 $17 $18 } if ($19 != $null) { .raw -q mode # -vvvvvv $19 $20 $21 $22 $23 $24 } | if ($25 != $null) { .raw -q mode # -vvvvvv $25 $26 $27 $28 $29 $30 } | if ($31 != $null) { .echo -a $timestamps $+ %icon You can only use this command to a max of 30 users. | halt } }
i know baisacly what it does but i dont understand why did author made so many $users couldn't it be easier to make /raw -q mode # -v $1-29 ?
and why somewhere it is use /mode # and somewhere /raw -q, isnt that the same ?
|
|
|
|
Joined: Feb 2004
Posts: 714
Hoopy frood
|
Hoopy frood
Joined: Feb 2004
Posts: 714 |
No, because you need as many v's as nicks you have. So /raw -q +v $1-29 would actually only voice the 1st nick. The author used so many $N because they didn't know how many people the user wanted to Op/Deop, etc.. In the code that follows you have the server's maximum modes: $modespl - which changes from net to net. One work around could be: alias [color:blue]op[/color] {
if (# == $null) { .echo You must use this command in a channel window. | halt }
if ($me !isop #) { .echo You're not a channel operator! | halt }
else { .raw -q mode # $+([color:orange]+[/color],$str([color:red]o[/color],$modespl)) $$1 $2- }
} You can copy/paste this code as many times as you want: OP, DEOP, VOICE, DEVOICE, etc.. Another one could be: (no limitations) alias [color:blue]op[/color] {
if (# == $null) { .echo You must use this command in a channel window. | halt }
if ($me !isop #) { .echo You're not a channel operator! | halt }
var %x = $numtok($$1-,32)
.raw -q mode # $+([color:orange]+[/color],$str([color:red]o[/color],%x)) $$1-
} Things you need to change:The alias name -> op, deop, etc..If the code is a DEx (DEop, DEvoice, DEhelp), change that + for a -Change that o for the respective letter of the usermode: v = voices, h = hop, o = op, etc..Hope this helps  Zyzzyx.
Last edited by Zyzzyx26; 12/08/04 09:54 PM.
"All we are saying is give peace a chance" -- John Lennon
|
|
|
|
Joined: Jul 2004
Posts: 169
Vogon poet
|
OP
Vogon poet
Joined: Jul 2004
Posts: 169 |
thanks, must admit that your code is much much nicer to look =)
|
|
|
|
Joined: Feb 2004
Posts: 714
Hoopy frood
|
Hoopy frood
Joined: Feb 2004
Posts: 714 |
yw  and thanks
"All we are saying is give peace a chance" -- John Lennon
|
|
|
|
Joined: Jul 2004
Posts: 169
Vogon poet
|
OP
Vogon poet
Joined: Jul 2004
Posts: 169 |
ehm.. btw can you pls look at that "mode" post last time ?
|
|
|
|
Joined: Feb 2004
Posts: 2,019
Hoopy frood
|
Hoopy frood
Joined: Feb 2004
Posts: 2,019 |
Hi Zyzzy, the alias you suggested was fine, though the script will not process any amount of nicks that are higher than $modespl. Also the user had to make an alias for each mode, which is a bit redundant. Usage: /massmode -|+ o|h|v [nicks]
massmode {
if $me !isop # { echo -a You are not an operator on # | return }
if !$istok(+ -,$1,32) || $2 !isin ohv { echo -a Incorrect syntax: /massmode +|- o|h|v [nicks] }
var %x = $modespl, %y = $$3-
while $gettok(%y,1- %x,32) { mode # $+($1,$str($2,%x)) $v1 | %y = $deltok(%y,1- %x,32) }
}
The alias is designed to be used in a popup, but can of course be used manually as well, by specifying the nicks. Anyway, as stated, your solution is fine, I just wanted to add some extra value to it. Greets
Gone.
|
|
|
|
Joined: Feb 2004
Posts: 714
Hoopy frood
|
Hoopy frood
Joined: Feb 2004
Posts: 714 |
That's a cool alias  I'm just curious about sth: while $gettok(%y,1- %x,32) { mode # $+($1,$str($2,%x)) $v1 | %y = $deltok(%y,1- %x,32) }Why the $gettok(%y,1- %x,32) and then the $deltok(%y,1- %x,32)?
"All we are saying is give peace a chance" -- John Lennon
|
|
|
|
Joined: Feb 2004
Posts: 2,019
Hoopy frood
|
Hoopy frood
Joined: Feb 2004
Posts: 2,019 |
Hi,
Ok suppose you select 6 nicks, and the modespl allows for 2.
Var %x = 2, %y = one two three four five six
while $gettok(%y,1- %x,32) { … | %y = $deltok(%y,1- %x,32) } First iteration: I get the first two nicks, “one two”, with gettok and range 1-%x (1-2). I do the mode on them, and then delete the first two nicks with deltok. Remaining nicks in %y: three four five six
Second iteration: I get the first two nicks, “three four”, with gettok and range 1-%x (1-2). I do the mode on them, and then delete the first two nicks with deltok. Remaining nicks in %y: five six. …
So instead of looping through the %y, I actually just keep taking the first two nicks, and deleting them, until there’s no nicks left.
Another approach would be to loop through %y and keep changing the ranges, like: 1-2,3-4,5-6. However then you need to increment 2 extra vars e.g. %n and %m to represent the new range with each iteration. %x can't be used for this, because %x needs to remain at its value for the $str(...,%x)
Anyway, as always, there are multiple ways to achieve something, and that day I felt like going for this particular approah, hehe.
Cya!
Gone.
|
|
|
|
Joined: Feb 2004
Posts: 714
Hoopy frood
|
Hoopy frood
Joined: Feb 2004
Posts: 714 |
Ohh, clever  thanks!
"All we are saying is give peace a chance" -- John Lennon
|
|
|
|
Joined: Feb 2004
Posts: 2,019
Hoopy frood
|
Hoopy frood
Joined: Feb 2004
Posts: 2,019 |
No problem.
You're always welcome to ask anything. It's one of the best ways to learn new tricks.
Greets
Gone.
|
|
|
|
|