mIRC Home    About    Download    Register    News    Help

Print Thread
Page 1 of 2 1 2
Setting up a timer #160651 29/09/06 04:15 AM
Joined: Sep 2006
Posts: 14
K
kantremem Offline OP
Pikka bird
OP Offline
Pikka bird
K
Joined: Sep 2006
Posts: 14
So far I have :

on *:CONNECT: { .timerstart 19:34:00 1 1 .timermsg 0 10 msg #channel hello | .timerend 4:00:00 1 1 .timermsg off }

What I want to do is say hello between the hours of 7:34pm to 4:00am everyday even if I get disconnected and reconnected to the IRC server. For example, if at 8:35pm my internet connection dies, and mirc reconnects to the server and rejoins the channel, I still want "hello" to be said as if I wasn't disconnected - never missing a heartbeat. So I want to say "hello" strickly between the hours of 7:34pm to 4:00am even if my connection dies and reconnects - I still want "hello" to be said in circumstances like that.

So what commands do I add?

Re: Setting up a timer #160652 29/09/06 05:00 AM
Joined: Aug 2004
Posts: 7,252
R
RusselB Offline
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
First off, I wouldn't have this as an on connect event, since there's no guarantee that you're going to be in a channel for the message to be sent to via the timer. I changed it to an on join event, and did a bit of re-writing, coming up with
Code:
 on me:*:join:#:{
  if !$timer(end) {
    .timerend 4:00 1 1 timermsg off
  }
  if ($asctime(HH:nn) < 19:34) && ($v1 > 04:00) && !$timer(start)   {
    .timerstart 19:34 1 1 msg $chan
  }
  else {
    msg $chan
  }
}
alias msg {
  .timermsg 0 10 msg $1 hello
}
on *:disconnect:{
  .timermsg off
  .timerstart off
  .timerend off
}
 

Please note that you can't have a script that literally "never missing a heartbeat", since the script won't work if you're disconnected.
However, aside from the condition that you must be connected, I think the above script will work per your request.

Re: Setting up a timer #160653 29/09/06 05:56 AM
Joined: Aug 2005
Posts: 1,052
L
Lpfix5 Offline
Hoopy frood
Offline
Hoopy frood
L
Joined: Aug 2005
Posts: 1,052
Quote:

Please note that you can't have a script that literally "never missing a heartbeat", since the script won't work if you're disconnected.
However, aside from the condition that you must be connected, I think the above script will work per your request.


You can actually never miss that heart beat :P

timer -o DATAHOUR DATAXTIMES DATAINTERVAL COMMAND

will create whats called a offline timer meaning that should it occur the user is disconnected or something the command will still work or the timer in question I should say


Code:
if $reality > $fiction { set %sanity Sane }
Else { echo -a *voices* }
Re: Setting up a timer #160654 29/09/06 06:33 AM
Joined: Aug 2004
Posts: 7,252
R
RusselB Offline
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
Yes, an offline timer would do that, but the command line (from my script, msg $1 hello), would generate an error when offline, since no channel could be passed to the alias via $1.

Re: Setting up a timer #160655 29/09/06 08:22 AM
Joined: Aug 2005
Posts: 1,052
L
Lpfix5 Offline
Hoopy frood
Offline
Hoopy frood
L
Joined: Aug 2005
Posts: 1,052
In theory thats correct however is not quite the hard problem to fix

A simple check to see if server is null meaning connection is not current.

if (!$server) { echo -a result }
else { perform old stuff from the script }


Code:
if $reality > $fiction { set %sanity Sane }
Else { echo -a *voices* }
Re: Setting up a timer #160656 29/09/06 09:06 AM
Joined: Mar 2003
Posts: 612
B
billythekid Offline
Fjord artisan
Offline
Fjord artisan
B
Joined: Mar 2003
Posts: 612
i'm not keen on using msg as an alias name since there is already a built in /msg command.


billythekid
Re: Setting up a timer #160657 29/09/06 07:33 PM
Joined: Sep 2006
Posts: 14
K
kantremem Offline OP
Pikka bird
OP Offline
Pikka bird
K
Joined: Sep 2006
Posts: 14
Will the code posted by RusselB repeat itself 24/7, 365/year?(as long as I am connected to the irc server) And since msg is an alias already built into mirc, what code should I use to replace:

