You may alternatively use a hash table, adding an item to the table for every *whatever* action that unsets after N seconds.
Advantages of this method:
- hash tables are ~ as fast as variables
- all data will be destroyed (unless saved) on exit - no need to care for unsetting variables on start (e.g. in case of a crash)
- each item unsets separately: you can check precisely for the current No. of items
- you may perform wildcard checks (if item and / or data was named properly)

Example 1
Code:
alias test {
; add to table "test" for 20 seconds a random-named item with dummy data "x" 
  hadd -mu20 test $rand(1,99999) x

  if ($hget(test,0).item < 5) { ECHO -a triggered "test" less than 5times in the last 20 seconds }
  else { ECHO -a triggered "test" $hget(test,0).item times in the last 20 seconds }
}

Example2 to illustrate some wildcard checks
Code:
; on join of a user: add to table "joins" for 180 seconds a random-named item with data "<connectionID>chr1<channel>chr1<nick>" . 
on *:join:#: {
  hadd -mu180 joins $rand(1,99999) $+($cid,$chr(1),$chan,$chr(1),$nick)

  ECHO -a total No. of joins (all connections, all channels) (last 30s): $hget(joins,0).item
  ECHO -a No. of joins on this connection $cid (last 30s): $hfind(joins, $+($cid,$chr(1),*) ,0,w).data
  ECHO -a No. of joins on this connection $cid and this channel $chan (last 30s): $hfind(joins, $+($cid,$chr(1),$chan,$chr(1),*) ,0,w).data
  ECHO -a No. of joins of the nick $nick on all connections (last 30s): $hfind(joins, $+(*,$chr(1),$nick) ,0,w).data
}