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.
on *:TEXT:!trigger:*: /msg $chan $read(textfile.txt)
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.
Works perfectly, thank you.
just wondering, whats the point of %talk? why not just have "else {" instead of "elseif (%talk) {" ?
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
Explained it in better words than I could
oh yeah, didn't think of that, having a blonde night tonight
Personaly I would simply kill the command if the command isny available since you could still get flooded off a server with that.