this was requested on the forums so i thought id bring it here
Syntax:
~deathclock
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,/ <b>(.+)<\/b>/g)) { msg %dc.targ Your Personal Day of Death is... $remove($regml(1), ) | unset %dc.* }
}
@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.
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 ;/
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,/ <b>(.+)<\/b>/g)) { msg %dc.targ Your Personal Day of Death is... $remove($regml(1), ) | unset %dc.* }
}
anyways nice work