on *:Join:#:{
var %x = $calc($gettok($hget(Visits,$+($network,.,Count,.,$chan)),1,32) + 1)
var %y = $calc($gettok($hget(Visits,$+($network,.,$chan,.,$nick)),1,32) + 1)
if (!$hget(Visits,$+($network,.,$chan,.,$nick))) {
notice $nick Welcome to $+($chan,$chr(44)) $+($nick,.) You are the $ord(%x) person to join $+($chan,.)
hadd Visits $+($network,.,$chan,.,$nick) %y $asctime(mm/dd/yyyy) $ctime
hinc Visits $+($network,.,Count,.,$chan)
}
else {
notice $nick Welcome to $+($chan,$chr(44)) $+($nick,.) This is your $ord(%y) visit to $+($chan,.) Your last visit was on $+($gettok($hget(Visits,$+($network,.,$chan,.,$nick)),2,32),$chr(44)) $duration($calc($ctime - $gettok($hget(Visits,$+($network,.,$chan,.,$nick)),3,32))) ago.
hadd Visits $+($network,.,$chan,.,$nick) %y $asctime(mm/dd/yyyy) $ctime
}
}