mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Aug 2011
Posts: 3
M
Self-satisified door
OP Offline
Self-satisified door
M
Joined: Aug 2011
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

Last edited by mysticalNinja; 25/08/11 04:15 PM.
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
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.

Last edited by Riamus2; 25/08/11 04:22 PM.

Invision Support
#Invision on irc.irchighway.net
Joined: Aug 2011
Posts: 3
M
Self-satisified door
OP Offline
Self-satisified door
M
Joined: Aug 2011
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

Last edited by mysticalNinja; 25/08/11 04:28 PM.
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
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
Joined: Aug 2011
Posts: 3
M
Self-satisified door
OP Offline
Self-satisified door
M
Joined: Aug 2011
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.

Last edited by mysticalNinja; 25/08/11 07:44 PM.
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
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
Joined: Jul 2007
Posts: 1,129
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,129
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.

Last edited by Tomao; 26/08/11 12:56 AM.
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
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
Joined: Jul 2007
Posts: 1,129
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,129
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.

Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
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
Joined: Jul 2007
Posts: 1,129
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,129
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.

Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
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

Last edited by Riamus2; 27/08/11 03:02 PM.

Invision Support
#Invision on irc.irchighway.net
Joined: Jul 2007
Posts: 1,129
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,129
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)
}
}

Last edited by Tomao; 27/08/11 05:01 PM.
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
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

Link Copied to Clipboard