mIRC Home    About    Download    Register    News    Help

Print Thread
#243210 27/10/13 03:02 PM
Joined: Oct 2013
Posts: 10
S
Pikka bird
OP Offline
Pikka bird
S
Joined: Oct 2013
Posts: 10
I am trying to add flood control to my script. This is what I have tried
Code:
else {
    var %get $+(#,.,$1)
    var %name $1
    var %text $readini(cmds.ini,%get,text)
    if (!%text) {
      /msg # No such command available.
    }
    else {
      if (%flood%name) { return }
      set -u30 %flood%name On
      /msg # %text
    }
  }

and
Code:
else {
    var %get $+(#,.,$1)
    var %name $1
    var %text $readini(cmds.ini,%get,text)
    if (!%text) {
      /msg # No such command available.
    }
    else {
      if (%flood $+ %name) { return }
      set -u30 %flood $+ %name On
      /msg # %text
    }
  }


The first version always sets the flood to %flood%name and disables every command which is not what I would like.
The second version makes it so I can't use any of the commands.

How can I make it so it only adds a flood control to a single command?

Joined: Aug 2013
Posts: 15
P
Pikka bird
Offline
Pikka bird
P
Joined: Aug 2013
Posts: 15
if you want to make a floodcontroll seperate for each command you can do something like this
Code:
on @*:TEXT:!command1:#: {
  if ($nick isop $chan) {
    if (!%floodcommand1) {
      set -u15 %floodcommand1 0
      msg $chan Hello World.
    }
  }
}
on @*:TEXT:!command2:#: {
  if ($nick isop $chan) {
    if (!%floodcommand2) {
      set -u15 %floodcommand2 0
      msg $chan Hello World.
    }
  }
}


if you want it for different channels aswell you can do it like this:
Code:
on @*:TEXT:!command1:#: {
  if ($nick isop $chan) {
    if $($+(%,floodcommand1.,$chan),2)) { return }
      set -u15 %floodcommand1. $+ $chan On
      msg $chan Hello World.
    }
  }
on @*:TEXT:!command2:#: {
  if ($nick isop $chan) {
    if ($($+(%,floodcommand2.,$chan),2)) { return }
      set -u15 %floodcommand2. $+ $chan On
      msg $chan Hello World.
    }
  }


anyone can correct me if i am wrong, please.

Joined: Jan 2004
Posts: 1,358
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Jan 2004
Posts: 1,358
For dynamically named variables you need to use brackets (or $eval(), $()) to change the order of evaluation:

%flood [ $+ [ %name ] ]

This causes %name to be resolved before anything, then the $+ is resolved afterward so that by the time everything else is resolved it's actually gone through these steps:

%flood [ $+ [ %name ] ]
%flood [ $+ somename ]
%floodsomename
somevalue


Link Copied to Clipboard