mIRC Home    About    Download    Register    News    Help

Print Thread
Simple deop protection script? #135827 17/11/05 10:31 PM
Joined: Nov 2005
Posts: 11
N
ninjin Offline OP
Pikka bird
OP Offline
Pikka bird
N
Joined: Nov 2005
Posts: 11
Hi, i tried to write simple andi-deop script,but it is not working..:

on 1:DEOP:#: {
if $address == someident@some.host then mode $chan +o $opnick
}

where's the mistake? smirk

i also wanted to add something,that will deop the deopper of user i want to protect with this,but it will deop him and then i deop myself frown
please help,iam newbie in mIRC scripting...

Re: Simple deop protection script? #135828 17/11/05 11:14 PM
Joined: Aug 2005
Posts: 525
S
schaefer31 Offline
Fjord artisan
Offline
Fjord artisan
S
Joined: Aug 2005
Posts: 525
Well, your logic is right but you don't actually use the word then wink

Code:
on @1:DEOP:#:{
  if ($remove($address($opnick,1),$chr(42),$chr(33)) == ident@hostmask.com) {
    mode # +o $opnick

    if ($nick ison #) {
      mode # -o $nick
    }
  }
}


Though, I think your best bet is to make use of the userlist, especially if there are many [email]ident@hostmasks[/email] to check for.

Re: Simple deop protection script? #135829 18/11/05 07:45 AM
Joined: Nov 2005
Posts: 11
N
ninjin Offline OP
Pikka bird
OP Offline
Pikka bird
N
Joined: Nov 2005
Posts: 11
Ooh, thank you, god bless you smile
Ok it's working,that'S great, but can you explain me, what exactly this condition do? ( if ($remove($address($opnick,1),$chr(42),$chr(33)) )
i don't want just script that works, i'd be glad to understand it as well smile

and ad userlist: actually i would use it on about 3-4 addresses so i don't know, maybe it could be :P.. but if you have free time for me,i'd be glad if you explain me,how to create that userlist and how to make the script work with it smile

Re: Simple deop protection script? #135830 18/11/05 07:54 AM
Joined: Aug 2004
Posts: 7,252
R
RusselB Offline
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
$remove($address($opnick,1),$chr(42),$chr(33))

taking it step by step, as mIRC would do it
1) get the nick that was opped
$opnick
2) find their address, using a #1 mask
$address($opnick,1)
3) remove the characters $chr(42) & $chr(33) from the address
NOTE: these two characters correspond with the ! & *

For more information read up
/help $remove
/help $address
/help $mask
/help $chr
/help $asc

Regarding the user list, you can create a text file with each users address on a different line, and then use $read(<text file>,s,<address>) to search the text file for that address.

Re: Simple deop protection script? #135831 18/11/05 08:21 AM
Joined: Aug 2005
Posts: 525
S
schaefer31 Offline
Fjord artisan
Offline
Fjord artisan
S
Joined: Aug 2005
Posts: 525
Code:
on [color:green]@[/color]1:DEOP:#:{
  if ([color:green]$remove($address($opnick,1),$chr(42),$chr(33)) == ident@hostmask.com[/color]) {
    mode # +o $opnick

    if ([color:green]$nick ison #[/color]) {
      mode # -o $nick
    }
  }
}


@ - The @ prefix means that it will not execute unless YOU are opped.


$remove($address($opnick,1),$chr(42),$chr(33)) == [email]ident@hostmask.com[/email] - This is essentially the same as what you were doing.

$address($opnick,1) - Returns the opnick's address in the form *!*ident@hostmask.
We aren't interested in the *!* part so I used $remove to take out those characters.
$chr(44) is the * and $chr(33) is the !
Thus the address format, after doing the removal results in this form [email]ident@hostmask[/email]


$nick ison # - This checks if the user who did the deop is still on the channel and if so, it will deop him.


-------------------------------------

Regarding the user list. This is quite simple to do and more practical if you're dealing with many addresses.

Press Alt + R and switch to the Users tab

In this window you can add users with the following format (one per line)
AccessLevel:nick!ident@hostmask

You can use wildcards here.

The default AccessLevel for all nicks is 1, so if you make use of this be sure to give a higher number than 1.

So for example lets say we have an user who's nick is MircUser, his ident is mirc and his hostmask is 127-0-0-1.client.isp.com

We'd like to give him an access level of 5 according to his hostmask, so in the user list we add this line

5:*!*@127-0-0-1.client.isp.com I will use this particular form of access in describing the integration further down

If we wanted to make it a bit more restricted, we could also make it include his ident, so you would add this line in place of the previous one

5:*!mirc@127-0-0-1.client.isp.com

I think you should understand where I'm going with this so I'll stop with the users part here.




Onto making the script work with the user list. Remember, in the users list we have 5:*!*@127-0-0-1.client.isp.com

We want it to only trigger if the opnick has an AccessLevel of 5.

So, we replace this line:

