mIRC Home    About    Download    Register    News    Help

Print Thread
#222517 21/06/10 02:36 PM
Joined: Jun 2004
Posts: 124
S
sigbin Offline OP
Vogon poet
OP Offline
Vogon poet
S
Joined: Jun 2004
Posts: 124
how can i make OP immune to this scripts its a anti-swear script? anyone?
Code:
alias swear {
  return swear1 swear2 swear3
}

On *:Text:*:#channel: {
  if (!$hget(swear)) hmake swear 10
  var %swr = 1
  while ($gettok($swear,%swr,32)) {
    if ($+(*,$gettok($swear,%swr,32),*) iswm $1-) {
      hinc swear $nick
      var %swear = $gettok($swear,%swr,32)
      if ($hget(swear,$nick) == 1) do something here
      if ($hget(swear,$nick) == 3) .do something here
    }
    inc %swr
  }
}


On *:Action:*:#channel: {
  if (!$hget(swear)) hmake swear 10
  var %swr = 1
  while ($gettok($swear,%swr,32)) {
    if ($+(*,$gettok($swear,%swr,32),*) iswm $1-) {
      hinc swear $nick
      var %swear = $gettok($swear,%swr,32)
      if ($hget(swear,$nick) == 1) do something here
      if ($hget(swear,$nick) == 3) do something here
    }
    inc %swr
  }
}

Joined: Jan 2010
Posts: 6
Nutrimatic drinks dispenser
Offline
Nutrimatic drinks dispenser
Joined: Jan 2010
Posts: 6
Hey there,

To make your code immune to OPs and yourself... Here is one way you can do it smile

Code:
alias swear {
  return swear1 swear2 swear3
}

On !*:Text:*:#channel: {
if ($nick !isop #) {
  if (!$hget(swear)) hmake swear 10
  var %swr = 1
  while ($gettok($swear,%swr,32)) {
    if ($+(*,$gettok($swear,%swr,32),*) iswm $1-) {
      hinc swear $nick
      var %swear = $gettok($swear,%swr,32)
      if ($hget(swear,$nick) == 1) do something here
      if ($hget(swear,$nick) == 3) .do something here
    }
    inc %swr
  }
}
}

On !*:Action:*:#channel: {
if ($nick !isop #) {
  if (!$hget(swear)) hmake swear 10
  var %swr = 1
  while ($gettok($swear,%swr,32)) {
    if ($+(*,$gettok($swear,%swr,32),*) iswm $1-) {
      hinc swear $nick
      var %swear = $gettok($swear,%swr,32)
      if ($hget(swear,$nick) == 1) do something here
      if ($hget(swear,$nick) == 3) do something here
    }
    inc %swr
  }
}
}


By adding a ! prefix to your on EVENTs, this halts proceeding with the event if you have triggered it yourself.. So in this case if you have typed a swear word you will be ignored smile

By adding if ($nick !isop #) { }
This says if a $nick is not an op, then proceed with the command... If you remove the ! character from this, it would say if $nick is an op proceed.. Which is not what you want to do in this case..

Hope this helps smile

Kind Regards,
Daniel

Joined: Jul 2007
Posts: 1,129
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,129
You can also do
Code:
if ($nick(#,$nick,rv)) {
so that this script only gets triggered for voiced and regular users. If you want to exclude the voiced, just remove the letter v. Then if that's to mainly address the regular user, a positive approach would become: $nick isreg $chan

Anyway, this
Quote:
if ($nick !isop #) {
if (!$hget(swear)) hmake swear 10
Can just be:
Code:
if ($nick !isop #) && (!$hget(swear)) {
 hmake swear 10
saves yourself a if and a bracket.

The whole script, as a matter of fact, can just be:
Code:
On *:Text:*:#channel: { swear $1- }
On *:Action:*:#channel: { swear $1- }
alias -l swear {
  if ($nick !isop #) && (!$hget(swear)) hmake swear 10
  var %swr = 1
  while ($gettok($swear,%swr,32)) {
    if ($+(*,$gettok($swear,%swr,32),*) iswm $strip($1-)) {
      hinc swear $nick
      var %swear = $gettok($swear,%swr,32)
      if ($hget(swear,$nick) == 1) do something here
      if ($hget(swear,$nick) == 3) .do something here
    }
    inc %swr
  }
}

Joined: Sep 2009
Posts: 52
Z
ziv Offline
Babel fish
Offline
Babel fish
Z
Joined: Sep 2009
Posts: 52
The channel has to be passed to the alias though.
Also, I don't think the table creation has anything to do with the rest of the code, which should execute if it's not an op.

Code:
On *:Text:*:#channel: { swear $chan $1- }
On *:Action:*:#channel: { swear $chan $1- }
alias -l swear {
  if ($nick !isop $1) {
  if (!$hget(swear)) hmake swear 10
  var %swr = 1
  while %swr <= $lines($mircdirswear.txt) {
    if ($+(*,$read($mircdirswear.txt,%swr),*) iswm $strip($2-)) {
      hinc swear $nick
      if ($hget(swear,$nick) == 1) .do something here
      if ($hget(swear,$nick) == 3) .do something here
    }
    inc %swr
  }
}


This should work perfectly fine, you can place cos words in a text file called swear.txt, one on every line.
The file should be placed in your mIRC directory, in Win7 this is C:\Users\YOUR-USER-NAME\App-Data\Roaming\mIRC\

Enjoy,
ziv.

Joined: Feb 2009
Posts: 133
C
Vogon poet
Offline
Vogon poet
C
Joined: Feb 2009
Posts: 133
"iswm" isnt a good idea bcz if u say hotel, campus or other thing this will be taken as a swear!!


WorldDMT
Joined: Jul 2007
Posts: 1,129
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,129
ziv, you don't need to pass it. The $chan or # will work. Why go the extra mile for when you can just do swear $1- ? Try it for yourself. Yes, I agree with chacha. It'd be better to use $istok then:
Code:
On *:Text:*:#: { swear $1- }
On *:Action:*:#: { swear $1- }
alias -l swear {
  if ($nick !isop #) {
    if (!$hget(swear)) hmake swear 10
    var %swr = 1
    while %swr <= $lines($mircdirswear.txt) {
      if ($istok($strip($1-),$read($mircdirswear.txt,%swr),32)) {
        hinc swear $nick
        if ($hget(swear,$nick) == 1) .do something here
        if ($hget(swear,$nick) == 3) .do something here
      }
      inc %swr
    }
  }
}

Joined: Sep 2009
Posts: 52
Z
ziv Offline
Babel fish
Offline
Babel fish
Z
Joined: Sep 2009
Posts: 52
I stand corrected!...well...seat corrected...
Anyways, thank you.

ziv.


Link Copied to Clipboard