mIRC Home    About    Download    Register    News    Help

Print Thread
How to set delay between use of commands? #239594 09/11/12 07:08 PM
Joined: Nov 2012
Posts: 18
J
Judgebot Offline OP
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?

Re: How to set delay between use of commands? [Re: Judgebot] #239595 09/11/12 07:16 PM
Joined: Jun 2007
Posts: 933
5
5618 Offline
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
}

Re: How to set delay between use of commands? [Re: 5618] #239596 09/11/12 07:52 PM
Joined: Nov 2012
Posts: 18
J
Judgebot Offline OP
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?

Re: How to set delay between use of commands? [Re: Judgebot] #239597 09/11/12 08:24 PM
Joined: Jun 2007
Posts: 933
5
5618 Offline
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*?

Re: How to set delay between use of commands? [Re: 5618] #239598 09/11/12 08:28 PM
Joined: Nov 2012
Posts: 18
J
Judgebot Offline OP
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"

Re: How to set delay between use of commands? [Re: Judgebot] #239599 09/11/12 08:35 PM
Joined: Jun 2007
Posts: 933
5
5618 Offline
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.

Re: How to set delay between use of commands? [Re: 5618] #239600 09/11/12 08:39 PM
Joined: Nov 2012
Posts: 18
J
Judgebot Offline OP
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?

Re: How to set delay between use of commands? [Re: Judgebot] #239601 09/11/12 08:41 PM
Joined: Nov 2012
Posts: 18
J
Judgebot Offline OP
Pikka bird
OP Offline
Pikka bird
J
Joined: Nov 2012
Posts: 18
Moving it up in the script fixed it smile

Re: How to set delay between use of commands? [Re: 5618] #260454 22/04/17 10:17 PM
Joined: Apr 2017
Posts: 1
K
kamikaze424 Offline
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

Re: How to set delay between use of commands? [Re: kamikaze424] #260462 23/04/17 04:45 PM
Joined: Jul 2016
Posts: 28
Z
zapdos26 Offline
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 

Re: How to set delay between use of commands? [Re: zapdos26] #260465 23/04/17 08:39 PM
Joined: Jan 2004
Posts: 1,551
maroon Offline
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 1,551
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 }
}