|
Joined: Feb 2003
Posts: 3,432
Hoopy frood
|
OP
Hoopy frood
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,.) }
|
|
|
|
Joined: Mar 2005
Posts: 212
Fjord artisan
|
Fjord artisan
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
|
|
|
|
Joined: Feb 2003
Posts: 3,432
Hoopy frood
|
OP
Hoopy frood
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,.) }
|
|
|
|
Joined: Mar 2005
Posts: 212
Fjord artisan
|
Fjord artisan
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.
|
|
|
|
Joined: Feb 2003
Posts: 3,432
Hoopy frood
|
OP
Hoopy frood
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.. so if it only show the time i guess i can figure out the rest
if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }
|
|
|
|
Joined: Dec 2002
Posts: 3,138
Hoopy frood
|
Hoopy frood
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.
|
|
|
|
Joined: Oct 2004
Posts: 72
Babel fish
|
Babel fish
Joined: Oct 2004
Posts: 72 |
You could use this 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.
|
|
|
|
Joined: Feb 2003
Posts: 3,432
Hoopy frood
|
OP
Hoopy frood
Joined: Feb 2003
Posts: 3,432 |
thnx.. i try it
if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }
|
|
|
|
Joined: Sep 2005
Posts: 2,881
Hoopy frood
|
Hoopy frood
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 $+(). //timer $time($calc($ctime + 3600),HH:00) 0 3600 blah
|
|
|
|
Joined: Feb 2003
Posts: 3,432
Hoopy frood
|
OP
Hoopy frood
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.
|
|
|
|
Joined: Aug 2004
Posts: 7,252
Hoopy frood
|
Hoopy frood
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. alias time.check {
if !$mid($time,4,2) { echo -a The time is $time }
}
on *:start:{
$+(.timer,time) 0 30 time.check
}
|
|
|
|
Joined: Sep 2003
Posts: 4,230
Hoopy frood
|
Hoopy frood
Joined: Sep 2003
Posts: 4,230 |
.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
|
|
|
|
Joined: Oct 2004
Posts: 72
Babel fish
|
Babel fish
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?
|
|
|
|
|