mIRC Homepage
Posted By: zad0909 Make this script op only and work - 18/10/07 03:39 AM
I have this script that works fine until I added the @. I want it to be so that only ops can use it. However, I put the @ and now it wont run at all. Ran fine without it.

Anyone know why?

Here is the script:
Quote:
ON @:TEXT:!Sban*:#: {
if ( $2 == $null ) {
notice $nick please specify a nick | return
}
if ( $2 == $me ) {
.notice $nick Nt. I don't think so. | return
}
else /mode $chan +b $2
/mode $chan +b $address($2,1)
/mode $chan +b $address($2,2)
/mode $chan +b $address($2,3)
/mode $chan +b $address($2,4)
/mode $chan +b $address($2,5)
/mode $chan +b $address($2,6)
/mode $chan +b $address($2,7)
/mode $chan +b $address($2,8)
/mode $chan +b $address($2,9)
/mode $chan +b $address($2,10)
/mode $chan +b $address($2,20)
.msg $chan better hope you dont get kicked $2. You won't be back any time soon.
}

ON @:TEXT:!Sunban*:#: {
if ( $2 == $null ) {
notice $nick please specify a nick | return
}
else /mode $chan -b $2
/mode $chan -b $address($2,1)
/mode $chan -b $address($2,2)
/mode $chan -b $address($2,3)
/mode $chan -b $address($2,4)
/mode $chan -b $address($2,5)
/mode $chan -b $address($2,6)
/mode $chan -b $address($2,7)
/mode $chan -b $address($2,8)
/mode $chan -b $address($2,9)
/mode $chan -b $address($2,10)
/mode $chan -b $address($2,20)
.msg $chan Well I felt sorry for you too.
}
Posted By: Mpot Re: Make this script op only and work - 18/10/07 03:55 AM
Change the on event from the @ over to *, and try this:

if ($nick isop $chan)

Code:
ON *:TEXT:!Sban*:#: {
  if ($nick isop on $chan) {  
    if ( $2 == $null ) { notice $nick please specify a nick | return }
    if ( $2 == $me ) { .notice $nick Nt. I don't think so. | return }
    else { 
      /mode $chan +b $2
      /mode $chan +b $address($2,1)
      /mode $chan +b $address($2,2)
      /mode $chan +b $address($2,3)
      /mode $chan +b $address($2,4)
      /mode $chan +b $address($2,5)
      /mode $chan +b $address($2,6)
      /mode $chan +b $address($2,7)
      /mode $chan +b $address($2,8)
      /mode $chan +b $address($2,9)
      /mode $chan +b $address($2,10)
      /mode $chan +b $address($2,20)
      .msg $chan better hope you dont get kicked $2. You won't be back any time soon.
    }
  }
}

ON *:TEXT:!Sunban*:#: {
  if ($nick isop on $chan) {
    if ( $2 == $null ) { notice $nick please specify a nick | return }
    else { 
      /mode $chan -b $2
      /mode $chan -b $address($2,1)
      /mode $chan -b $address($2,2)
      /mode $chan -b $address($2,3)
      /mode $chan -b $address($2,4)
      /mode $chan -b $address($2,5)
      /mode $chan -b $address($2,6)
      /mode $chan -b $address($2,7)
      /mode $chan -b $address($2,8)
      /mode $chan -b $address($2,9)
      /mode $chan -b $address($2,10)
      /mode $chan -b $address($2,20)
      .msg $chan Well I felt sorry for you too.
    }
  }
}


Also, cramming stuff up against identifiers never turns out well:

$2.

could be

$2 $+ .

$+ combines the identifier and whatever else, while still parsing it properly.
Posted By: 5618 Re: Make this script op only and work - 18/10/07 11:30 AM
and just to clarify, from the /help file:
Quote:
The @ prefix

You can limit events to being executed only when you have Ops on a channel by using the @ prefix.

on @2:JOIN:#mIRC:/mode $chan +o $nick

When the above user joins channel #mIRC and you have Ops on #mIRC, the associated /mode command will be executed, in this case giving the user Ops. If you don't have Ops, the event will not trigger.

So this makes the script trigger only when you have ops, not when others do. For that you use the abovementioned if-statement: if ($nick isop $chan)
Posted By: Riamus2 Re: Make this script op only and work - 18/10/07 12:48 PM
Change the 2 "if ($nick isop on $chan) {" in Mpot's code to:

Code:
if ($nick isop $chan) {


As mentioned @ checks if YOU are an op, not the person triggering the script.
Posted By: zad0909 Re: Make this script op only and work - 18/10/07 02:13 PM
Ooo I see. Thanks Riamus didn't understand that.

By the way mpot, I don't understand how to use the $2 $+. Could you give me an example as to how it would be used in this script?

Also I remember a friend telling me you could put something like $2- and it meant that the script would not run if $2 was empty or not specified. I know I did a if $2 == null thingy. BUt whats the command just for my own curiosty, is it $2-?
Posted By: RoCk Re: Make this script op only and work - 18/10/07 02:45 PM
if (!$2)

/help if then else

Originally Posted By: mirc.chm

You can use the ! prefix in front of variables and identifiers in an if-then-else statement to negate a value.

Posted By: Mpot Re: Make this script op only and work - 18/10/07 04:42 PM
Oops, I did put an "on" in there. Should be isop $chan, not isop on chan. ANYHOW.

A double $$ means that the script won't run if the data isn't specified. A single $ means that it'll try and run anyway. As for $-, that basically means that the identifier can have more than one word. For example:

I like pie! could be $1 $2 $3

or

$1-


--


$+ combines things. For instance:

I li $+ ke pi $+ e

Would turn in to

I like pie

The point of doing that is so that you can combine stuff in the output. Let's say you wanted to message the channel with a comma after the nickname.

msg $chan What's up $nick, how are you?

Would cause an error, because the engine reads it incorrectly.

However, this would work and allow the engine to read it properly, and still output with the comma after the nick:

msg $chan What's up $nick $+ , how are you?


--

Oh, yeah, for stopping if something inputted:

if ($1 == $null) { return }

Or, shorten it to

if (!$2) { return }

The ! is a negation prefix.
Posted By: RoCk Re: Make this script op only and work - 18/10/07 06:16 PM
Originally Posted By: Mpot

I like pie! could be $1 $2 $3

or

$1-



I like pie! could also be $1-3
Posted By: Wims Re: Make this script op only and work - 18/10/07 06:17 PM
if ($1 == $null) { }
is different of
if (!$1) { }

!$1 means that $1 is equal to $false, $null or 0, not only $null
Posted By: zad0909 Re: Make this script op only and work - 18/10/07 06:31 PM
Thanks for clearing all that up guys <3
© mIRC Discussion Forums