mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Nov 2012
Posts: 18
J
Pikka bird
OP Offline
Pikka bird
J
Joined: Nov 2012
Posts: 18
How to set delay between use of commands?

to around a 6second delay ?

on *:text:*command*:#: {
msg $chan hello all
}

and then for it to say "this command is on cool down" when used within 6seconds?

Joined: Jun 2007
Posts: 933
5
Hoopy frood
Offline
Hoopy frood
5
Joined: Jun 2007
Posts: 933
I believe this is what you are asking for...
Code:
on *:TEXT:*command*:#:{
  if (!%comwait) {
    set -u6 %comwait 1
    msg $chan hello all
  }
  else msg $chan this command is on cool down
}

Joined: Nov 2012
Posts: 18
J
Pikka bird
OP Offline
Pikka bird
J
Joined: Nov 2012
Posts: 18
Originally Posted By: 5618
I believe this is what you are asking for...
Code:
on *:TEXT:*command*:#:{
  if (!%comwait) {
    set -u6 %comwait 1
    msg $chan hello all
  }
  else msg $chan this command is on cool down
}


This doesn't seem to work?

Joined: Jun 2007
Posts: 933
5
Hoopy frood
Offline
Hoopy frood
5
Joined: Jun 2007
Posts: 933
Define "doesn't work".
How are you testing it and what is (not) happening?
Also, did you remove other scripts responding to *command*?

Joined: Nov 2012
Posts: 18
J
Pikka bird
OP Offline
Pikka bird
J
Joined: Nov 2012
Posts: 18
Originally Posted By: 5618
Define "doesn't work".
How are you testing it and what is (not) happening?
Also, did you remove other scripts responding to *command*?


When i tested this in my twitch IRC chat using mIRC nothing happened when i did "!command"

Joined: Jun 2007
Posts: 933
5
Hoopy frood
Offline
Hoopy frood
5
Joined: Jun 2007
Posts: 933
You know that you cannot trigger your own on TEXT events? Someone else need to trigger it for you.

Joined: Nov 2012
Posts: 18
J
Pikka bird
OP Offline
Pikka bird
J
Joined: Nov 2012
Posts: 18
Originally Posted By: 5618
You know that you cannot trigger your own on TEXT events? Someone else need to trigger it for you.


All or most of my scripts are text triggered, but for some reason this:

Code:
on *:TEXT:*command*:#: {
  if (!%comwait) {
    set -u6 %comwait 1
    msg $chan testcommand
  }
  else {
    msg $chan this command is on cool down
  }
}


doesn't work, maybe i should try moving it up in my script file?

Joined: Nov 2012
Posts: 18
J
Pikka bird
OP Offline
Pikka bird
J
Joined: Nov 2012
Posts: 18
Moving it up in the script fixed it smile

Joined: Apr 2017
Posts: 1
K
Mostly harmless
Offline
Mostly harmless
K
Joined: Apr 2017
Posts: 1
If I wanted to use a global variable rather than a hard coded number how would I do this?

eg. set -u%cooldownTime %comwait 1

Joined: Jul 2016
Posts: 28
Z
Ameglian cow
Offline
Ameglian cow
Z
Joined: Jul 2016
Posts: 28
Code:
alias -l customcooldown {
  return -u $+ $1
}

This is what I used for the custom cooldown. It would be an identifier.
Code:
.set $customcooldown(%cooldownTime) %comwait 1 

Joined: Jan 2004
Posts: 2,127
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
for cooldowns, instead of

set -u6 %cooldown 1

I sometimes use

set -z %cooldown 6

That has the advantage of telling you how many seconds remain in the cooldown, making it easy to fire up a timer that will launch when the cooldown expires.

Just be aware that 6 doesn't always mean 6 seconds. If you set your cooldown variable with zero seconds past the minute, setting it with value of X seconds does not mean the variable disappears at X seconds past the minute.

Code:
alias cooldowntestZ {
  if ($1 == 1) { set -z %cooldown 10 | echo -s cooldowntestZ1 %cooldown $asctime | .timer 1 0 cooldowntestZ 2 }
  if ($1 == 2) { echo -s cooldowntestZ2a %cooldown $asctime | var %x 999999 | while (%x) { var %rand $rand(1,1000) | dec %x } | echo -s cooldowntestZ2b %cooldown $asctime | .timer 1 0 cooldowntestZ 3 }
  if ($1 == 3) { echo -s cooldowntestZ3 %cooldown $asctime }
}


if you run this alias with: /cooldowntestZ 1
you'll see that no matter how many seconds it takes during step#2, the cooldown variable either stays at 10 or notches down to 9.

This will happen regardless whether you're using -u or -z, as you can see from /cooldowntestU 1

Code:
alias cooldowntestU {
  if ($1 == 1) { set -u10 %cooldown 10 | echo -s cooldowntestU1 $var(%cooldown,1).secs $asctime | .timer 1 0 cooldowntestU 2 }
  if ($1 == 2) { echo -s cooldowntestU2a $var(%cooldown,1).secs $asctime | var %x 999999 | while (%x) { var %rand $rand(1,1000) | dec %x } | echo -s cooldowntest2b $var(%cooldown,1).secs $asctime | .timer 1 0 cooldowntestU 3 }
  if ($1 == 3) { echo -s cooldowntestU3 $var(%cooldown,1).secs $asctime }
}


Link Copied to Clipboard