Countdown Script. Great for Holidays.

By vegeto079 on Dec 01, 2007

A nice Count Down script I made from scratch.


CLIENT VERSION

It does what it's meant to do. You type in:
!countdown [month] [day] [hour] [name of occasion]
EX: !countdown 6 5 0 My Birthday!
(0 in hour means midnight)
(from a CLIENT, not mIRC itself!)
thus month, day, and hour being a NUMBER, and not the actual days/months.
it will create a 'CountDown' for you. If you type "!countdown check", it will show you how many years(if needed), months, days, hours, minutes, and seconds until the Count Down date is through.

This can be great for birthdays, holidays, or any special occasion.

Commands:
!countdown - Show how to make a new countdown - in notice
!countdown check - Check how long until your countdown ends - in notice
@countdown - Show how to make a new countdown - in channel
@countdown check - Check how long until your countdown ends - in channel

This script supports color, and is originally colored with A light red(04) and Dark red(05). You may change these as you please, but they are in the actual code, so you will have to look for it and change it manually. I may add a code to change it by an alias later.
You can also color your [name of occasion], and it will copy the colors into the Check message.

This script is not found person-by-person by $Address, but Your IRC nickname instead. This prevents $address changing problems, and easier editing of variables.

Note: To Count Down to a time past 12 months, instead of trying to put a 1 year in there somewhere, simply put how many months it is until it happens.
For Example...
!countdown 25 25 12 Randomness.
Would display the countdown for 25 months in advance, on the 25th day, at noon (12 hours into the day).

-To be edited if flaws are found-


ALIAS VERSION

Basically self-explanatory.
Commands:
/Countdown
/countdown2
First, type /countdown, and simply follow the instructions. It will do the work for you.
After finishing the boxes for /countdown, you can (at any time), type /countdown2, and type in the name of your variable (named in /countdown).
Doing such will display in an "/echo -a"(active window echo) how long until the date surpasses.

Note: The alias version and client version do not interact. You cannot create a countdown in the Alias version, then try to retrieve it in the Client version.

For example:
/countdown
june
5
0
birthday
/countdown2
birthday

-This creates a countdown for my birthdate, and labels it birthday, and you will need to type that in order for you to get the information.
-You can have more than one countdown (as long as they are different names) in the Alias version, whereas in the Client version, one name can only hold one countdown
-You may simply overlap an old alias countdown by making a new one over it and asking to use the same exact name

-To be edited if flaws are found-


----Updates-----

"
Date - Script that it applies to
Update
"

12/01/07 - Both Scripts
Created script.

12/01/07 - Client Script
Made it so you can't get overloaded and lagged for a long time due to loops if somebody tried to overload the script with a large number. Now, only numbers under 150 are allowed.

12/01/07 - Both Scripts
Made a few changes, fixed a few errors, and shortened alias blah (thanks Olliegod)

12/16/07 - Both Scripts
Changed a few things. Not worth noting :P

1/16/08 - Client Script
Changed a few things and made it so that an extra message is sent if you simply type !countdown or @countdown, so you don't think your countdown got deleted.

5/1/08 - Both Scripts
You now can type "!countdown check [name]" and replace [name] with somebodies name to see their countdown.

5/09/08 - Both Scripts
Now, instead of showing -1 months if your event has passed, it will show when the next time it will happen appropriately.

