Highscores 2

By owl on Mar 21, 2010

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)
  }
}

Comments

Sign in to comment.
thejman   -  Feb 28, 2011

; 2 for ini file eg: [money]
; nick1=30
; nick2=20

How can i return the value's 30 and 20?

So if i do: !rank nick1
it says: [Highscores] Thejman is 1st in the highscores with 30.

 Respond  
owl   -  Mar 23, 2010

Meh, some people store their data like that, i personally don't :p

Jetrhro_ My other highscores does alot more than this one so i decided not to delete it >.<

 Respond  
WorldDMT   -  Mar 23, 2010

hi

; 3 for second ini type eg: [nick1]
; money=60
; [nick2]
; money=90

it's not a good idea if some nick is [BamBoo] then into ini file it will be ~BamBoo~

e.g:
[~BamBoo~]
money=20

then you'll never got the result of this type of nicks

 Respond  
GuitarMasterx7   -  Mar 22, 2010

touche my N!44a touche =[]

 Respond  
Jethro   -  Mar 22, 2010

Well, If the original code is confusing, don't you think it makes sense to update the old one with the new method? Old software or applications are usually phased out with new improved ones. That's the way to go. It could be a different story if you're an old, bulky code collector...:P

 Respond  
GuitarMasterx7   -  Mar 22, 2010

its not an update but a rather non- confusing one

 Respond  
Jethro   -  Mar 21, 2010

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.

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.