mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Jan 2015
Posts: 40
J
jimieo Offline OP
Ameglian cow
OP Offline
Ameglian cow
J
Joined: Jan 2015
Posts: 40
I am trying to add cooldowns to user Spikenet's !addcom commands found here.

Code:
ON *:TEXT:*:#: {
  tokenize 32 $strip($1-,burci)
  if ($read(# $+ commands.txt, nts, $1)) {
    var %com = $v1
    var %com = $replace(%com,@user@,$iif($2,$2,?),@nick@,$nick,@target@,$target)
    if (-ul=mod == $gettok(%com,1,32)) && ($nick !isop $chan) { msg $chan  | return }
    msg $chan $iif(-ul=mod == $gettok(%com,1,32),$gettok(%com,2-,32),$gettok(%com,1-,32))
  }
}


I tried adding something like this:
Code:
      if ((%(%com)) || ($($+(%,flood(%com).,$nick),2))) { return }
      set -u3 %flood(%com) On
      set -u3 %flood(%com). $+ $nick On


and

Code:
      set %lastcom $1
      if (((%lastcom, $+ flood)) || ($($+((%,lastcom $+ flood),.,$nick),2))) { return }
      set -u3 (%lastcom, $+ flood) On
      set -u3 (%lastcom, $+ flood). $+ $nick On  

But the cooldown variables it creates look like this:
%flood(%com) On
%flood(%com).jimieo On
Or the command doesn't function.

Instead of using the actual command

ex: if I use !test I want the cooldown to be %floodtest

Could someone point me in the right direction to do this? I would greatly appreciate it.

Joined: Feb 2003
Posts: 2,812
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2003
Posts: 2,812
if ($($+(%,flood.,$cid),2) > 10) { return }
if ($($+(%,flood.,$cid,.,$nick),2) > 4) { return }
inc -z $+(%,flood.,$cid) 2
inc -z $+(%,flood.,$cid,.,$nick) 2


---

Each time the event gets triggered, a global and per-nick variable is incremented by 2 and decays in value 1 per second. In the above example: 2-4-6-8-10-12 ... a flood 3 commands by a single user or 6 by all users will block additional commands, with 1 command being released every 2 seconds as people calm down.

You can modify these values as you see fit. I often use > 120 with an inc of 60. That would mean 3 commands every 3 minutes on average. (3 right away, wait 1 minute before another is allowed.)


Well. At least I won lunch.
Good philosophy, see good in bad, I like!
Joined: Sep 2014
Posts: 52
Babel fish
Offline
Babel fish
Joined: Sep 2014
Posts: 52
Code:
if ((%flood [ $+ [ $1 ] ]) || ($($+(%,flood,$1,.,$nick),2))) { return }
set -u3 %flood [ $+ [ $1 ] ] On
set -u3 %flood [ $+ [ $1 ] $+ [ . ] $+ [ $nick ] ] On

Joined: Jan 2015
Posts: 40
J
jimieo Offline OP
Ameglian cow
OP Offline
Ameglian cow
J
Joined: Jan 2015
Posts: 40
Thanks to both of you for the help. I really appreciate it.


Link Copied to Clipboard