mIRC Homepage
Posted By: Judgebot How to set delay between use of commands? - 09/11/12 07:08 PM
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?
Posted By: 5618 Re: How to set delay between use of commands? - 09/11/12 07:16 PM
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
}
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?
Posted By: 5618 Re: How to set delay between use of commands? - 09/11/12 08:24 PM
Define "doesn't work".
How are you testing it and what is (not) happening?
Also, did you remove other scripts responding to *command*?
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"
Posted By: 5618 Re: How to set delay between use of commands? - 09/11/12 08:35 PM
You know that you cannot trigger your own on TEXT events? Someone else need to trigger it for you.
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?
Moving it up in the script fixed it smile
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
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 
Posted By: maroon Re: How to set delay between use of commands? - 23/04/17 08:39 PM
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 }
}
© mIRC Discussion Forums