mIRC Home    About    Download    Register    News    Help

Topic Options
#233577 - 25/08/11 05:14 PM Op/Deop/Voice/Devoice Script
mysticalNinja Offline
Self-satisified door

Registered: 25/08/11
Posts: 3
i made an op/deop/voice/devoice script and i want to do that only the op's with level up to 10.
Code:
 if ( $1 == !op ) { /cs op $chan $2 | notice $2 Welcome  }
    if ( $1 == !deop ) { /cs deop $chan $2 | notice $2 Sorry  }
if ( $1 == !voice ) { /cs voice $chan $2 | notice $nick  Voiced }
    if ( $1 == !devoice ) { /cs devoice $chan $2 | notice $nick DeVoiced }

i made that with if ( $nick isop)
i know i have to make it with on *:TEXT: but can you tell me how to do it because i am newbie with script.
Thanks in advance


Edited by mysticalNinja (25/08/11 05:15 PM)

Top
#233578 - 25/08/11 05:21 PM Re: Op/Deop/Voice/Devoice Script [Re: mysticalNinja]
Riamus2 Offline
Planetary brain

Registered: 13/10/04
Posts: 8338
Loc: NC, USA
Code:
on 10:text:*:#channel: {
  ; Your code here
}


Make sure the users are set at level 10 (or higher) in your user list. And, I'd suggest using ELSEIF instead of IF for the last 3 just to make it more efficient.


Edited by Riamus2 (25/08/11 05:22 PM)
_________________________
Invision Support
#Invision on irc.irchighway.net

Top
#233579 - 25/08/11 05:28 PM Re: Op/Deop/Voice/Devoice Script [Re: Riamus2]
mysticalNinja Offline
Self-satisified door

Registered: 25/08/11
Posts: 3
Thanks but i dont want the opers to do it if they dont have access lvl 6
and i dont want the users to do it smile
smile


Edited by mysticalNinja (25/08/11 05:28 PM)

Top
#233580 - 25/08/11 07:03 PM Re: Op/Deop/Voice/Devoice Script [Re: mysticalNinja]
Riamus2 Offline
Planetary brain

Registered: 13/10/04
Posts: 8338
Loc: NC, USA
The number in the on text event tells you what level the person has to be. You said originally that you wanted them to have access level 10, so 10 is there. If you want 6 instead, use that. No one without an access level (regular channel visitors, etc) cannot use it because it requires them to have the access level listed in the event.
_________________________
Invision Support
#Invision on irc.irchighway.net

Top
#233582 - 25/08/11 08:38 PM Re: Op/Deop/Voice/Devoice Script [Re: Riamus2]
mysticalNinja Offline
Self-satisified door

Registered: 25/08/11
Posts: 3
it works thanks and if the user that gonna use it dont have the access to use it how i can make to send him a notice tha You Can Use This Command.


Edited by mysticalNinja (25/08/11 08:44 PM)

Top
#233583 - 25/08/11 08:56 PM Re: Op/Deop/Voice/Devoice Script [Re: mysticalNinja]
Riamus2 Offline
Planetary brain

Registered: 13/10/04
Posts: 8338
Loc: NC, USA
Instead of only triggering for a specific level (having the level in the event line itself), you can use an IF statement to check $ulevel and then based on what the level is, allow the command or give an error message.
_________________________
Invision Support
#Invision on irc.irchighway.net

Top
#233585 - 26/08/11 01:55 AM Re: Op/Deop/Voice/Devoice Script [Re: Riamus2]
Tomao Offline
Hoopy frood

Registered: 07/07/07
Posts: 1132
Loc: United States
That's true, Riamus2, but by using the if statement, it'll trigger the error check anytime if anyone sends a text. The text event may need to be made a regex to ensure it triggers on those aforementioned commands only. I don't think making it as:

on *:text:!*:#:{

is such a good idea, because it'll also be triggered if someone enters !!!!!!!! for any reason.


Edited by Tomao (26/08/11 01:56 AM)

Top
#233587 - 26/08/11 11:09 AM Re: Op/Deop/Voice/Devoice Script [Re: Tomao]
Riamus2 Offline
Planetary brain

Registered: 13/10/04
Posts: 8338
Loc: NC, USA
It can definitely be made regex, but there really isn't anything wrong with a text event that triggers on everything either. Yes, it's less work to avoid triggering on all text, but it really doesn't hurt. That's what any theme script is going to do.
_________________________
Invision Support
#Invision on irc.irchighway.net

Top
#233588 - 26/08/11 05:42 PM Re: Op/Deop/Voice/Devoice Script [Re: Riamus2]
Tomao Offline
Hoopy frood

