I made this script some time ago without releasing it, and have recently converted it from .ini's to hash tables along with my Word Counter script, these two scripts are my first real attempts at using hash tables so I thought some feedback would be nice.
Commands are:
!char - to show the number of recorded characters for that channel
!char - to show the number of times that specific character was recorded. Note: this is case-sensitive.
!char -c <$asc number value for a character e.g. 32 for a space> - this also shows how many times a specific character has been recorded.
Also, if anyone is interested, my Word Recorder script, which is quite similar to this script, cant be found at: http://www.hawkee.com/snippet/2736/
on *:TEXT:!char*:#: {
if (!$2) { .msg $chan Total number of characters used on $+ $chan $+ is: $+ $bytes($iif(!$hget($+(CharCount.,$chan),Total), 0, $hget($+(CharCount.,$chan),Total)),bd) $+ $+ . }
elseif ($2 == -c) && ($hget($+(CharCount.,$chan),$3)) { .msg $chan The character $+ $chr($3) $+ has been used $+ $bytes($hget($+(CharCount.,$chan),$3),bd) $+ $iif($hget($+(CharCount.,$chan),$3) == 1,time,times) on $+ $chan $+ $+ . }
elseif ($hget($+(CharCount.,$chan),$asc($left($2,1)))) { .msg $chan The character $+ $left($2,1) $+ has been used $+ $bytes($hget($+(CharCount.,$chan),$asc($left($2,1))),bd) $+ $iif($hget($+(CharCount.,$chan),$asc($left($2,1))) == 1,time,times) on $+ $chan $+ $+ . }
else .msg $chan The character $+ $left($2,1) $+ has not been recorded for $+ $chan $+ $+ .
}
on *:TEXT:*:#: {
var %x = 1
while (%x <= $len($1-)) {
hinc -m $+(CharCount.,$chan) $asc($mid($1-,%x,1))
inc %x
}
hinc -m $+(CharCount.,$chan) Total $len($1-)
}
on *:KICK:#: if ($hget($+(CharCount.,$chan))) && ($knick == $me) { hsave -o $+(CharCount.,$chan) $+(CharCount.,$chan,.dat) | hfree $+(CharCount.,$chan) }
on *:PART:#: if ($hget($+(CharCount.,$chan))) && ($nick == $me) { hsave -o $+(CharCount.,$chan) $+(CharCount.,$chan,.dat) | hfree $+(CharCount.,$chan) }
on *:START: {
var %x = 1
while (%x <= $chan(0)) {
if ( !$hget($+(CharCount.,$chan)) ) hmake $+(CharCount.,$chan) 10
if ( $isfile($+(CharCount.,$chan,.dat)) ) hload $+(CharCount.,$chan) $+(CharCount.,$chan,.dat)
inc %x
}
}
on *:JOIN:#:{
if ($nick == $me) {
if ( !$hget($+(CharCount.,$chan)) ) hmake $+(CharCount.,$chan) 10
if ( $isfile($+(CharCount.,$chan,.dat)) ) hload $+(CharCount.,$chan) $+(CharCount.,$chan,.dat)
}
}
on *:EXIT:{
var %x = 1
while (%x <= $chan(0)) {
if ( $hget($+(CharCount.,$chan(%x))) ) hsave -o $+(CharCount.,$chan(%x)) $+(CharCount.,$chan(%x),.dat)
inc %x
}
if ($hget(CharCount.Totals)) hsave -o CharCount.Totals CharCount.Totals.dat
}
on *:DISCONNECT:{
var %x = 1
while (%x <= $chan(0)) {
if ( $hget($+(CharCount.,$chan(%x))) ) hsave -o $+(CharCount.,$chan(%x)) $+(CharCount.,$chan(%x),.dat)
inc %x
}
if ($hget(CharCount.Totals)) hsave -o CharCount.Totals CharCount.Totals.dat
}