mIRC Home    About    Download    Register    News    Help

Print Thread
speed/tweak this up a bit? #180798 13/07/07 10:24 PM
Joined: Feb 2003
Posts: 3,432
S
sparta Offline OP
Hoopy frood
OP Offline
Hoopy frood
S
Joined: Feb 2003
Posts: 3,432
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 
    }
  }
}


if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }
Re: speed/tweak this up a bit? [Re: sparta] #180804 13/07/07 10:42 PM
Joined: Dec 2002
Posts: 2,962
S
starbucks_mafia Offline
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 2,962
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.


Spelling mistakes, grammatical errors, and stupid comments are intentional.
Re: speed/tweak this up a bit? [Re: starbucks_mafia] #180806 13/07/07 10:56 PM
Joined: Dec 2002
Posts: 503
B
Bekar Offline
Fjord artisan
Offline
Fjord artisan
B
Joined: Dec 2002
Posts: 503
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

Re: speed/tweak this up a bit? [Re: Bekar] #180810 13/07/07 11:09 PM
Joined: Dec 2002
Posts: 2,962
S
starbucks_mafia Offline
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 2,962
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.


Spelling mistakes, grammatical errors, and stupid comments are intentional.
Re: speed/tweak this up a bit? [Re: starbucks_mafia] #180812 13/07/07 11:16 PM
Joined: Feb 2003
Posts: 3,432
S
sparta Offline OP
Hoopy frood
OP Offline
Hoopy frood
S
Joined: Feb 2003
Posts: 3,432
thankyou for the answers, i look at what you did to the code, then try to rewrite the whole thing smile


if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }
Re: speed/tweak this up a bit? [Re: sparta] #180819 14/07/07 02:37 AM
Joined: Mar 2007
Posts: 218
V
vexed2 Offline
Fjord artisan
Offline
Fjord artisan
V
Joined: Mar 2007
Posts: 218
Looking forward to the script release.
Gonna be a lot of names from mirc.co.uk forum on the credit list. grin