mIRC Home    About    Download    Register    News    Help

Print Thread
#172921 18/03/07 02:17 AM
Joined: Apr 2006
Posts: 464
O
Fjord artisan
OP Offline
Fjord artisan
O
Joined: Apr 2006
Posts: 464
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!

Joined: Jan 2007
Posts: 1,156
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Jan 2007
Posts: 1,156
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)

Joined: Oct 2005
Posts: 1,741
G
Hoopy frood
Offline
Hoopy frood
G
Joined: Oct 2005
Posts: 1,741
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

Joined: Apr 2006
Posts: 464
O
Fjord artisan
OP Offline
Fjord artisan
O
Joined: Apr 2006
Posts: 464
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!

Joined: Apr 2006
Posts: 464
O
Fjord artisan
OP Offline
Fjord artisan
O
Joined: Apr 2006
Posts: 464
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.

Joined: Jan 2003
Posts: 2,523
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
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.


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com

Link Copied to Clipboard