mIRC Homepage
Posted By: OrionsBelt Timer trouble - 18/03/07 02:17 AM
Hi All,

I'm still having problems with a script that I've been using for quite some time now.

Code:
on *:START:{ .timerhour 0 1 timesetup }

alias timesetup { .hour }

alias hour {
  if (($remove($time,$mid($time,1,3)) == 00:00) || ($time(HH:nn:ss) == 00:00:00)) {
    COMMANDS
  }
}


It's a little bugged somehow.
Sometimes it doesn't recognise the hour, and thus nothing happens. Imagine you make a count down timer, that deducts every hour... Skipping an hour could be a serious problem...

Does anyone have better idea's on how to make it?
Bulletproof idea's, with maybe a check in it or summin?

I just want to perform some commands, every hour, when the time is xx:00:00

Thanks in advance!
Posted By: DJ_Sol Re: Timer trouble - 18/03/07 04:54 AM
Sorry if this isn't exactly what you asked for but ..

why do you have an alias whose sole purpose is to trigger another alias? Why not just have it trigger hour?

Also, you have a bracket mismatch.

if (($remove($time,$mid($time,1,3)) == 00:00)
-should be-
if ($remove($time,$mid($time,1,3)) == 00:00)
Posted By: genius_at_work Re: Timer trouble - 18/03/07 05:30 AM
The problem with that kind of time script is that if the timer is delayed for 1 second at just the 'wrong' time, the time for that hour will never be exactly HH:00:00 and the commands won't happen. The simplest way to make something happen at a specific time is to use the [time] option in the timer.

Try this code:
Code:
on *:START:hourtimer
alias hourtimer {
  var %nexthour = $+($calc(($asctime(HH) + 1) % 24),:00)
  timerhour -o %nexthour 1 1 hourtimer
  ;; Perform your commands below this line ;;

}

(untested)

-genius_at_work
Posted By: OrionsBelt Re: Timer trouble - 19/03/07 09:44 PM
Ok guys, thanks for both your reactions.
I'll try Genius's script.

Added in the commands section:
echo -a The time is now $time

Just as a simple test.
I'll let mIRC open for a couple of days, and see how stable this is.

Thanks in advance!
Posted By: OrionsBelt Re: Timer trouble - 22/03/07 06:25 PM
Ok, yeah it ran for a couple of days, and it seems to work a lot more solid than the old version.

Solved!

Thx again genius.
Posted By: qwerty Re: Timer trouble - 22/03/07 08:58 PM
The only potential problem is that if you close the first Status window (after you've opened other Status window(s)), the timer will stop. To avoid that, include the -i switch in the /timer command: this will make the timer "jump" to the active session whenever the old one loses focus or is ended.
© mIRC Discussion Forums