The way the score database is designed is:
[nick]
value1=#
value2=#
[nick]
value1=#
value2=#
etc...
Now the code
Code: Select all
proc proc_top10 {nick uhost handle chan text} {
global mainchanreqs inifilereqs inifilescores
if {$chan != $mainchanreqs} {
return 0
}
set choice [lindex $text 0]
if {[string match -nocase "reqs" $text]} {
set v 0
set hscore(0) 0
set hiscore(0) 0
foreach {name} [parseIni $inifilescores] {
incr v
set hscore($v) value1
set hiscore($v) value2
if {($hscore($v) == "\;") && ($hiscore($v) == "\;")} {
set hscore($v) 0
set hiscore($v) 0
}
}
set first 0
set second 0
set third 0
set fourth 0
set fifth 0
set sixth 0
set seventh 0
set eight 0
set ninth 0
set tenth 0
for { set k 0 } {$k < $v} {incr k} {
if {$hscore($k) > $hscore($first)} {
set tenth $ninth
set ninth $eight
set eight $seventh
set seventh $sixth
set sixth $fifth
set fifth $fourth
set fourth $third
set third $second
set second $first
set first $k
continue
}
if {$hscore($k) > $hscore($second)} {
set tenth $ninth
set ninth $eight
set eight $seventh
set seventh $sixth
set sixth $fifth
set fifth $fourth
set fourth $third
set third $second
set second $k
continue
}
if {$hscore($k) > $hscore($third)} {
set tenth $ninth
set ninth $eight
set eight $seventh
set seventh $sixth
set sixth $fifth
set fifth $fourth
set fourth $third
set third $k
continue
}
if {$hscore($k) > $hscore($fourth)} {
set tenth $ninth
set ninth $eight
set eight $seventh
set seventh $sixth
set sixth $fifth
set fifth $fourth
set fourth $k
continue
}
if {$hscore($k) > $hscore($fifth)} {
set tenth $ninth
set ninth $eight
set eight $seventh
set seventh $sixth
set sixth $fifth
set fifth $k
continue
}
if {$hscore($k) > $hscore($sixth)} {
set tenth $ninth
set ninth $eight
set eight $seventh
set seventh $sixth
set sixth $k
continue
}
if {$hscore($k) > $hscore($seventh)} {
set tenth $ninth
set ninth $eight
set eight $seventh
set seventh $k
continue
}
if {$hscore($k) > $hscore($eight)} {
set tenth $ninth
set ninth $eight
set eight $k
continue
}
if {$hscore($k) > $hscore($ninth)} {
set tenth $ninth
set ninth $k
continue
}
if {$hscore($k) > $hscore($tenth)} {
set tenth $k
continue
}
}
if {($hscore($first) == "0") && ($hiscore($first) == "0")} {
putserv "PRIVMSG $mainchanreqs :\0032No one has requested anything yet.\003"
return 0
}
if {($hscore($second) == "0") && ($hiscore($second) == "0")} {
puthelp "PRIVMSG $mainchanreqs :\0032Top 1 Requester\:\003 1\)\0034 $hiscore($first)\003 \0036 $hscore($first)\003\002"
return 0
}
if {($hscore($third) == "0") && ($hiscore($third) == "0")} {
puthelp "PRIVMSG $mainchanreqs :\0032Top 2 Requesters\:\003 1\)\0034 $hiscore($first)\003 \0036 $hscore($first)\003 2\)\0034 $hiscore($second)\003 \0036 $hscore($second)\003\002"
return 0
}
if {($hscore($fourth) == "0") && ($hiscore($fourth) == "0")} {
puthelp "PRIVMSG $mainchanreqs :\0032Top 3 Requesters\:\003 1\)\0034 $hiscore($first)\003 \0036 $hscore($first)\003 2\)\0034 $hiscore($second)\003 \0036 $hscore($second)\003 3)\0034 $hiscore($third)\003 \0036 $hscore($third)\003\002"
return 0
}
if {($hscore($fifth) == "0") && ($hiscore($fifth) == "0")} {
puthelp "PRIVMSG $mainchanreqs :\0032Top 4 Requesters\:\003 1\)\0034 $hiscore($first)\003 \0036 $hscore($first)\003 2\)\0034 $hiscore($second)\003 \0036 $hscore($second)\003 3)\0034 $hiscore($third)\003 \0036 $hscore($third)\003 4\)\0034 $hiscore($fourth)\003 \0036 $hscore($fourth)\003\002"
return 0
}
if {($hscore($sixth) == "0") && ($hiscore($sixth) == "0")} {
puthelp "PRIVMSG $mainchanreqs :\0032Top 5 Requesters\:\003 1\)\0034 $hiscore($first)\003 \0036 $hscore($first)\003 2\)\0034 $hiscore($second)\003 \0036 $hscore($second)\003 3)\0034 $hiscore($third)\003 \0036 $hscore($third)\003 4\)\0034 $hiscore($fourth)\003 \0036 $hscore($fourth)\003 5\)\0034 $hiscore($fifth)\003 \0036 $hscore($fifth)\003\002"
return 0
}
if {($hscore($seventh) == "0") && ($hiscore($seventh) == "0")} {
puthelp "PRIVMSG $mainchanreqs :\0032Top 6 Requesters\:\003 1\)\0034 $hiscore($first)\003 \0036 $hscore($first)\003 2\)\0034 $hiscore($second)\003 \0036 $hscore($second)\003 3)\0034 $hiscore($third)\003 \0036 $hscore($third)\003 4\)\0034 $hiscore($fourth)\003 \0036 $hscore($fourth)\003 5\)\0034 $hiscore($fifth)\003 \0036 $hscore($fifth)\003 6\)\0034 $hiscore($sixth)\003 \0036 $hscore($sixth)\003\002"
return 0
}
if {($hscore($eight) == "0") && ($hiscore($eight) == "0")} {
puthelp "PRIVMSG $mainchanreqs :\0032Top 7 Requesters\:\003 1\)\0034 $hiscore($first)\003 \0036 $hscore($first)\003 2\)\0034 $hiscore($second)\003 \0036 $hscore($second)\003 3)\0034 $hiscore($third)\003 \0036 $hscore($third)\003 4\)\0034 $hiscore($fourth)\003 \0036 $hscore($fourth)\003 5\)\0034 $hiscore($fifth)\003 \0036 $hscore($fifth)\003 6\)\0034 $hiscore($sixth)\003 \0036 $hscore($sixth)\003 7\)\0034 $hiscore($seventh)\003 \0036 $hscore($sixth)\003\002"
return 0
}
if {($hscore($ninth) == "0") && ($hiscore($ninth) == "0")} {
puthelp "PRIVMSG $mainchanreqs :\0032Top 8 Requesters\:\003 1\)\0034 $hiscore($first)\003 \0036 $hscore($first)\003 2\)\0034 $hiscore($second)\003 \0036 $hscore($second)\003 3)\0034 $hiscore($third)\003 \0036 $hscore($third)\003 4\)\0034 $hiscore($fourth)\003 \0036 $hscore($fourth)\003 5\)\0034 $hiscore($fifth)\003 \0036 $hscore($fifth)\003 6\)\0034 $hiscore($sixth)\003 \0036 $hscore($sixth)\003 7\)\0034 $hiscore($seventh)\003 \0036 $hscore($sixth)\003 8\)\0034 $hiscore($eight)\003 \0036 $hscore($eight)\003\002"
return 0
}
if {($hscore($tenth) == "0") && ($hiscore($tenth) == "0")} {
puthelp "PRIVMSG $mainchanreqs :\0032Top 9 Requesters\:\003 1\)\0034 $hiscore($first)\003 \0036 $hscore($first)\003 2\)\0034 $hiscore($second)\003 \0036 $hscore($second)\003 3)\0034 $hiscore($third)\003 \0036 $hscore($third)\003 4\)\0034 $hiscore($fourth)\003 \0036 $hscore($fourth)\003 5\)\0034 $hiscore($fifth)\003 \0036 $hscore($fifth)\003 6\)\0034 $hiscore($sixth)\003 \0036 $hscore($sixth)\003 7\)\0034 $hiscore($seventh)\003 \0036 $hscore($sixth)\003 8\)\0034 $hiscore($eight)\003 \0036 $hscore($eight)\003 9\)\0034 $hiscore($ninth)\003 \0036 $hscore($ninth)\003\002"
return 0
}
puthelp "PRIVMSG $mainchanreqs :\0032Top 10 Requesters\:\003 1\)\0034 $hiscore($first)\003 \0036 $hscore($first)\003 2\)\0034 $hiscore($second)\003 \0036 $hscore($second)\003 3)\0034 $hiscore($third)\003 \0036 $hscore($third)\003 4\)\0034 $hiscore($fourth)\003 \0036 $hscore($fourth)\003 5\)\0034 $hiscore($fifth)\003 \0036 $hscore($fifth)\003 6\)\0034 $hiscore($sixth)\003 \0036 $hscore($sixth)\003 7\)\0034 $hiscore($seventh)\003 \0036 $hscore($sixth)\003 8\)\0034 $hiscore($eight)\003 \0036 $hscore($eight)\003 9\)\0034 $hiscore($ninth)\003 \0036 $hscore($ninth)\003 10\)\0034 $hiscore($tenth)\003 \0036 $hscore($tenth)\003\002"
return 0
}
return 0
}