This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

highscores

Old posts that have not been replied to for several years.
Locked
m
meks
Voice
Posts: 16
Joined: Mon Jun 09, 2003 3:16 pm

highscores

Post by meks »

hi!

ive build a script which allows people from a list to give points to other people (even if the receivers are not on the list).

well - this script is working fine and without any problems. now i thought i could make a highscore-list. so i started to code such a thing.
now - about 24h later i gave it up.

i got a file where all users and their points are logged in this way:
nick|hostmask|points
so i thought i could create a ranking by simply checking each entry against the others. if the current entry has more points than another, simply increase the rank by one, and otherwise decrease by one.

well. no. it doesnt work at all.

so my question is quite clear - what's the simplest way to create a ranking?
i can remeber of keyed arrays like in php, where each entry of an array got a key and if you sort the array by its values you can afterwards do a ranking with ease. but thats not possible in tcl afaik?

so...please help me :)
s
spyda
Halfop
Posts: 64
Joined: Mon Aug 12, 2002 2:22 am
Location: Australia

Good idea... But try this!

Post by spyda »

With what you have said about your problem, I did a sort file for my trivia chan and i used this method.

Code: Select all

  set ofile [open $filename r]
  set ranks [lsort -dict -decreasing [split [gets $ofile]]]
  close $ofile
With using this code. You will need to change the way the data is entered in the file...
Meks.....

i got a file where all users and their points are logged in this way:
nick|hostmask|points
Cause the coding will sort from the biggest to the smallest number.. Change the format to points|nick|uhost.

Note: When i made my top100 list.. I made the TXT file, LINE BY LINE. I found out latter on the it would make the file quite big. So you might want to have a look into making it one long string.

eg. 553|Meks|there@there.com 400|ThePope|home@home.com 350|Bot|Bot@bot.com

Hope that Helps.
-----------
ThePope[/b]
Locked