alias msg {
.timermsg 0 10 msg $1 hello
}

?

Last edited by kantremem; 29/09/06 07:36 PM.
Re: Setting up a timer #160658 29/09/06 07:45 PM
Joined: Aug 2005
Posts: 1,052
L
Lpfix5 Offline
Hoopy frood
Offline
Hoopy frood
L
Joined: Aug 2005
Posts: 1,052
Quote:
First off, I wouldn't have this as an on connect event, since there's no guarantee that you're going to be in a channel for the message to be sent to via the timer. I changed it to an on join event, and did a bit of re-writing, coming up with
Code:
 on me:*:join:#:{
  if !$timer(end) {
    .timerend 4:00 1 1 timermsg off
  }
  if ($asctime(HH:nn) < 19:34) && ($v1 > 04:00) && !$timer(start)   {
    .timerstart 19:34 1 1 [color:red]T[/color]msg $chan
  }
  else {
    [color:red]T[/color]msg $chan
  }
}
alias [color:red]Tmsg[/color] {
  .timermsg 0 10 msg $1 hello
}
on *:disconnect:{
  .timermsg off
  .timerstart off
  .timerend off
}
 

Please note that you can't have a script that literally "never missing a heartbeat", since the script won't work if you're disconnected.
However, aside from the condition that you must be connected, I think the above script will work per your request.


look above @ red code.


Code:
if $reality > $fiction { set %sanity Sane }
Else { echo -a *voices* }
Re: Setting up a timer #160659 29/09/06 09:23 PM
Joined: Sep 2006
Posts: 14
K
kantremem Offline OP
Pikka bird
OP Offline
Pikka bird
K
Joined: Sep 2006
Posts: 14
How do I repeat the above code so it does this everyday?

I tried:

alias repeat { on me:*:join:#:{
if !$timer(end) {
.timerend 4:00 1 1 timermsg off
}
if ($asctime(HH:nn) < 19:34) && ($v1 > 04:00) && !$timer(start) {
.timerstart 19:34 1 1 Tmsg $chan
}
else {
Tmsg $chan
}
}
alias Tmsg {
.timermsg 0 10 msg $1 hello
}
on *:disconnect:{
.timermsg off
.timerstart off
.timerend off
}
}

/timer1 0 500 /repeat

but that doesn't work.

Re: Setting up a timer #160660 29/09/06 09:51 PM
Joined: Sep 2006
Posts: 14
K
kantremem Offline OP
Pikka bird
OP Offline
Pikka bird
K
Joined: Sep 2006
Posts: 14
What does "$v1" mean in :

if ($asctime(HH:nn) < 19:34) && ($v1 > 04:00) && !$timer(start) {
.timerstart 19:34 1 1 Tmsg $chan

?

Re: Setting up a timer #160661 29/09/06 10:30 PM
Joined: Jun 2006
Posts: 508
D
deegee Offline
Fjord artisan
Offline
Fjord artisan
D
Joined: Jun 2006
Posts: 508
Directly from mirc.hlp
Quote:
$v1 & $v2

Returns the first and second parameters of an if-then-else comparison. So, in the case of this comparison:

if (text isin sometext) { ... }

$v1 will return "text" and $v2 will return "sometext".

"if ($asctime(HH:nn) < 19:34) && ($v1 > 04:00)"
19:34 would be $v2

Re: Setting up a timer #160662 29/09/06 10:39 PM
Joined: Aug 2004
Posts: 7,252
R
RusselB Offline
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
Under those conditions, yes my code would work 24/7 365 days/year (366 for leap years). You can use msg as the alias name, although it would be a good idea to use something else, since /msg is a built in command. If you use msg as the alias, you'll have to remember to use /!msg <nick/channel> <message> in order for the built in command to run, rather than the alias. I'm honestly not sure why I didn't catch that when I wrote the code.

Re: Setting up a timer #160663 29/09/06 10:49 PM
Joined: Sep 2006
Posts: 14
K
kantremem Offline OP
Pikka bird
OP Offline
Pikka bird
K
Joined: Sep 2006
Posts: 14
It's only 3:43pm and the script is already saying "hello." I want it to say hello inbetween the hours of 7:34pm to 4:00am.

Re: Setting up a timer #160664 29/09/06 11:44 PM
Joined: Aug 2004
Posts: 7,252
R
RusselB Offline
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
Sorry about that, I re-did the method of determining the correct start and end times. Here's the new
Code:
on me:*:join:#:{
  if !$timer(end) {
    .timerend 4:00 1 1 timermsg off
  }
  if ($calc($ctime - $ctime($date 00:00:00)) &lt; 70440) &amp;&amp; ($v1 &gt; 14400) &amp;&amp; !$timer(start)   {
    .timerstart 19:34 1 1 tmsg $chan
  }
  else {
    tmsg $chan
  }
}
alias tmsg {
  .timermsg 0 10 msg $1 hello
}
on *:disconnect:{
  .timermsg off
  .timerstart off
  .timerend off
} 