;Script no1. Client version
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;Script By Vegeto079/Peach/Peachbot;;;;;;;;;;;;;
;;;;;;Sorry about many variables, but it's the way i script!;;;;;;
;;;To Contact me about the script, email veget00tegev@yahoo.com;;;
;;;;;;;;;;;;Or talk to me in #peach on irc.swifitrc.net;;;;;;;;;;;
;;;;;Please do not edit this in any way without my permission;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
on *:text:!countdown*:#:{
  if ($2 == $null) {
    notice $nick Please type this all in numerals:
    notice $nick !countdown Month Day Hour Name Of Occasion
    notice $nick Or type '@countdown check' if you have made one.
    halt
  }
  if ($2 == check) {
    set %look $3
    if (!$3) { set %look $nick }
    if (%countdown [ $+ [ %look ] ] == $null) {
      notice $nick No CountDown found for " $+ $3 $+ "
      halt
    }
  }
  if ($2 isnum) {
    if ($2 > 150) || ($3 > 150) || ($4 > 150) {
      notice $nick Trying to overload my script? Nice try :)
      halt
    }
    set %countdown [ $+ [ $nick ] ] $2 $3 $4 0 0 $monthcountdown($2) $5-
    notice $nick CountDown Created! Type !countdown check how much time is left!
    halt
  }
  if (%countdown [ $+ [ %look ] ] == $null) {
    notice $nick Please type this all in numerals:
    notice $nick !countdown Month Day Hour Name Of Occasion
    halt
  }
  if ($2 == check) {
    set %1 $calc($gettok(%countdown [ $+ [ %look ] ],1,32) - $gettok($date,2,47)))
    set %2 $calc($gettok(%countdown [ $+ [ %look ] ],2,32) - 1 - $gettok($date,1,47)))
    set %3 $calc(23+ $gettok(%countdown [ $+ [ %look ] ],3,32) - $gettok($asctime(HH:nn:ss),1,58)))
    set %4 $calc(59+ $gettok(%countdown [ $+ [ %look ] ],4,32) - $gettok($asctime(HH:nn:ss),2,58)))
    set %5 $calc(60+ $gettok(%countdown [ $+ [ %look ] ],5,32) - $gettok($asctime(HH:nn:ss),3,58)))
    blah
    :again
    if (%5 < 60) && (%4 < 60) && (%3 < 24) && (%2 < $gettok(%countdown [ $+ [ %look ] ],6,32)) && (%1 < 12) {
      goto end
    }
    if (%5 > 59) {
      dec %5 60
      inc %4
      goto again
    }
    if (%4 > 59) {
      dec %4 60
      inc %3
      goto again
    }
    if (%3 > 23) {
      dec %3 24
      inc %2
      goto again
    }
    if (%2 > $calc($gettok(%countdown [ $+ [ %look ] ],6,32)-1)) {
      dec %2 $gettok(%countdown [ $+ [ %look ] ],6,32)
      inc %1
      goto again
    }
    if (%1 > 11) {
      dec %1 12
      inc %0
      goto again
    }
    if (%1 < 0) {
      set %0 1
      set %1 0
      goto again
    }
    :end
    if (%0 != $null) {
      notice $nick 04 $+ %0 05years, 04 $+ %1 05months, 04 $+ %2 05days, 04 $+ %3 05hours, 04 $+ %4 05minutes, and 04 $+ %5 05seconds until: $gettok(%countdown [ $+ [ %look ] ],7-,32)
      unset %0
      halt
    }
    notice $nick 04 $+ %1 05months, 04 $+ %2 05days, 04 $+ %3 05hours, 04 $+ %4 05minutes, and 04 $+ %5 05seconds until: $gettok(%countdown [ $+ [ %look ] ],7-,32)
  }
}
alias blah {
  if (%1 < 0) && (%1 > -12) {
    set %1 $calc(%1 + 13)
  }
  if (%2 < 0) && (%2 > -30) {
    set %2 $calc(%2 + 30)
    dec %1
  }
  if (%1 < 0) {
    set %i 0
  }
  set %1 $replace(%1,-1,11)
}
on *:text:@countdown*:#:{
  if ($2 == $null) {
    msg $chan Please type this all in numerals:
    msg $chan @countdown Month Day Hour Name Of Occasion
    msg $chan Or type '@countdown check' if you have made one.
    halt
  }
  if ($2 == check) {
    set %look $3
    if (!$3) { set %look $nick }
    if (%countdown [ $+ [ %look ] ] == $null) {
      notice $nick No CountDown found for " $+ $3 $+ "
      halt
    }
  }
  if ($2 isnum) {
    if ($2 > 150) || ($3 > 150) || ($4 > 150) {
      msg $chan Trying to overload my script? Nice try :)
      halt
    }
    set %countdown [ $+ [ $nick ] ] $2 $3 $4 0 0 $monthcountdown($2) $5-
    msg $chan CountDown Created! Type @countdown check how much time is left!
    halt
  }
  if (%countdown [ $+ [ $nick ] ] == $null) {
    msg $chan Please type this all in numerals:
    msg $chan @countdown Month Day Hour Name Of Occasion
    halt
  }
  if ($2 == check) {
    set %look $3
    if (!$3) { set %look $nick }
    if (%countdown [ $+ [ %look ] ] == $null) {
      msg $chan No CountDown found for " $+ $3 $+ "
      halt
    }
    set %1 $calc($gettok(%countdown [ $+ [ %look ] ],1,32) - $gettok($date,2,47)))
    set %2 $calc($gettok(%countdown [ $+ [ %look ] ],2,32) - 1 - $gettok($date,1,47)))
    set %3 $calc(23+ $gettok(%countdown [ $+ [ %look ] ],3,32) - $gettok($asctime(HH:nn:ss),1,58)))
    set %4 $calc(59+ $gettok(%countdown [ $+ [ %look ] ],4,32) - $gettok($asctime(HH:nn:ss),2,58)))
    set %5 $calc(60+ $gettok(%countdown [ $+ [ %look ] ],5,32) - $gettok($asctime(HH:nn:ss),3,58)))
    blah
    :again
    if (%5 < 60) && (%4 < 60) && (%3 < 24) && (%2 < $gettok(%countdown [ $+ [ %look ] ],6,32)) && (%1 < 12) {
      goto end
    }
    if (%5 > 59) {
      dec %5 60
      inc %4
      goto again
    }
    if (%4 > 59) {
      dec %4 60
      inc %3
      goto again
    }
    if (%3 > 23) {
      dec %3 24
      inc %2
      goto again
    }
    if (%2 > $calc($gettok(%countdown [ $+ [ %look ] ],6,32)-1)) {
      dec %2 $gettok(%countdown [ $+ [ %look ] ],6,32)
      inc %1
      goto again
    }
    if (%1 > 11) {
      dec %1 12
      inc %0
      goto again
    }
    :end
    if (%0 != $null) {
      msg $chan 04 $+ %0 05years, 04 $+ %1 05months, 04 $+ %2 05days, 04 $+ %3 05hours, 04 $+ %4 05minutes, and 04 $+ %5 05seconds until: $gettok(%countdown [ $+ [ %look ] ],7-,32)
      unset %0
      halt
    }
    msg $chan 04 $+ %1 05months, 04 $+ %2 05days, 04 $+ %3 05hours, 04 $+ %4 05minutes, and 04 $+ %5 05seconds until: $gettok(%countdown [ $+ [ %look ] ],7-,32)
  }
}
alias monthcountdown {
  if ($1 == 1) {
    set %x 31
  }
  if ($1 == 2) {
    set %x 28
  }
  if ($1 == 3) {
    set %x 31
  }
  if ($1 == 4) {
    set %x 30
  }
  if ($1 == 5) {
    set %x 31
  }
  if ($1 == 6) {
    set %x 30
  }
  if ($1 == 7) {
    set %x 31
  }
  if ($1 == 8) {
    set %x 31
  }
  if ($1 == 9) {
    set %x 30
  }
  if ($1 == 10) {
    set %x 30
  }
  if ($1 == 11) {
    set %x 31
  }
  if ($1 == 12) {
    set %x 30
  }
  return %x
}
;Script no2. Alias version
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;Script By Vegeto079/Peach/Peachbot;;;;;;;;;;;;;
;;;;;;Sorry about many variables, but it's the way i script!;;;;;;
;;;To Contact me about the script, email veget00tegev@yahoo.com;;;
;;;;;;;;;;;;Or talk to me in #peach on irc.swifitrc.net;;;;;;;;;;;
;;;;;Please do not edit this in any way without my permission;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
alias countdown {
  set %month $replace($?="What month is the Occasion?",January,1,jan,1,febuary,2,feb,2,march,3,mar,3,april,4,apr,4,may,5,june,6,july,7,August,8,Aug,8,September,9,Sep,9,October,10,Oct,10,november,11,nov,11,december,12,dec,12,0,1,$null,1)
  set %day $replace($?="What is the number of the day of the Occasion?",0,1,$null,1)
  set %hour $replace($?="What is the hour of the Occasion? Set this to 0 for Midnight.",$null,0)
  set %minute 0
  set %second 0
  set %set $?="What do you want the variable to be named? (do not include the percent)"
  set %monthinyear $monthcountdown(%month)
  set % [ $+ [ %set ] ] %month %day %hour %minute %second %monthinyear
  echo -a 04Please type 05/countdown204 to see how much time is left.
  halt
}
alias countdown2 {
  set %what $?="What is your variable named? (do not include the percent)"
  set %variable % [ $+ [ %what ] ]
  set %1 $calc($gettok(%variable,1,32) - $gettok($date,2,47)))
  set %2 $calc($gettok(%variable,2,32) - 1 - $gettok($date,1,47)))
  set %3 $calc(23+ $gettok(%variable,3,32) - $gettok($asctime(HH:nn:ss),1,58)))
  set %4 $calc(59+ $gettok(%variable,4,32) - $gettok($asctime(HH:nn:ss),2,58)))
  set %5 $calc(60+ $gettok(%variable,5,32) - $gettok($asctime(HH:nn:ss),3,58)))
  blah
  :again
  if (%5 < 60) && (%4 < 60) && (%3 < 24) && (%2 < $gettok(%variable,6,32)) && (%1 < 12) {
    goto end
  }
  if (%5 > 59) {
    dec %5 60
    inc %4
    goto again
  }
  if (%4 > 59) {
    dec %4 60
    inc %3
    goto again
  }
  if (%3 > 23) {
    dec %3 24
    inc %2
    goto again
  }
  if (%2 > $calc($gettok(%variable,6,32)-1)) {
    dec %2 $gettok(%variable,6,32)
    inc %1
    goto again
  }
  if (%1 > 11) {
    dec %1 12
    inc %0
    goto again
  }
  :end
  echo -a %1 months %2 days %3 hours %4 minutes %5 seconds
}

Comments

Sign in to comment.
Olliegod   -  Dec 01, 2007
alias blah {
  if (%1 == -11) {
    set %1 2
  }
  if (%1 == -10) {
    set %1 3
  }
  if (%1 == -9) {
    set %1 4
  }
  if (%1 == -8) {
    set %1 5
  }
  if (%1 == -7) {
    set %1 6
  }
  if (%1 == -6) {
    set %1 7
  }
  if (%1 == -5) {
    set %1 8
  }
  if (%1 == -4) {
    set %1 9
  }
  if (%1 == -3) {
    set %1 10
  }
  if (%1 == -2) {
    set %1 11
  }
  if (%1 == -1) {
    set %1 12
  }
}

This can be shortened to

alias blah if (%1 < 0 && %1 > -12) set %1 $calc(%1 + 13)

Also you should look into using while loops rather than goto\'s.
Altogether this isn\'t an amazing script but I suppose it\'s decent.

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.