mIRC Homepage
Posted By: sigbin op immune to script? - 21/06/10 02:36 PM
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
  }
}
Posted By: Dan01 Re: op immune to script? - 21/06/10 02:50 PM
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
Posted By: Tomao Re: op immune to script? - 21/06/10 08:04 PM
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
  }
}
Posted By: ziv Re: op immune to script? - 21/06/10 09:41 PM
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.
Posted By: chacha Re: op immune to script? - 21/06/10 11:09 PM
"iswm" isnt a good idea bcz if u say hotel, campus or other thing this will be taken as a swear!!
Posted By: Tomao Re: op immune to script? - 22/06/10 01:27 AM
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
    }
  }
}
Posted By: ziv Re: op immune to script? - 22/06/10 02:56 PM
I stand corrected!...well...seat corrected...
Anyways, thank you.

ziv.
© mIRC Discussion Forums