Deathclock

By PuNkTuReD on Mar 26, 2009

this was requested on the forums so i thought id bring it here

Syntax:
~deathclock

  • modes can be < normal | pessimistic | sadistic | optimistic >
  • sex can be < male | female >
  • smoker can be < yes | no >

Example:
~deathclock 25 7 1984 male optimistic 25 yes

edit:
added a bit more error checking

/*
DeathClock By PuNkTuReD

Syntax:
~deathclock <date> <month> <year> <sex> <mode> <body mass index> <smoker>
- modes can be < normal | pessimistic | sadistic | optimistic >
- sex can be < male | female >
- smoker can be < yes | no >

Example:
~deathclock 25 7 1984 male optimistic 25 yes

*/
on *:text:*:#: {
  if ($1 == ~deathclock) {
    set %dc.targ #
    if (!$2) { 
      msg %dc.targ Syntax: ~deathclock <date> <month> <year> <sex> <mode> <body mass index> <smoker>
      msg %dc.targ - modes can be < normal OR pessimistic OR sadistic OR optimistic >
      msg %dc.targ - sex can be < male OR female >
      msg %dc.targ - smoker can be < yes OR no >
    }
    else {
      ; date
      if ($2 isnum) { set %dc.date $2 }
      elseif ($2 !isnum) { msg # date has to be a number. | halt }
      ; month
      if ($3 isnum) { set %dc.month $3 }
      elseif ($3 !isnum) { msg # month has to be a number. | halt }
      ; year
      if ($4 isnum) { set %dc.year $4 }
      elseif ($4 !isnum) { msg # year has to be a number. | halt }
      ; sex
      if ($5 == male) || ($5 == female) { set %dc.sex $5 }
      elseif ($5 !== male) || ($5 !== female) { msg # sex has to be <male OR female> | halt }
      ; mode
      if ($6 == normal) || ($6 == pessimistic) || ($6 == sadistic) || ($6 == optimistic) { set %dc.mode $6 }
      elseif ($6 !== normal) || ($6 !== pessimistic) || ($6 !== sadistic) || ($6 !== optimistic) { msg # mode can be any of the following < normal OR pessimistic OR sadistic OR optimistic > | halt }
      ; body mass index
      if ($7 isnum) { set %dc.bmi $7 }
      elseif ($7 !isnum) { msg # body mass index has to be a number. | halt }
      ; smoker
      if ($8 == yes) || ($8 == no) { 
        if ($8 == yes) { set %dc.smoker 1 }
        if ($8 == no) { set %dc.smoker 0 }
      }
      elseif ($8 !== yes) && ($8 !== no) { msg # smoker has to be < yes OR no > | halt }
      sockopen deathclock www.deathclock.com 80
    }
  }
}
on *:sockopen:deathclock: {
  sockwrite -n $sockname GET $+($chr(47),dw.cfm,$chr(63),Day=,%dc.date,&Month=,%dc.month,&Year=,%dc.year,&Sex=,%dc.sex,&Mode=,%dc.mode,&bmi=,%dc.bmi,&Smoker=,%dc.smoker) HTTP/1.1
  sockwrite -n $sockname Host: deathclock.com 
  sockwrite -n $sockname $crlf 
}
on *:sockread:deathclock: {
  var %sockread | sockread %sockread
  if ($regex(%sockread,/&nbsp;<b>(.+)<\/b>/g)) { msg %dc.targ Your Personal Day of Death is... $remove($regml(1),&nbsp;) | unset %dc.* }
}

Comments

Sign in to comment.
PuNkTuReD   -  Mar 27, 2009

@Slickone ahh shoot cheers, fixed. and updated the output to Slickone's.

@Aucun yea i put in the description, it was a request but i thought it had a place here too.

@EveryoneElse cheers glad u like.

yea i might add some more checks on to check month etc
dont want people putting 13 for month for example.

 Respond  
uneek   -  Mar 26, 2009

Excellent work! Thanks so much..will be a lot of fun!

 Respond  
FordLawnmower   -  Mar 26, 2009

Ha! I was just getting ready to post the same script Only mine has different syntax.
DeathClock mm/dd/yyyy m|f s|n bmi. s|n, bmi optional. Then I just had !pessimistic
!sadistic !optimistic to refer to the last call. Here is my bmi alias anyway ;/

;Syntax $1 = weight in lbs $2 = height in inches
alias bmi {
  return $round($calc(($1 * 703) / ($2 * $2)),0)
}

At least I looked first this time ;/

 Respond  
Slickone   -  Mar 26, 2009

you should look over the code again.

if ($3 isnum) { set %dc.month $3 }
      elseif ($4 !isnum) { msg # month has to be a number. | halt }

on the elseif line you used $4 instead of $3

on the output you could make it like this

on *:sockread:deathclock: {
  var %sockread | sockread %sockread
  if ($regex(%sockread,/&nbsp;<b>(.+)<\/b>/g)) { msg %dc.targ Your Personal Day of Death is... $remove($regml(1),&nbsp;) | unset %dc.* }
}

anyways nice work

 Respond  
Aucun50   -  Mar 26, 2009

I saw someone wanting one of these on forums nice work as always

 Respond  
Fossa   -  Mar 26, 2009

Nice Job PunkTuReD ! Only the results are in difference (+- 13 years) when using the same info but thats not a scripting fault :) Well done man 7/10

 Respond  
a careful warchild   -  Mar 26, 2009

lol, good to have that cleared up.

Just spent 10 minutes looking over the script, looks good, haven't had a chance to test it yet, but for the layout, i'll give you a 4/10, when i've tested it, i'll update the rating accordingly :)

 Respond  
PuNkTuReD   -  Mar 26, 2009

"What if your an hermaphrodite like Jonesy? What would you put then?"
unfortunatley they cant use this snippet. :-(

"And the 'Smoking' part, does that cover bongs?"
yea, why not.

 Respond  
a careful warchild   -  Mar 26, 2009

What if your an hermaphrodite like Jonesy? What would you put then?

And the 'Smoking' part, does that cover bongs?

 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.