Your script is very complicated for what your actually trying to achieve, by no means do you have to use this, but heres a more realistical coding.
This runs an alias and adds the voiced user to the database.
On *:VOICE:#:{
vtimechkfile
hadd voicetime $+($vnick,.vtime) $ctime
}
This runs an alias and checks if the users 'time of voice' is recorded it not, doesnt do anything, if it is, it calculates the difference in seconds, adds that difference to the total time and then echos in your screen the total they were voiced, changing 'echo -a' to 'msg $chan' will make it msg the channel as i'm sure your aware.
On *:DEVOICE:#:{
vtimechkfile
if ($hget(voicetime,$+($vnick,.vtime))) {
var %tmp = $calc($ctime - $hget(voicetime,$+($vnick,.vtime)))
.hinc voicetime $+($vnick,.total) %tmp
.hdel voicetime $+($vnick,.vtime)
echo -a * This time $vnick was voiced for $duration(%tmp,2) in total they have been voiced for $duration($hget(voicetime,$+($vnick,.total)))
}
}
This alias will check if the database exists, if not, will create it, then check if theres already entries (which are saved in a file, voicetime.hash in the mIRC directory), if so, loads them - and if the database already exists it will save your database to file so its always up-to-date.
alias vtimechkfile {
if (!$hget(voicetime)) {
hmake voicetime 5000
if ($isfile($mircdirvoicetime.hash)) { hload voicetime $+(",$mircdirvoicetime.hash,") }
}
else { hsave -o voicetime $+(",$mircdirvoicetime.hash,") }
}
Eamonn.