mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Dec 2008
Posts: 7
C
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
C
Joined: Dec 2008
Posts: 7
I want to adapt my mirc script to send messages on chanels at every
full hour, etc. if now is 15:00:00 send msg on chanels "It's now 3:00pm. I tried with timers as its shown in mirc help i.e

/timer9 14:30 1 1 /say It's now 2:30pm
but this option not work.

Pls help me,

regards

Joined: Feb 2007
Posts: 234
M
Fjord artisan
Offline
Fjord artisan
M
Joined: Feb 2007
Posts: 234
/timer9 0 3600 /msg #channel It's now $asctime(hh:nntt)

Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
This may be put better and more short - I hope you get the general idea none the less.
Code:
alias hourly {
  var %mins = 00
  var %cmd = if ( $!me ison #somechan ) msg #somechan it's now $!time

  ; get the next time in HH:nn format that will meet the desired "minutes of the hour"
  var %offset = $iif(($time(nn) >= %mins),$duration(1h),0)
  var %starttime =  $asctime($calc($ctime($date $time(HH: $+ %mins)) + %offset),HH:nn)

  ; start a timer that will execute the command once at that start time
  .timer.hourly.1 %starttime 1 0 %cmd

  ; start another timer to execute the command every hour after that start time
  .timer.hourly.0 %starttime 0 $duration(1h) %cmd
}
%mins = minutes of the hour to start at, e.g. "00" or "30"
%cmd = your command to execute. Identifiers, variables etc will be evaluated in the /timer command - You have to force their re-evaluation if they shall be evaluated at the time the timer executes; for example "$(%variable,0)" instead of "%variable", or "$!time" instead of "$time".
You may prefer calling an alias or custom identifier instead.

MTec007: the request was about full hours, and your code will message the time of the timer's start, not the current time smile

Last edited by Horstl; 06/02/09 10:34 AM.
Joined: Dec 2008
Posts: 7
C
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
C
Joined: Dec 2008
Posts: 7
Thank you very match Horstl, but this alias didnt work.

I only change #someone in #probni (my chanel).

If you tested this tell me suuggest.

Best regards,https://forums.mirc.com/images/icons/default/cool.gif


Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
Hum, it's working fine for me... :|
Do you see the running timers?
To get a list of all running timers: /timers
To get the 2 timers in question listed: /timer.hourly.*

Joined: Feb 2007
Posts: 234
M
Fjord artisan
Offline
Fjord artisan
M
Joined: Feb 2007
Posts: 234
Originally Posted By: Horstl
MTec007: the request was about full hours, and your code will message the time of the timer's start, not the current time smile



ah ok i misread then. i see i forgot to use the ! in my code.. i am 0 for 2 i guess. .. lol. whistle

Joined: Dec 2008
Posts: 7
C
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
C
Joined: Dec 2008
Posts: 7
Horstl

Thank you, but reply on /timers or /timer.hourly is "* No active timers". I tried all solutions.

If it very important for me, as if it not problem for you
pls send me by mail (in atachment zip) only basic mIRC(6.17-6.21) with this code witch correctly work.

mail: driblersanjica@yahoo.com
or: driblercic@hotmail.com

Thank you in advance,

Best regards laugh

Joined: Feb 2007
Posts: 234
M
Fjord artisan
Offline
Fjord artisan
M
Joined: Feb 2007
Posts: 234
you should consider using the latest mirc, 6.35 if you are not. also you might want to edit your posting, you will receive spam emails if you leave your email addresses on these forums.

Joined: Oct 2003
Posts: 3,918
A
Hoopy frood
Offline
Hoopy frood
A
Joined: Oct 2003
Posts: 3,918
I'm not sure why everybody made this so complicated. Type:

//timerHOURLY 14:00 0 3600 /say It's now $time

Where 14:00 is the next upcoming hour when you start the script.

typing /timerHOURLY off would turn it off

--(Stop reading here, the rest is needlessly complicated)--

Of course if you were lazy you could do something like:

//timer $calc(($asctime(HH) + 1) % 24) 0 3600 /say It's now time

and that would automatically trigger it for the upcoming hour when you type it


- argv[0] on EFnet #mIRC
- "Life is a pointer to an integer without a cast"
Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
I aliased it
- to start it easily - e.g. automate it on start or the like, without knowing the next :nn match
- to allow "every :15" (or whatever nn of the hour is desired) as well
- to execute the timer not only every hour after the desired :nn is matched for the first time, but at that time too (thus 2 timers)

Note that in your code, $time isn't re-evaluated, and "$calc(($asctime(HH) + 1) % 24)" misses the :nn. Your "% 24" is indeed a good idea that saves a ctime-asctime conversion:
Code:
var %offset = $iif($time(nn) < %mins),0,1), %starttime = $calc(($time(HH) + %offset) % 24) $+ : $+ %mins

_____
To the OP:
- do you have remotes enabled? ("/remote on")
- did you copy the code to a new remotes file and saved it? After that, started it with "/hourly"?

Last edited by Horstl; 07/02/09 09:28 AM.
Joined: Dec 2008
Posts: 7
C
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
C
Joined: Dec 2008
Posts: 7
Horstl

Thank you,
* Active timers:
* Timer .hourly.1 13:00 1 time(s) 1ms delay if ( $me ison #probni ) msg #probni it's now $time (PIK)
* Timer .hourly.0 13:00 3600s delay if ( $me ison #probni ) msg #probni it's now $time (PIK)

As I understand you think that is better way to replace

var %offset = $iif(($time(nn) >= %mins),$duration(1h),0)

with

var %offset = $iif($time(nn) < %mins),0,1), %starttime = $calc(($time(HH) + %offset) % 24) $+ : $+ %mins

or add this variable.

Thank you very mach

Best regards,
NB:

It need activation /hourly after every connection.

I add before alias

On *:CONNECT: {
/hourly
}

Last edited by cankolizac; 07/02/09 12:04 PM.
Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
Your on connect event is correct if you chat only on one network at a time.
The / in front of a the /hourly command is only required in editboxes, you don't need that / in scriptfiles. But it's OK to keep the / there smile


The line
Code:
var %offset = $iif($time(nn) < %mins),0,1), %starttime = $calc(($time(HH) + %offset) % 24) $+ : $+ %mins
does the same as these two lines:
Code:
var %offset = $iif(($time(nn) >= %mins),$duration(1h),0)
var %starttime =  $asctime($calc($ctime($date $time(HH: $+ %mins)) + %offset),HH:nn)
...The new line is only a shoter way to do it. You may keep the 2 original lines, or replace the two lines with the "new" one.


The current message will look like " it's now 14:30:00 ". If you want it to be like " It's now 2:30pm ", replace " msg #probni it's now $!time " with " msg #probni It's now $!asctime(hh:nntt) "

Joined: Jan 2007
Posts: 1,156
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Jan 2007
Posts: 1,156
Originally Posted By: cankolizac

/timer9 14:30 1 1 /say It's now 2:30pm
but this option not work.


This works, but only when your computer says it is 14:30.


Link Copied to Clipboard