Ok, this is my second highscores snippet as my first one confused a lot of people and was not compatible with how they stored their data.
This one now does 4 different types of data
Please make sure that you set all the settings before using it or it will not work :p
;owls highscores system
;simply use $highscores(<rank>) eg: $highscores(5) returns rawr
;or $highscores(<nick>) eg: $highscores(rawr) return 5th
;Change this to fit what how your data is stored:
; 1 for hash table eg: nick1=10 | nick2=5
; 2 for ini file eg: [money]
; nick1=30
; nick2=20
; 3 for second ini type eg: [nick1]
; money=60
; [nick2]
; money=90
; 4 for vars eg: %money.nick1 30 | %money.nick2 34
alias highscores.type { return 0 }
;Change to the file that your data is stored in, eg hs.ini for inis or just money for hash
;Ignore this if you picked option 4
alias highscores.file { return filename }
;Ignore this if you picked option 1
;Change the section/item in your ini file (Choose the section if you picked option 2 or the item if you picked option 3)
;If you picked option 4 please use this as the start of your var eg: money.
alias highscores.item { return item/sectionName }
;;;;;key;;;;;
; [section] ;
; item=date ;
;;;;;;;;;;;;;
;This is optional if you get really stuck I have made an on text event to explain better how it works
;Please note that this on text is very basic and I would advise adding some spam filters to it ;]
#highscore.text on
on $*:TEXT:/^[!@.]rank\b/Si:#:{
if ($1 isnum) {
$iif($left($1,1) == @,msg $chan,notice $nick) [Highscores] Ranked $ord($2) is $highscores($2)
}
else {
$iif($left($1,1) == @,msg $chan,notice $nick) [Highscores] $2 is $highscores($2) in the highscores.
}
}
#highscore.text end
alias highscores {
if (!$highscores.type) {
echo -a [Highscores Error] Please set how you store your data.
return
}
else if (!$isid) { return }
if ($highscores.type == 1) {
if (!$hget($highscores.file,0).item) {
echo -a [Highscores Error] Please either make/load your hash file or set it.
return
}
.remove temp.ini
.hsave -i $highscores.file temp.ini
.window -c @hs
.window -h @hs
.filter -fwctue 2 61 temp.ini @hs *=*
return $iif($iif($1 isnum,$gettok($line(@hs,$1),1,61),$ord($fline(@hs,$1 $+ =*))),$v1,not ranked)
}
else if ($highscores.type == 2) {
if (!$ini($highscores.file,$highscores.item,0)) {
echo -a [Highscores Error] Please make sure that you have set the file and the section and it has data in it.
return
}
.window -c @hs
.window -h @hs
.loadbuf -t $+ $highscores.item @hs $highscores.file
.filter -wwctue 2 61 @hs @hs *=*
return $iif($iif($1 isnum,$gettok($line(@hs,$1),1,61),$ord($fline(@hs,$1 $+ =*))),$v1,not ranked)
}
else if ($highscores.type == 3) {
if (!$readini($highscores.file,$ini($highscores.file,1),$highscores.item)) {
echo -a [Highscores Error] Please make sure that you have set the file and the section and it has item and data in it.
return
}
.window -c @hs
.window -h @hs
var %x $ini($highscores.file,0)
while (%x) {
var %y $ini($highscores.file,%x)
aline @hs %y $+ = $+ $readini($highscores.file,%y,$highscores.item)
dec %x
}
.filter -wwctue 2 61 @hs @hs *=*
return $iif($iif($1 isnum,$gettok($line(@hs,$1),1,61),$ord($fline(@hs,$1 $+ =*))),$v1,not ranked)
}
else if ($highscores.type == 4) {
var %item % $+ $highscores.item $+ *
if (!$var($(%item,1))) {
echo -a [Highscores Error] Please make sure that you have set your vars like % $+ $highscores.item $+ nick1 56
return
}
.window -c @hs
.window -h @hs
var %x 1
while ($var($(%item,1),%x)) {
aline @hs $right($var($(%item,1),%x),- $+ $len(% $+ $highscores.item)) $+ = $+ $var($(%item,1),%x).value
inc %x
}
.filter -wwctue 2 61 @hs @hs *=*
return $iif($iif($1 isnum,$gettok($line(@hs,$1),1,61),$ord($fline(@hs,$1 $+ =*))),$v1,not ranked)
}
}
This script strikes a similarity of somewhat to the one I've helped out in the forum in response to -XperTeeZ-'s a few days ago. But nice effort nevertheless. =)
By the way, you should update your original highscores script instead of making a new one according to the posting rules. I believe this one will get deleted.