on *:start: {
hmake TopScores 100
if ($isfile($scriptdir\topscores.hsh)) { hload TopScores $qt($scriptdir\topscores.hsh) }
}
on *:text:!addpoint & &:#: {
if ($nick isop $chan && $3 isnum) {
hadd TopScores $2 $calc($hget(TopScores,$2) + $3)
.notice $nick Added $3 points to $2 $+ .
}
hsave TopScores $qt($scriptdir\topscores.hsh)
}
on *:text:!delpoint & &:#: {
if ($nick isop $chan) {
if ($3 isnum) {
hadd TopScores $2 $iif($calc($hget(TopScores,$2) - $3) >= 0,$v1,0)
.notice $nick Subtracted $3 points from $2 $+ .
}
elseif ($3 == all) {
hadd TopScores $2 0
.notice $nick Removed ALL points from $2 $+ .
}
hsave TopScores $qt($scriptdir\topscores.hsh)
}
}
on *:text:!top5:#: {
if (%Top5.fld) { return }
set -u10 %Top5.fld On
hsave TopScores hash.tmp
filter -ffcuten 2 32 hash.tmp
var %cnt = 1
while (%cnt <= 5) {
var %data = $read(hash.tmp,%cnt)
msg $chan $hget(TopScores,$gettok(%data,1,32)).item is 1/ $+ $hget(TopScores,0).item with $gettok(%data,2,32) points
inc %cnt
}
.remove hash.tmp
}