Registered: 07/07/07
Posts: 1132
Loc: United States
I meant if I composed the code this way:
Code:
on *:text:*:#:{  
  tokenize 32 $strip($1-)
  if ($ulevel == 10) { 
    if ($1 == !op) { 
      cs op $chan $2 
      notice $2 Welcome 
    }
    elseif ($1 == !deop) { 
      cs deop $chan $2 
      notice $2 Sorry
    }
    elseif ($1 == !voice) { 
      cs voice $chan $2 
      notice $nick  Voiced 
    }
    elseif ($1 == !devoice) { 
      cs devoice $chan $2 
      notice $nick DeVoiced 
    }
  }
  else { 
    notice $nick You cannot use the command $1 
  }
}
this is going to trigger "You cannot use the command" warning every time someone enters a message who doesn't have an access level 10.

Top
#233596 - 27/08/11 02:01 AM Re: Op/Deop/Voice/Devoice Script [Re: Tomao]
Riamus2 Offline
Planetary brain

Registered: 13/10/04
Posts: 8338
Loc: NC, USA
Ok, I see what you meant. Yeah, you'd have to do it differently... something like:

Code:
on *:text:*:#:{  
  tokenize 32 $strip($1-)
  if ($istok(!op !deop !voice !devoice,$1,32) && $2) {
    if ($ulevel == 10) {
      cs $remove($1,!) $chan $2
      if (op isin $1) { notice $2 $iif($1 == !op,Welcome,Sorry) }
      else { notice $nick $iif($1 == !voice,Voiced,DeVoiced) }
    }
    else { notice $nick You cannot use the command $1 }
  }
}


Or, for a regex option:

Code:
on *:text:*:#:{
  tokenize 32 $strip($1-)
  if ($regex($1,/!(de)?(op|voice)/) && $2) {
    if ($ulevel == 10) {
      cs $remove($1,!) $chan $2
      if (op isin $1) { notice $2 $iif($1 == !op,Welcome,Sorry) }
      else { notice $nick $iif($1 == !voice,Voiced,DeVoiced) }
    }
    else { notice $nick You cannot use the command $1 }
  }
}


I believe I have the regex correct, but someone can improve it if it needs it. smile
_________________________
Invision Support
#Invision on irc.irchighway.net

Top
#233598 - 27/08/11 07:55 AM Re: Op/Deop/Voice/Devoice Script [Re: Riamus2]
Tomao Offline
Hoopy frood

Registered: 07/07/07
Posts: 1132
Loc: United States
Right on. Thanks for understanding what I meant and taking your time with these two examples, Riamus2.
Originally Posted By: Riamus2
I believe I have the regex correct, but someone can improve it if it needs it. smile
Code:
on $*:text:/^!(de)?(op|voice)( |$)/i:#:{
  tokenize 32 $strip($1-)
  if ($2) {
I'm sure you're already aware that regex is case-sensitive until you specify the /i modifier at the end of match or (?i) option in the regex match section. This is to presume that some people may have their text capitalized. The ^ is to make sure it starts with ! followed by the command. ( |$) basically means it proceeds a space or ends the command as is. It's better than the \b word boundary. \b won't prevent punctuation characters.

Last but not least, happy birthday to you. I see you have a birthday cake by your nickname.

Top
#233601 - 27/08/11 03:57 PM Re: Op/Deop/Voice/Devoice Script [Re: Tomao]
Riamus2 Offline
Planetary brain

Registered: 13/10/04
Posts: 8338
Loc: NC, USA
Thanks for the updated regex. Still learning and I did forget about /i. I considered putting it on the event line like that, but then you don't get the else option to give an error message to the user.

And thanks for the birthday wish. smile


Edited by Riamus2 (27/08/11 04:02 PM)
_________________________
Invision Support
#Invision on irc.irchighway.net

Top
#233605 - 27/08/11 05:43 PM Re: Op/Deop/Voice/Devoice Script [Re: Riamus2]
Tomao Offline
Hoopy frood

Registered: 07/07/07
Posts: 1132
Loc: United States
Originally Posted By: Riamus2
I considered putting it on the event line like that, but then you don't get the else option to give an error message to the user.
Well it's not the end of the world with $regml(). Here is just my example:
Code:
on $*:text:/^!((de)?(op|voice))( |$)/iS:#:{
var %n = $strip($2), %c = $regml(1)
if (%n) {
if ($ulevel == 10) {
cs %c #
if (%c == op) notice %n Welcome
elseif (%c == deop) notice %n Sorry
else notice $nick $+($iif(%c == voice,Vo,Devo),iced)
}
else notice $nick you can't use the command $+(!,%c)
}
}


Edited by Tomao (27/08/11 06:01 PM)

Top
#233607 - 27/08/11 08:50 PM Re: Op/Deop/Voice/Devoice Script [Re: Tomao]
Riamus2 Offline
Planetary brain

Registered: 13/10/04
Posts: 8338
Loc: NC, USA
Ah, good one. I didn't think of being able to use $regml() when the regex is in the event line. smile
_________________________
Invision Support
#Invision on irc.irchighway.net

Top