if ($remove($address($opnick,1),$chr(42),$chr(33)) == [email]ident@hostmask.com)[/email] {

with the following:

if ($ulist($address($opnick,2),5,1) != $null) {

This will obtain the opnick's address in the form of *!*@127-0-0-1.client.isp.com, it then searches the user list for "*!*@127-0-0-1.client.isp.com" and sees if it matches to an access level of 5.
If an address is found, then it deop's the deopper and re-ops the deopped nick.

If an address if not found, it does nothing.

Here is the code if you're using the user list.


Code:
on @1:DEOP:#:{
  if ($ulist($address($opnick,2),5,1) != $null) {
    mode # +o $opnick
    if ($nick ison #) {
      mode # -o $nick
    }
  }
}

Re: Simple deop protection script? #135832 18/11/05 04:23 PM
Joined: Aug 2005
Posts: 525
S
schaefer31 Offline
Fjord artisan
Offline
Fjord artisan
S
Joined: Aug 2005
Posts: 525
I've left out a check to see if the deopper is you ($me). Now it will not deop if you are the one doing the deop.

Code:
on @1:DEOP:#:{
  if ($ulist($address($opnick,2),5,1) != $null) {
    mode # +o $opnick
    if ($nick ison #) {
      if ($nick != $me) {
        mode # -o $nick
      }
    }
  }
}

Re: Simple deop protection script? #135833 18/11/05 04:45 PM
Joined: Nov 2005
Posts: 11
N
ninjin Offline OP
Pikka bird
OP Offline
Pikka bird
N
Joined: Nov 2005
Posts: 11
wow guys,thx for your help, now i understand it a bit more.. but there is one more bug-when i deop somebody protected, the script will reop him and deop myself smile
so i added this at the start smile :

Code:
if ($nick == $me) {
 halt
}

Re: Simple deop protection script? #135834 18/11/05 05:04 PM
Joined: Oct 2004
Posts: 8,330
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
The ! prefix will prevent it from triggering if you did it...

on !@*:deop:#: {

You can then avoid those if $nick == me and if $nick != $me parts.

Also, the if ($nick != $me) should have done what yours did, besides that it still re-opped the person. It shouldn't have deopped you.

Finally, if you want to halt a script prematurely like that, it is better to use RETURN instead of HALT.


Invision Support
#Invision on irc.irchighway.net
Re: Simple deop protection script? #135835 18/11/05 05:30 PM
Joined: Nov 2005
Posts: 11
N
ninjin Offline OP
Pikka bird
OP Offline
Pikka bird
N
Joined: Nov 2005
Posts: 11
ah you were faster... i had it written here but i forget to post it.. but is it correct too, as i have it? it is working,so i think it is :P

Re: Simple deop protection script? #135836 18/11/05 05:50 PM
Joined: Oct 2004
Posts: 8,330
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Yes, that should work with the halt. It's not needed, but it will work. smile


Invision Support
#Invision on irc.irchighway.net
Re: Simple deop protection script? #135837 18/11/05 05:55 PM
Joined: Aug 2005
Posts: 525
S
schaefer31 Offline
Fjord artisan
Offline
Fjord artisan
S
Joined: Aug 2005
Posts: 525
When I tried doing !@* as you suggested, it does not re-op the deopped nick if they have a certain user level/hostmask. I guess this makes sense that it wouldn't but if the user is "protected" it should still re-op that user regardless of who did it.

Re: Simple deop protection script? #135838 18/11/05 06:13 PM
Joined: Nov 2005
Posts: 11
N
ninjin Offline OP
Pikka bird
OP Offline
Pikka bird
N
Joined: Nov 2005
Posts: 11
hmm and what about if i want to allow some people from the list to deop protected too?
how will that look?
i tried something, but no effect

Re: Simple deop protection script? #135839 18/11/05 06:29 PM
Joined: Oct 2004
Posts: 8,330
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
You could just do:
Code:
on @*:deop:#: {
  if ($nick != $me &amp;&amp; $address($nick,2) != [color:red]some_address_in_#2_mask_format[/color] &amp;&amp; $address($nick,2) != [color:red]some_other_address[/color]) {
    [color:blue]; Insert re-op and deop code here.[/color]
  }
}


Invision Support
#Invision on irc.irchighway.net
Re: Simple deop protection script? #135840 20/11/05 09:51 PM
Joined: Nov 2005
Posts: 11
N
ninjin Offline OP
Pikka bird
OP Offline
Pikka bird
N
Joined: Nov 2005
Posts: 11
Quote:
You could just do:
Code:
on @*:deop:#: {
  if ($nick != $me &amp;&amp; $address($nick,2) != [color:red]some_address_in_#2_mask_format[/color] &amp;&amp; $address($nick,2) != [color:red]some_other_address[/color]) {
    [color:blue]; Insert re-op and deop code here.[/color]
  }
}

uh.. thanks too,but can i ask-what'S the #2 mask format?

Re: Simple deop protection script? #135841 21/11/05 12:54 AM
Joined: Dec 2002
Posts: 1,245
M
MikeChat Offline
Hoopy frood
Offline
Hoopy frood
M
Joined: Dec 2002
Posts: 1,245
Quote:
You could just do:
Code:
on @*:deop:#: {
  if ($nick != $me &amp;&amp; $address($nick,2) != [color:red]some_address_in_#2_mask_format[/color] &amp;&amp; $address($nick,2) != [color:red]some_other_address[/color]) {
    [color:blue]; Insert re-op and deop code here.[/color]
  }
}

uh.. thanks too,but can i ask-what'S the #2 mask format?

/help $mask

$address($nick,2) <-- the 2 in that outputs the address in the format described in the table in the help file for $mask.

this string if ($nick != $me && $address($nick,2) != some_address_in_#2_mask_format && $address($nick,2) != some_other_address)
well I wouldnt do it that way, even though it may work I would conform to what is in the help files as when updates to mIRC come along shortcuts like that often no longer work
/help &&

Quote:

Combining comparisons
You can combine comparisons by using the && for AND and || for OR characters.

if (($1 > 0) && ($1 < 10)) {