mIRC Home    About    Download    Register    News    Help

Print Thread
#2513 19/12/02 03:40 AM
Joined: Dec 2002
Posts: 332
C
Cheech Offline OP
Fjord artisan
OP Offline
Fjord artisan
C
Joined: Dec 2002
Posts: 332
hey i was browseing thru the other day and i say the snippet on the countdown timer i dont remember who answerd it but i tossed one in for kicks .. lol
alias xmas {
/set %xmas $duration($calc($ctime(25/12/02) - $ctime))
/amsg 00,04 %xmas Until Christmas
.timerxmas 1 3600 xmas
my question is ? is it possible to display Merry Christmas when the timer counts to zero ? or close to it anyhow ?
sort of like
if ( %xmas <= 0 ) { /amsg Merry christmas } ?

#2514 19/12/02 03:48 AM
Joined: Dec 2002
Posts: 144
D
Vogon poet
Offline
Vogon poet
D
Joined: Dec 2002
Posts: 144
Have an On CONNECT, On START or such check what date it is and if it's close to Christmas, start a timer to automatically say Merry Christmas at midnight.

Dana


"Any sufficiently advanced technology is indistinguishable from magic." - Arthur C. Clarke
#2515 19/12/02 04:02 AM
Joined: Dec 2002
Posts: 1,321
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Dec 2002
Posts: 1,321
This code would go into your remotes (Alt-R); to prevent it from conflicting with other scripts, place it in its own file by using File -> New.
Code:

on *:CONNECT: .timerChristmasCountdown 0 3600 ChristmasCountdown
alias ChristmasCountdown {
  if ($calc($ctime(25 Dec 02) - $ctime) &lt; 3601) .timerChristmasCountdown 0:00 1 1 amsg Merry Christmas, everyone!
  amsg $duration($calc($ctime(25 Dec 02) - $ctime)) until Christmas!
}



DALnet: #HelpDesk and #m[color:#FF0000]IR[color:#EEEE00]C
#2516 19/12/02 04:42 AM
Joined: Dec 2002
Posts: 332
C
Cheech Offline OP
Fjord artisan
OP Offline
Fjord artisan
C
Joined: Dec 2002
Posts: 332
ok makes sense but would this work ?
alias xmas {
/set %xmas $duration($calc($ctime(25/12/02) - $ctime))
if ( %xmas < 3600 ) { /timerxmas off | /timer 1 %xmas /amsg Merry Chistmas }
else /amsg 00,04 %xmas Until Christmas
.timerxmas 1 3600 xmas
}
i was working on it and thats what i came up with ?
also i resolve the connection issue with /xmas on connect

hmm i was just looking your over ? is there a reason for the < 3601 ? rather than 3600 ?

Last edited by Cheech; 19/12/02 04:43 AM.
#2517 19/12/02 02:03 PM
Joined: Dec 2002
Posts: 1,321
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Dec 2002
Posts: 1,321
I've looked over your code and I'm pretty sure you have it scripted correctly this time. I have a couple of scripting hints, though.

Code:

alias xmas {
  ;
  ;  You are using a / before each command. This is completely unnecessary inside a script. mIRC already knows it's
  ;  supposed to be looking for commands because it is already processing the script, so it's looking for commands.
  ;  The command prefix (which is / by default, but can be changed) is only required when you TYPE a command, not
  ;  inside a script that is filled with nothing but command lines.
  ;
  set %xmas $duration($calc($ctime(25/12/02) - $ctime))
  ;
  if (%xmas &lt; 3600) {
    ;
    ;  The /timer command is not silent; so, in a script that uses them, silence them by prefacing them with a period
    ;  (full stop), as you did below to set off the next 1 3600 xmas timer.
    ;
    .timerxmas off
    .timer 1 %xmas amsg Merry Chistmas
  }
  ;
  ;  You will need to group the following two commands inside an else { } block because you don't want to fire the timer
  ;  again after Christmas has arrived. Otherwise, you'll be telling people once every hour for the next year how close
  ;  they are to NEXT Christmas (before this one has even ended).
  ;
  else {
    amsg 00,04 %xmas Until Christmas 
    .timerxmas 1 3600 xmas
  }
}

Quote:
hmm i was just looking your over ? is there a reason for the < 3601 ? rather than 3600 ?


My previous example used a timer set to fire at a specific time. I didn't want the time to get closer to midnight than 1 second or else I risk the chance that the midnight timer might get set 1 second after the actual midnight I am targetting causing my Merry Christmas timer to actually fire 24 hours minus one second later (this is a special case scenario: the next to the last timer firing at exactly 3600 seconds before midnight). So, I gave it a 1-second buffer. Yours does not work this way since you are using a variable that will eventually be used as the timer duration. mIRC will accept a negative duration for a timer, so there is no problem if yours fires after actual midnight. It can only be as accurate as your system clock; your /amsg might very well arrive at everyone else's clients after that first second of Christmas Day anyway, due to the lag between you, your server, any connecting hubs, their servers and then on to their clients, so exact timing is not that important. Nice, but not essential, nor really possible.

If it were me scripting yours, I would use that same 1-second buffer for basically the same reason. smile


DALnet: #HelpDesk and #m[color:#FF0000]IR[color:#EEEE00]C
#2518 10/01/03 12:46 AM
Joined: Jan 2003
Posts: 44
L
Ameglian cow
Offline
Ameglian cow
L
Joined: Jan 2003
Posts: 44
while looking for information on writing my own tminus script I found this nice thread.

However, it doesn't work as written so please find the workable version below...

Code:
 
alias xmas {  
  ; $duration doesn't create a value that timer will
  ; like, but timer does like seconds.
  [color:red]set %seconds $calc($ctime(25/12/02) - $ctime)[/color]
  set %xmas $duration([color:red]%seconds[/color]) 
 
  ; this comparison failed religiously until it was finally
  ; told to compare against the seconds
  if (  [color:red]%seconds[/color]  &lt; 3600 )  {
    .timerxmas off
    .timer 1 [color:red]0[/color] %xmas amsg Merry Chistmas
  }
  else {
    amsg 00,04 %xmas Until Christmas
    .timerxmas 1 3600 xmas  
 }
}


hopefully people looking at this won't go bald anymore.


Link Copied to Clipboard