mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Apr 2009
Posts: 2
S
skript Offline OP
Bowl of petunias
OP Offline
Bowl of petunias
S
Joined: Apr 2009
Posts: 2
Hi. I'm an absolute beginner.

I'm trying to make a countdown simple countdown script. When I type /countdown <number> it is supposed to countdown from that number to 0. And rest for let's say 1 second before saying the next number.

10
*1 second*
9
*1 second*
8
and so on...

My code so far:
Code:
/countdown {
  var %n = $1
  while (%n >= 0) {
    say %n
    dec %n
  }
}


Can you please teach me how can I add 1 second interval between saying the numbers?

Last edited by skript; 06/04/09 05:03 PM.
Joined: Jul 2007
Posts: 1,129
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,129
Code:
countdown {
  var %n = $1
  while (%n >= 0) {
    .timer 1 $calc($1 - %n) say %n
    dec %n
  }
}

Joined: Apr 2009
Posts: 2
S
skript Offline OP
Bowl of petunias
OP Offline
Bowl of petunias
S
Joined: Apr 2009
Posts: 2
Thanks it works

Joined: Oct 2005
Posts: 1,741
G
Hoopy frood
Offline
Hoopy frood
G
Joined: Oct 2005
Posts: 1,741
You shouldn't use /say in scripts.

Use /msg $chan instead.

-genius_at_work

Joined: Jul 2007
Posts: 1,129
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,129
Thanks, Genius_at_work. Can you explain why /say cannot be used? Apart from what I read in mirc help file that it shouldn't be used in a remote script, I don't see why not, especially for an alias script as above? I have seen people use on input event with say...nevertheless I will appreciate it if you could give me more insight into the use of it. Anyone else is welcome to give me more info on this.

Joined: Mar 2009
Posts: 74
K
Babel fish
Offline
Babel fish
K
Joined: Mar 2009
Posts: 74
In this particular script, I wouldn't use $chan or /say as that would change the channel the number appears on if you change channels, or move to a /query window. I'd probably set some variable to $active, and have it /msg %variable. But with most aliases /say works very well, as long as it immediately does what it's supposed to do instead of having a delay (as a timer will create). I have a few aliases that use /say instead of trying to determine if the active window is a channel or nick, then sending a message to that window. /say is just much neater and easier in such situations.


Link Copied to Clipboard