mIRC Homepage

time

Posted By: sparta

time - 13/01/06 09:21 PM

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
Posted By: NeUtRoN_StaR

Re: time - 13/01/06 09:24 PM

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
Posted By: sparta

Re: time - 13/01/06 09:28 PM

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..
Posted By: NeUtRoN_StaR

Re: time - 13/01/06 09:35 PM

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
Posted By: sparta

Re: time - 13/01/06 09:41 PM

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
Posted By: Collective

Re: time - 13/01/06 09:45 PM

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.
Posted By: captain_comic

Re: time - 13/01/06 10:02 PM

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.
Posted By: sparta

Re: time - 13/01/06 10:03 PM

thnx.. i try it smile
Posted By: hixxy

Re: time - 13/01/06 11:45 PM

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
Posted By: sparta

Re: time - 14/01/06 01:00 AM

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:
Posted By: RusselB

Re: time - 14/01/06 01:26 AM

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
}
 
Posted By: DaveC

Re: time - 14/01/06 03:23 AM

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
Posted By: captain_comic

Re: time - 14/01/06 09:19 AM

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?
© 2021 mIRC Discussion Forums