mIRC Home    About    Download    Register    News    Help

Print Thread
#144692 13/03/06 06:38 PM
Joined: Feb 2006
Posts: 164
V
vexed Offline OP
Vogon poet
OP Offline
Vogon poet
V
Joined: Feb 2006
Posts: 164
I used to use a timer for this on one of my old scripts, just wondered if there was a way to show the time like this in the active window, every hour.

--- the time is now: 6:00pm

thanks for any help.

Joined: Dec 2002
Posts: 1,245
M
Hoopy frood
Offline
Hoopy frood
M
Joined: Dec 2002
Posts: 1,245
I haven't tested this, but I think it should go
Code:
on *:start:{
timesetup
}
alias timesetup {
var %current = $asctime(hh)
var %current = $calc(%current + 1) $+ :00
.timertimenow $(%current,2) 1 0 onthehour
}
alias onthehour {
  .timerhour 0 3600 echo $!active The time is now: $!asctime(h:nn TT)
}


Edit: Added the $calc to the %current setup

Last edited by MikeChat; 13/03/06 08:54 PM.
Joined: Feb 2006
Posts: 164
V
vexed Offline OP
Vogon poet
OP Offline
Vogon poet
V
Joined: Feb 2006
Posts: 164
Well it just turned 9pm, and no echo appeared. lol

Joined: Dec 2002
Posts: 1,245
M
Hoopy frood
Offline
Hoopy frood
M
Joined: Dec 2002
Posts: 1,245
hmm I did a /timers and saw the hourly timer is running
what was missing then was a line to echo when the alias fires
Code:
on *:start:{
  timesetup
}
alias timesetup {
  var %current = $asctime(hh)
  var %current = $calc(%current + 1) $+ :00
  .timertimenow $(%current,2) 1 0 onthehour
}
alias onthehour {
  echo $active The time is now: $asctime(h:nn TT)
  .timerhour 0 3600 echo $!active The time is now: $!asctime(h:nn TT)
}

i think that should fix it
you migth reset the time to 15 after to see if its fixed

Joined: Feb 2006
Posts: 164
V
vexed Offline OP
Vogon poet
OP Offline
Vogon poet
V
Joined: Feb 2006
Posts: 164
i put the clock back to 20:59 and restarted the timer

* Timer timenow 09:00 1 time(s) 1ms delay onthehour (Chatshack)

and still no echo.

Joined: Dec 2002
Posts: 1,245
M
Hoopy frood
Offline
Hoopy frood
M
Joined: Dec 2002
Posts: 1,245
worked here, did you add the change in the onthehour alias?
Code:

alias onthehour {
[color:red]  echo $active The time is now: $asctime(h:nn TT) [/color]
  .timerhour 0 3600 echo $!active The time is now: $!asctime(h:nn TT)
}


Joined: Feb 2006
Posts: 164
V
vexed Offline OP
Vogon poet
OP Offline
Vogon poet
V
Joined: Feb 2006
Posts: 164
I have exactly what you have written, and i don't get an echo of any sort, if this for 6.17?

Joined: Dec 2002
Posts: 1,245
M
Hoopy frood
Offline
Hoopy frood
M
Joined: Dec 2002
Posts: 1,245
yes its for 6:17 and that is what i tested it in.

first, change the time setup to be This hour, a few minutes form now

for exampole here its 1:38

I'll set it to fire off at 1:40

alias timesetup {
var %current = $asctime(hh)
;var %current = $calc(%current + 1) $+ :00

var %current = 13:40

.timertimenow $(%current,2) 1 0 onthehour
}

then type /timesetup to reset the timer

Joined: Feb 2006
Posts: 164
V
vexed Offline OP
Vogon poet
OP Offline
Vogon poet
V
Joined: Feb 2006
Posts: 164
i'm using 6.16 see, but i don't see what's different in the code that could cause this not to work. crazy oh well. thanks anyway!

Joined: Mar 2003
Posts: 32
P
Pap Offline
Ameglian cow
Offline
Ameglian cow
P
Joined: Mar 2003
Posts: 32
Hi,

try using "HH" instead of "hh"

it's 3pm right now. hh gives me 03. HH gives me 15, but mirc's timers only go by 24-hour time.

Joined: Dec 2002
Posts: 1,245
M
Hoopy frood
Offline
Hoopy frood
M
Joined: Dec 2002
Posts: 1,245
the scripting is no different for this in 6.17

I have set someone else up with it to play a sound every quarter hour and it is working for them.

Joined: Dec 2002
Posts: 1,245
M
Hoopy frood
Offline
Hoopy frood
M
Joined: Dec 2002
Posts: 1,245
yes, changed to HH, however the timer was setting for the correct time, it does work in my mIRC, not sure why it won't for vexed.

I did make this change so it fires within the first 15 minutes of the startup event (and every 15 minutes)

Code:
on *:start:{
  timesetup
}
alias timesetup {
  var %currenttime = $asctime(nn)
  if (%currenttime <= 15) { %current = $asctime(HH:15) }
  elseif (%currenttime > 15) && (%currenttime <= 30) { %current = $asctime(HH:30) }
  elseif (%currenttime > 30) && (%currenttime <= 45) { %current = $asctime(HH:45) }
  else { var %current = $calc($asctime(HH) + 1) $+ :00 }
  .timertimenow %current 1 0 onthehour
}
alias onthehour {
  echo $active The time is now: $asctime(h:nn TT)
  .timerhour 0 900 echo $!active The time is now: $!asctime(h:nn TT)
}

Last edited by MikeChat; 13/03/06 10:50 PM.
Joined: Mar 2003
Posts: 32
P
Pap Offline
Ameglian cow
Offline
Ameglian cow
P
Joined: Mar 2003
Posts: 32
And if that doesn't fix it, try this code:

Code:
on *:start:{
  timesetup
}

alias timesetup {
  timer $asctime(HH) $+ :59 1 60 //echo -a Time: $eval($asctime,0) $chr(124) timesetup
}


Basically, timesetup sets itself into a timer that triggers ONCE one minute before the hour, waits 60 seconds, then as part of that trigger echos the time and calls itself again.

Last edited by Pap; 13/03/06 10:28 PM.
Joined: Mar 2003
Posts: 32
P
Pap Offline
Ameglian cow
Offline
Ameglian cow
P
Joined: Mar 2003
Posts: 32
//echo -s $asctime(hh)
==> 03
//echo -s $asctime(h)
==> 3

//echo -s $asctime(H)
==> 15
//echo -s $asctime(HH)
==> 15

and I think the single big H would return 24-hour time, but if the time is between 0100 and 0959, it would cut off the leading 0.

Last edited by Pap; 13/03/06 10:40 PM.
Joined: Feb 2006
Posts: 164
V
vexed Offline OP
Vogon poet
OP Offline
Vogon poet
V
Joined: Feb 2006
Posts: 164
Sorry i haven't replied, been asleep and stuff, i've just been playing about with all of this and still getting some problems, i tried yours paps and the timer goes out every time (Time: Tue Mar 14 14:00:36 2006)

36 seconds is a bit late lol

Joined: Feb 2006
Posts: 164
V
vexed Offline OP
Vogon poet
OP Offline
Vogon poet
V
Joined: Feb 2006
Posts: 164
I don't know why i had so many problems with yours
I managed to sort something out and it seems to work spot on for me now

Code:
 on *:START:{
  .timerhour 0 1 timesetup
}
alias hour {
  if ($remove($time,$mid($time,1,3)) == 00:00) { echo -a $bit the time is now: $timestamp } 
}

alias timesetup {
  .hour
} 


thanks for your time and effort though blush


Link Copied to Clipboard