mIRC Homepage
Posted By: sparta speed/tweak this up a bit? - 13/07/07 10:24 PM
This one work, how ever it's slow, any way to tweak this to be faster? care to explain how smile
Code:
on *:ban:#: {
  if ($me isop $chan) && ($banmask iswm $address($me,5)) && ($banmask != *!*@*) && ($banmask != *!~*@*) && (%banpro == enabled) {
    mode $chan -b $banmask
    mode $chan -bo $banmask $nick
    kick $chan $nick $eval(%bbanki,2)
    .notice $nick Don't ban me on $chan $+ .
  }
  if ($me !isop $chan) && ($banmask iswm $address($me,5)) && (%ban.pro == Enabled) {
    echo -at You got banned, you arent oped in $chan $+ .
  }
  elseif ($me isop $chan) && ($banmask != *!*@*) && ($banmask != *!~*@*) && (%enforceban == enabled) {
    var %banmask = $banmask
    if ($ial(%banmask,0).nick == 0) { return }
    if ($banmask iswm $address($me,5)) { return }
    var %totbu = $ial(%banmask,0).nick
    var %stb = 1
    while (%stb <= %totbu) {
      kick $chan $ial(%banmask,%totbu).nick $eval(%bbankick,2)
      inc %stb 
    }
  }
}
Posted By: starbucks_mafia Re: speed/tweak this up a bit? - 13/07/07 10:42 PM
Code:
on *:ban:#: {
  if ($me !isop $chan) && ($banmask iswm $address($me,5)) && (%ban.pro == Enabled) {
    echo -at You got banned, you arent oped in $chan $+ .
  }
  if ($me isop $chan) && ($banmask != *!*@*) && ($banmask != *!~*@*) {
    if ($banmask iswm $address($me,5)) && (%banpro == enabled) {
      mode $chan -bo $banmask $nick
      kick $chan $nick $eval(%bbanki,2)
      .notice $nick Don't ban me on $chan $+ .
    }
    elseif (%enforceban == enabled) {
      var %stb = $ial($banmask,0).nick
      if ($banmask !iswm $address($me,5)) {
        while %stb {
          kick $chan $ial($banmask, %stb).nick $eval(%bbankick,2)
          dec %stb 
        }
      }
    }
  }
}


You can probably see I haven't really changed much. I just re-arranged the if's a bit so that you don't check for the same conditions more than once, I've removed a couple of unnecessary variables (%banmask and %totbu) and removed a duplicate mode command.

There was also a bug in your original code that you were looping over %stb but you were kicking $ial(%banmask, %totbu).nick, so you were kicking the same guy %totbu times.

Note that the code I've given you is untested.
Posted By: Bekar Re: speed/tweak this up a bit? - 13/07/07 10:56 PM
Also, why use $ial() when you're only going to be acting on $chan anyway?

Use $ialchan() instead, much smaller data set. In any case, using $ial() without verifying $comchan() means you could get false-positive's with failed kicks.

Code:
var %stb = $ialchan($banmask, $chan, 0)

You should also set %stb inside of the final 'if'. If you're not going to use %stb, why set it.

Code:
kick $chan $gettok($ialchan($banmask, $chan, %stb), 1, 33) $eval(%bbankick,2)

.. just a few comments .. smile
Posted By: starbucks_mafia Re: speed/tweak this up a bit? - 13/07/07 11:09 PM
Good point. Using $ialchan will probably speed it up more than anything I'd changed in the code. I haven't worked with the IAL in a while, looks like I'm a little rusty!

Yeah the variable could be moved inside the if too. I shifted the code about a bit before submitting and I guess I missed that line.
Posted By: sparta Re: speed/tweak this up a bit? - 13/07/07 11:16 PM
thankyou for the answers, i look at what you did to the code, then try to rewrite the whole thing smile
Posted By: vexed2 Re: speed/tweak this up a bit? - 14/07/07 02:37 AM
Looking forward to the script release.
Gonna be a lot of names from mirc.co.uk forum on the credit list. grin
© mIRC Discussion Forums