Maybe I go overboard, but the "inc -uN <singlevar>" approach for flood protections might act different than intended.
For example, you call a limit "4 lines in 10 seconds". Now, if someone's sending 4 messages with 8 seconds offset, your script will trigger regardless of the fact that the 4 lines are spread over 24seconds (the -uN timer restarts for each new line).
You might use the method outlined here, using $ticks or $rand.

As you are familiar with hash tables, you might used them instead of %vars (the variables section remains clean; and after a crash, nothing remains there).

I'm sure you want to take $chan into account (or an /amsg with many comchans might trigger your flood protection), and $cid as well. Last, on action could be added smile

More simple version:
Code:
on *:text:*:#: {
  var %unset = 10, %limit = 4

  ; add to a TABLE "flood" the ITEM "<$cid><$chan><$nick><randomnumber> with DATA <dummy-char>
  hadd $+(-mu,%unset) flood $+($cid,$chr(10),$chan,$chr(10),$nick,$chr(10),$rand(1,999)) x

  if ($hfind( flood, $+($cid,$chr(10),$chan,$chr(10),$nick,$chr(10),*) ,0,w) >= %limit) {
    echo $chan $nick wrote $v1 lines on $chan in %unset seconds. limit is $v2
  }
}


Another version, just to show the possibilities of $hfind. Most of the checks below certainly are useless for you smile
Code:
on *:text:*:#: {
  var %unset = 10

  ; add to a TABLE "flood<$cid>" the ITEM "<$chan><$nick><randomnumber>" 
  ; with DATA "<$chan><$nick><message>"
  hadd $+(-mu,%unset) $+(flood,$cid) $+($chan,$chr(10),$nick,$chr(10),$rand(1,999)) $+($chan,$chr(10),$nick,$chr(10),$1-)

  ; with hfind, you now can do multiple protections at once


  ; Floodcheck

  ; normal (x lines per y seconds per nick in that channel)
  if ($hfind( $+(flood,$cid) , $+($chan,$chr(10),$nick,$chr(10),*) ,0,w) > 3) {
    echo $chan $nick wrote $v1 lines on $chan in %unset seconds. limit is $v2
  }

  ; channel (x lines per y seconds in that channel)
  if ($hfind( $+(flood,$cid) , $+($chan,$chr(10),*) ,0,w) > 10) {
    echo $chan $v1 lines on $chan in %unset seconds. limit is $v2
  }

  ; global spam (all comchans: x lines per y seconds by that nick)
  if ($hfind( $+(flood,$cid) , $+(*,$chr(10),$nick,$chr(10),*) ,0,w) > 10) {
    echo -a $nick wrote $v1 lines on all comchans. limit is $v2
  }


  ; Repetitions 

  ; normal (x repetitions of a text in y seconds by a nick in a channel)
  if ($hfind( $+(flood,$cid) , $+($chan,$chr(10),$nick,$chr(10),$1-) ,0).data > 3) {
    echo $chan $nick repeated a text $v1 times in $chan . limit is $v2
  }

  ; global 1 (x repetitions of a text in y seconds by a nick in all comchans) - meant as a demo only.
  ; BEWARE of /amsg triggering this - but may be usefull in connection with "url spam checks" or the like.
  if ($hfind( $+(flood,$cid) , $+(*,$chr(10),$nick,$chr(10),$1-) ,0,w ).data > 3) {
    echo -a $nick repeated a text in all comchans $v1 times. limit is $v2
  }

  ; global2 (x repetitions of a text in y seconds in all comchans)
  if ($hfind( $+(flood,$cid) , $+(*,$chr(10),*,$chr(10),$1-) ,0,w ).data > 3) {
    echo -a A text has been repeated $v1 times in all comchans. limit is $v2
  }

  ; ...

}

Last edited by Horstl; 15/11/08 03:22 AM.