mIRC Home    About    Download    Register    News    Help

Print Thread
#108836 22/01/05 10:15 PM
Joined: Aug 2004
Posts: 14
H
Hive Offline OP
Pikka bird
OP Offline
Pikka bird
H
Joined: Aug 2004
Posts: 14
I'm looking for a script that sets mode +o on users that do a certain command (The command I was thinking of was !op).

Thanks in advance.

#108837 22/01/05 10:19 PM
Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
on @*:TEXT:!op:#yourchannel: if $nick !isop # { mode # +o $nick }

Change #yourchannel to the channel you want this to trigger to.

Put it at # if you want it to trigger on all channels.

Use commas as delimiter to seperate multiple channels like #chan1,#chan2,#chan3

You can also use a variable fex %opchans #chan1,#chan2,#chan3 and specify that variable then like this:

on @*:TEXT:!op:%opchans: if $nick !isop # { mode # +o $nick }

Greets


Gone.
#108838 22/01/05 10:22 PM
Joined: Aug 2004
Posts: 14
H
Hive Offline OP
Pikka bird
OP Offline
Pikka bird
H
Joined: Aug 2004
Posts: 14
Could I have the code for +v as well please (The command being !voice)?

Thanks.

#108839 22/01/05 10:22 PM
Joined: Dec 2002
Posts: 3,547
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 3,547
Ok, using /auser <level> <nick> wouldn't be very safe to be honest, anyone who changes their nickname to a user in the user list will have access to the !op command. So we'll use /guser which specifically adds <level> <nick> <address type>

/guser op Andy 2

Would look something like:

-
* Added Andy[bed] (*!*@=Tydncb76-549-306-080.range81-155.btcentralplus.com) to user list
-


Now, the /guser command will only work if that user is on the server.

We've handled our nicknames, lets get to the event handling.

Code:
On @*:Text:*:[color:red]#channel[/color]: {
  if ($ulist($ial($nick))) {
    if ($left($1,1) == $chr(33)) {
      if ($gettok($1,1,33) == op) {  mode $chan +o $nick }
      if ($gettok($1,1,33) == deop) {  mode $chan -o $nick }
      if ($gettok($1,1,33) == voice) {  mode $chan +v $nick }
      if ($gettok($1,1,33) == devoice) {  mode $chan -v $nick }
    }
  }
}

#108840 22/01/05 10:23 PM
Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
on @*:TEXT:!voice:#yourchannel: if $nick !isvoice # { mode # +v $nick }


Gone.
#108841 22/01/05 10:43 PM
Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
Have two tips for you Andy:

  • You can either store the command in a var, or tokenize it so that $1 is filled with the command. Makes your code quite shorter, and easier to read.

    tokenize 33 !op --> $1 is now filled with the actual command: op

    if $1 == op { }
    elseif $1 == deop { }
    ...
  • Since op != deop != voice != devoice, you should put elseif's instead of if's.

    When using if's, mIRC's scripting parser will go through each if statement to see if it finds a match. Since our commands are exclusive, as in they are different, you can use elseif's, which makes mIRC not try to match what is in those elseif conditions, as soon as one has matched. In the case of this little snippet, where it is a few lines, it all doesn't matter as much, though in larger snippets, or in snippets where each if check takes some processing, you'll see the difference.

Cya


Gone.
#108842 22/01/05 10:55 PM
Joined: Dec 2002
Posts: 3,547
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 3,547
Quote:

You can either store the command in a var, or tokenize it so that $1 is filled with the command. Makes your code quite shorter, and easier to read.


I have never actually used this command, I know what it does but for whatever reason it's a habbit to use Token Identifiers, to have the longer and unreadable code, maybe one day I'll adjust. grin

Thanks for the pointers though,
have a good one.

#108843 23/01/05 02:10 AM
Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
were u trying to cater for someone typeing !!!!!!!!!!!!!!!!!!!!op ?

#108844 23/01/05 02:34 AM
Joined: Dec 2002
Posts: 3,547
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 3,547
I'm generous dude...no one ever tell you that?


Link Copied to Clipboard