mIRC Homepage
Posted By: silik flood protection - 24/10/04 11:32 PM
Hello, I wrote a little script that when triggered, randomly reads a line from a text file and sends it to the channel. The problem I have is that it will do it even if someone types the trigger, say, 10 times in rapid succession. Which, of ocurse, will get me killed for flooding. Is there a simple flood protection that could be implemented to prevent such a thing? Thank you.

Code:
on *:TEXT:!trigger:*: /msg $chan $read(textfile.txt)

Posted By: tidy_trax Re: flood protection - 24/10/04 11:44 PM
Code:
on *:TEXT:!trigger:*:{
  if (!%wait) { 
    set %wait 5
    set %talk 5
    dec -z %wait
    dec -z %talk
    msg $chan $read(textfile.txt,n)
  }
  elseif (%talk) { 
    .notice $nick Please wait %wait second $+ $iif(%wait > 1,s) before using the trigger.
    unset %talk
  }
}


Just change all instances of "5" to however many seconds you want them to wait before using the next one.
Posted By: silik Re: flood protection - 25/10/04 12:11 AM
Works perfectly, thank you. smile
Posted By: Danthemandoo Re: flood protection - 25/10/04 12:25 AM
just wondering, whats the point of %talk? why not just have "else {" instead of "elseif (%talk) {" ?
Posted By: FiberOPtics Re: flood protection - 25/10/04 01:21 AM
Hi,

when the first person types !trigger,

%wait is set to 5, so that the bot won't message another line from the text file within the 5 seconds. This is assured, because the code to relay this line, only triggers if !%wait { }

%talk is set to 5, so that the bot won't message "Please wait x seconds..." more than once, within 5 seconds. This is assured, because this message is only posted when %talk exists. After posting the message, %talk is unset, thus this message won't occur anymore.

In conclusion,

%wait is there so that the script doesn't flood with a line from the text file.
%talk is there so that the script doesn't flood with the message "Please wait x seconds.."

Greets
Posted By: tidy_trax Re: flood protection - 25/10/04 02:02 AM
Explained it in better words than I could wink
Posted By: FiberOPtics Re: flood protection - 25/10/04 02:10 AM
Hehe.
Posted By: Danthemandoo Re: flood protection - 25/10/04 02:24 AM
oh yeah, didn't think of that, having a blonde night tonight
Posted By: Armada Re: flood protection - 25/10/04 09:46 AM
Personaly I would simply kill the command if the command isny available since you could still get flooded off a server with that.
© mIRC Discussion Forums