mIRC Home    About    Download    Register    News    Help

Print Thread
#101483 24/10/04 11:32 PM
Joined: Jan 2003
Posts: 7
S
silik Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
S
Joined: Jan 2003
Posts: 7
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)


#101484 24/10/04 11:44 PM
Joined: Nov 2003
Posts: 2,327
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Nov 2003
Posts: 2,327
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.


New username: hixxy
#101485 25/10/04 12:11 AM
Joined: Jan 2003
Posts: 7
S
silik Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
S
Joined: Jan 2003
Posts: 7
Works perfectly, thank you. smile

#101486 25/10/04 12:25 AM
Joined: Mar 2004
Posts: 457
D
Fjord artisan
Offline
Fjord artisan
D
Joined: Mar 2004
Posts: 457
just wondering, whats the point of %talk? why not just have "else {" instead of "elseif (%talk) {" ?

#101487 25/10/04 01:21 AM
Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
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


Gone.
#101488 25/10/04 02:02 AM
Joined: Nov 2003
Posts: 2,327
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Nov 2003
Posts: 2,327
Explained it in better words than I could wink


New username: hixxy
#101489 25/10/04 02:10 AM
Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
Hehe.


Gone.
#101490 25/10/04 02:24 AM
Joined: Mar 2004
Posts: 457
D
Fjord artisan
Offline
Fjord artisan
D
Joined: Mar 2004
Posts: 457
oh yeah, didn't think of that, having a blonde night tonight

#101491 25/10/04 09:46 AM
Joined: Mar 2004
Posts: 540
A
Fjord artisan
Offline
Fjord artisan
A
Joined: Mar 2004
Posts: 540
Personaly I would simply kill the command if the command isny available since you could still get flooded off a server with that.


Link Copied to Clipboard