mIRC Home    About    Download    Register    News    Help

Print Thread
J
Judgebot
Judgebot
J
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?

5
5618
5618
5
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
}

J
Judgebot
Judgebot
J
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?

5
5618
5618
5
Define "doesn't work".
How are you testing it and what is (not) happening?
Also, did you remove other scripts responding to *command*?

J
Judgebot
Judgebot
J
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"

5
5618
5618
5
You know that you cannot trigger your own on TEXT events? Someone else need to trigger it for you.

J
Judgebot
Judgebot
J
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?

J
Judgebot
Judgebot
J
Moving it up in the script fixed it smile

K
kamikaze424
kamikaze424
K
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

Z
zapdos26
zapdos26
Z
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,081
M
Hoopy frood
Offline
Hoopy frood
M
Joined: Jan 2004
Posts: 2,081
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