This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

need help - flood code - random wait time

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
D
Diamond85
Voice
Posts: 27
Joined: Sat Oct 25, 2008 5:12 pm

need help - flood code - random wait time

Post by Diamond85 »

Hello EggHelp user! I need help again ...
I want a flood code.
three times that a user can use the command.
then he must wait one random time of under 30 seconds minimum and maximum 3Minutes..
Important: (the person should not be ignored but the command can not use).
it should be a variable available for the command, for example:

# How often can use
varaible maxuse "3"


is that possible?


with my code that I have, I will not work: (

Code: Select all

  variable command_char "!"
 
 # set these to your preferred binds
  variable command_bind "Join_Counter"
 
 # how many requests in how many seconds is considered flooding?
 # by default, this allows 2 queries in 60 seconds, the 3th being wait
  variable flood_limit "2:60"
 
 # number of wait seconds for the flooder
 # "0" - disable wait, "60" - the flooder must wait 60 seconds
  variable wait_time "60"
 
 # set here the admin flags (m=Master / n=Owner / o=OP ...)
 # to enable or disable this script on channel commands
  variable user_flags "+mno|+mno"
 
 # set here the default language
 # "en" - english, "de" - german
  variable text_lang "de"
 
 # set here the nicks are not to be added to database
  variable no_nicks "*guest*"
 
  # set here to channel record default on / off
  variable chan_record "on"

Code: Select all

 #############################################################################
 #                                Flood Check                                #
 #############################################################################
  proc fc_check {nick host hand chan arg} {
   if {[channel get $chan Join_Counter]} {
    if {[Join_Counter::fa_flood $nick $host $hand $chan $arg]} {
     return
    }
    Join_Counter::sa_action2 $nick $host $hand $chan $arg
   }
  }
 #############################################################################
 #                               Flood Action                                #
 #############################################################################
  variable fa_data
  variable fa_array
  proc fa(init) {} {
   foreach chan [channels] {
    if {![string match *:* [channel get $chan Join_Counter-Flood]]} {
     if {[channel get $chan Join_Counter-Lang] == "en"} {
      putlog "\[14Join_Counter 04Error\] 14variable \(09flood_limit: 09[channel get $chan Join_Counter-Flood]) 14is not set correctly."
      return 1
     }
         if {[channel get $chan Join_Counter-Lang] == "de"} {
      putlog "\[14Join_Counter 04Error\] 14variable \(09flood_limit: 09[channel get $chan Join_Counter-Flood]) 14wurde nicht richtig Eingestellt."
      return 1
     }
    }
    set Join_Counter::fa_data(flood_num) [lindex [split [channel get $chan Join_Counter-Flood] :] 0]
    set Join_Counter::fa_data(flood_time) [lindex [split [channel get $chan Join_Counter-Flood] :] 1]
    set i [expr $Join_Counter::fa_data(flood_num) - 1]
    while {$i >= 0} {
     set Join_Counter::fa_array($i) 0
     incr i -1
    }
   }
  }
  ; fa(init)
  proc fa_flood {nick host hand chan arg} {
   if {$Join_Counter::fa_data(flood_num) == 0} {
    return 0
   }
   set i [expr ${Join_Counter::fa_data(flood_num)} - 1]
   while {$i >= 1} {
    set Join_Counter::fa_array($i) $Join_Counter::fa_array([expr $i - 1])
    incr i -1
   }
   set Join_Counter::fa_array(0) [unixtime]
   if {[expr [unixtime] - $Join_Counter::fa_array([expr ${Join_Counter::fa_data(flood_num)} - 1])] <= ${Join_Counter::fa_data(flood_time)}} {
    Join_Counter::wa_action $nick $host $hand $chan $arg
    return 1
   } else {
    return 0
   }
  }
 #############################################################################
 #                               Wait Action                                 #
 #############################################################################
  proc wa_action {nick host hand chan arg} {
   if {[set timeleft [Join_Counter::wa_throttled $host,$chan [channel get $chan Join_Counter-Wait]]]} {
    if {[channel get $chan Join_Counter-Lang] == "en"} {
     putnow "PRIVMSG $chan :\[14Join_Counter 04Flood Protection\] 09You 14can only again in 04$timeleft 14seconds!"
    }
    if {[channel get $chan Join_Counter-Lang] == "de"} {
     putnow "PRIVMSG $chan :\[14Join_Counter 04Flood Protection\] 09Du 14darfst erst wieder in 04$timeleft 14Sekunden!"
    }
   } else {
    Join_Counter::sa_action2 $nick $host $hand $chan $arg
   }
  }
  proc wa_throttled {id time} {
   global wa_throttled
   if {[info exists wa_throttled($id)]} {
    return [expr {($wa_throttled($id)+$time)-[clock sec]}]  
   } {
    set wa_throttled($id) [clock sec]
    utimer $time [list unset wa_throttled($id)]
    return 0
   }
  }

the whole script I have here has 1069 lines so I'd rather not post this :)
Link to TCL on Pastebin

sorry for my bad english
Post Reply