I also changed the alias name so that it won't be confused with the built-in /msg command.

Re: Setting up a timer #160665 30/09/06 12:04 AM
Joined: Sep 2006
Posts: 14
K
kantremem Offline OP
Pikka bird
OP Offline
Pikka bird
K
Joined: Sep 2006
Posts: 14
No problem, but even if I copy and pasted your new command in the remote window, it still says and repeats hello (the time now is 5:01pm) before 7:34pm.

Re: Setting up a timer #160666 30/09/06 03:12 AM
Joined: Aug 2004
Posts: 7,252
R
RusselB Offline
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
I doin't know what you're doing, but I just retested the code, after changing the time on my system to check the code without having to wait the full time (as my normal time at this hour would have it working based on your specified times), and it worked exactly as the script calls for.

Make sure you don't have an old version of the script still running.

Re: Setting up a timer #160667 30/09/06 03:46 AM
Joined: Sep 2006
Posts: 14
K
kantremem Offline OP
Pikka bird
OP Offline
Pikka bird
K
Joined: Sep 2006
Posts: 14
You were right. I was running some other mirc scripts and I guess it was conflicting with their timers. Thank you so much for this, I really do like it a lot! smile

Re: Setting up a timer #160668 02/10/06 05:04 AM
Joined: Sep 2006
Posts: 14
K
kantremem Offline OP
Pikka bird
OP Offline
Pikka bird
K
Joined: Sep 2006
Posts: 14
I'm having trouble making the code repeat everyday, month, year, leap year etc. What is the code to make RusselB's code repeat everyday, month, year, etc?

Re: Setting up a timer #160669 02/10/06 05:20 AM
Joined: Aug 2005
Posts: 1,052
L
Lpfix5 Offline
Hoopy frood
Offline
Hoopy frood
L
Joined: Aug 2005
Posts: 1,052
well theres many ways you can setup the timer for every week/month/year example

.timerYEAR 0 xnumberofsecondstillyear2007 commandhere

or have it condition as a if statement like for example

on *:JOIN:#:{
if ($date(yy) == 06) { run timer here }
}


Code:
if $reality > $fiction { set %sanity Sane }
Else { echo -a *voices* }
Re: Setting up a timer #160670 02/10/06 05:21 AM
Joined: Aug 2004
Posts: 7,252
R
RusselB Offline
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
OK, I think what you mean, is that once the timer stops at 4 am, it doesn't restart at 5:34 pm. If this is correct, then the following code will work as a replacement for my original.
Code:
 on me:*:join:#:{
  if !$timer(end) {
    .timerend 4:00 1 1 timermsg off
    .timerstart 19:34 1 1 tmsg $chan
  }
  if ($calc($ctime - $ctime($date 00:00:00)) &lt; 70440) &amp;&amp; ($v1 &gt; 14400) &amp;&amp; !$timer(start)   {
    .timerstart 19:34 1 1 tmsg $chan
  }
  else {
    tmsg $chan
  }
}
alias tmsg {
  .timermsg 0 10 msg $1 hello
}
on *:disconnect:{
  .timermsg off
  .timerstart off
  .timerend off
} 
 


I forgot to mention this earlier, but due to the way the timers work, the first hello message won't go until 10 seconds after the script actually starts and the last hello message will actually be displayed 10 seconds after the script ends. So the timerstart timer won't actually produce a message until 5:34:10 pm and the last message will go out at 4:00:10 am

Page 1 of 2 1 2