That's kind of complicated for what can be done with less code.

Code:
on *:text:hi:#: {
  if (%flood) { return }
  set -u10 %flood On

  ; The rest of the script goes here
}


Notes for OP:
I strongly recommend using a variable name that is unique to avoid conflicts with other scripts. %flood is too generic. I used it here just to be clear as to what the variable represents.

Also, this same flood control can be used anywhere you want. Insert those same 2 lines above any code you want to be protected. With that in mind, if you use the same variable every time, you will have global flood protection on any scripts that have this code. That means that no matter what command is used, you'll only reply once every 10 seconds (or whatever you change the 10 to). Depending on the number of commands you allow and the amount of response text you have for each and how often those are used, this can be necessary. If 20 people all use different commands once at the same time, you will be flooded off the network if the flood protection isn't global, for example. However, if you don't need global flood protection (usually you won't), then you can use different variable names for each flood control. That will let each command have their own 10 second flood protection such that even if one person uses one command, another person can use a different command within those 10 seconds without it being ignored. In most cases, this works well.


*** There is one benefit to using $ctime as shown in the post above and that is that it cannot get messed up due to mIRC crashing or being closed before the timer expires. However, it's still more than is necessary. There's an easy "fix" to prevent any problems with the flood control variables and it lets you use the code throughout your script without having a larger set of code everywhere. Just add the following to your script and name all your variables with the same beginning (you can change the beginning of course):

Code:
on *:start: { unset %flood.* }


Now, you might have something like %flood.hi and %flood.help and %flood.rules and such. This will guarantee that regardless of crashing or closing mIRC during the timer, your variable will still be unset. Again, I recommend something other than %flood for this, but it is at least somewhat "safer" to use when you add the ".whatever" to it.

Last edited by Riamus2; 20/01/11 08:03 PM.

Invision Support
#Invision on irc.irchighway.net