mIRC Home    About    Download    Register    News    Help

Print Thread
time #139390 13/01/06 09:21 PM
Joined: Feb 2003
Posts: 3,432
S
sparta Offline OP
Hoopy frood
OP Offline
Hoopy frood
S
Joined: Feb 2003
Posts: 3,432
Someone here that have a easy way to do a command at every houer? like when the klock strikes 22, then /command .. when the clock strikes 23 /command ? i couldent find anything bout this in the search.. "it can also be 12 and 11" 12h formate or 24h


if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }
Re: time #139391 13/01/06 09:24 PM
Joined: Mar 2005
Posts: 212
N
NeUtRoN_StaR Offline
Fjord artisan
Offline
Fjord artisan
N
Joined: Mar 2005
Posts: 212
im assuming you want something specific for each hour
in which case i would have a timer call an alias that checks the time the timer should fire pretty frequently

Re: time #139392 13/01/06 09:28 PM
Joined: Feb 2003
Posts: 3,432
S
sparta Offline OP
Hoopy frood
OP Offline
Hoopy frood
S
Joined: Feb 2003
Posts: 3,432
I understand that, my prob is that i dont know how to make see if the time is XX.00.. if i use: if ($time == XX:xx), then i had to add one for every hour. would be many if's. so i wonder if it's an easyer way to solve it..


if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }
Re: time #139393 13/01/06 09:35 PM
Joined: Mar 2005
Posts: 212
N
NeUtRoN_StaR Offline
Fjord artisan
Offline
Fjord artisan
N
Joined: Mar 2005
Posts: 212
well thats what i was gonna tell you to do
are you having it do the same thing every hour

because then you can just do a check for the 00

im betting therell be at least one occasion where it goes off more than once in an hour
you can do $right($left($time,5),2)
to isolate the two digits in question

Last edited by NeUtRoN_StaR; 13/01/06 09:36 PM.
Re: time #139394 13/01/06 09:41 PM
Joined: Feb 2003
Posts: 3,432
S
sparta Offline OP
Hoopy frood
OP Offline
Hoopy frood
S
Joined: Feb 2003
Posts: 3,432
For now it will only echo the time to you.. The time is now: xx:xx pm/am .. just as a test it working ok, later on i will add other functions to it.. smile so if it only show the time i guess i can figure out the rest smile


if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }
Re: time #139395 13/01/06 09:45 PM
Joined: Dec 2002
Posts: 3,138
C
Collective Offline
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 3,138
Another way to do it would be to use the [time] parameter of /timer.

E.g.
//timer $+($time($calc($ctime + 3600),HH),:,00) 1 0 echo -a This will be echo'd on the next hour
//timer $+($time($calc($ctime + 3600),HH),:,00) 0 3600 echo -a This will be echo'd on every hour after the next.

Re: time #139396 13/01/06 10:02 PM
Joined: Oct 2004
Posts: 72
C
captain_comic Offline
Babel fish
Offline
Babel fish
C
Joined: Oct 2004
Posts: 72
You could use this code:

Code:
  
on *:join:#: {
  if ($nick == $me) {
    var %systime = $ctime
    .timercalltime $+ $chan 1 $calc(3600 - %systime + $floor($calc(%systime / 3600)) * 3600 + 5) calltime $chan
  }
}

on *:part:#: {
  if ($nick == $me) {
    .timercalltime $+ $chan off
  }
}

on *:quit: {
  if ($nick == $me) {
    .timercalltime* off
  }
}

on *:disconnect: {
  .timercalltime* off
}

alias calltime {
  var %systime = $ctime
  var %syshour = $left($time(%systime), 2)
  msg $1 It is $iif(%syshour == 0, midnight, $iif(%syshour >= 13, $calc(%syshour - 12), $iif(%syshour >= 10, %syshour, $right(%syshour, 1))) o'clock)
  .timercalltime $+ $1 1 $calc(3600 - %systime + $floor($calc(%systime / 3600)) * 3600 + 5) calltime $1
}


On join of a channel it starts a timer for that channel that will call the alias "calltime" 5 seconds after the next hour. In "calltime" the same timer is started again to call the same alias after exactly 3600 secs. I count for 5 seconds extra to prevent the timer to be called twice just before the hour due to some variance in calculating the delay time. You can test that by skipping the +5. The on part, on quit and on disconnect events will stop running timers.

Re: time #139397 13/01/06 10:03 PM
Joined: Feb 2003
Posts: 3,432
S
sparta Offline OP
Hoopy frood
OP Offline
Hoopy frood
S
Joined: Feb 2003
Posts: 3,432
thnx.. i try it smile


if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }
Re: time #139398 13/01/06 11:45 PM
Joined: Sep 2005
Posts: 2,881
H
hixxy Offline
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
Just thought I'd mention that since : and 0 (zero) have no meaning inside of $time(), you don't need to use $+().

Code:
//timer $time($calc($ctime + 3600),HH:00) 0 3600 blah

Re: time #139399 14/01/06 01:00 AM
Joined: Feb 2003
Posts: 3,432
S
sparta Offline OP
Hoopy frood
OP Offline
Hoopy frood
S
Joined: Feb 2003
Posts: 3,432
I coldent get anything from hixxy's or Collective's timers, didnt echo anything to me :tongue:

captain_comic's code worked, but it echo the time over and over again, i need something that echo only when the time strikes 21 or 22 .. i tryed to manipulate my system clock "turn it back 1 minute", but still nothing when it striked 2.. :tongue: dont know if i did something wrong, but i dont think i did..

EDIT ------------------------

this is what i use now..

.timer 00:00 1 1 echo -a The time is now: $time
.timer 01:00 1 1 echo -a The time is now: $time

the problem is that it have been triggered it stops, 0 is running for ever, but i dont know if thats a good idea to use it that way, it end up in allot of timers running.. :tongue:

Last edited by sparta; 14/01/06 01:07 AM.
Re: time #139400 14/01/06 01:26 AM
Joined: Aug 2004
Posts: 7,252
R
RusselB Offline
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
I knew this sounded familiar, just took me a while to figure out why. Here's a code that I wrote for someone else. Please note that this does have a variance of up to 30 seconds.
Code:
 alias time.check {
  if !$mid($time,4,2) { echo -a The time is $time }
}
on *:start:{
  $+(.timer,time) 0 30 time.check
}
 

Re: time #139401 14/01/06 03:23 AM
Joined: Sep 2003
Posts: 4,230
D
DaveC Offline
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
Quote:
.timercalltime $+ $chan 1 $calc(3600 - %systime + $floor($calc(%systime / 3600)) * 3600 + 5) calltime $chan


check out the % function on $calc

.timercalltime $+ $chan 1 $calc(3600 - (%systime % 3600) + 5) calltime $chan

x % y = remaineder of x / y

alot simplier to write smile

Re: time #139402 14/01/06 09:19 AM
Joined: Oct 2004
Posts: 72
C
captain_comic Offline
Babel fish
Offline
Babel fish
C
Joined: Oct 2004
Posts: 72
Thank you very much Davec! I looked for ´$mod´ in help and couldn't find it.
@Sparta: strange it doesn't work for you. I tested the code by manipulating the system clock and waiting for the first message to appear. After that I did /timers and checked whether the next call would come exactly 3600 secs later. Are you sure you copied everything right?