setting top 5(need a better way) - 23/12/02 08:26 PM
hey, i have made a game, which stores the top 5 players bassed on scores, and the way i did it to set the top 5 works great, BUT, if i have X many players, then it wont set the top 5, because the variable is "set %whatever line too long"
This is the code, and what i am looking for is a better way to sort through the scroes, cause if i have 200 players, then the vars will be too long for sure, here is what i have:
cplay sets in $1 param The $2 param as $3- in an ini file,
$cplay gets the data from the $1 param section, for $2
An example of a few entries in the inifile would be:
nightchillz=250
tim=125
frank=200
etc
.
An example Of What "%b" Would look like is:
250,nightchillz 200,frank 125,tim
those are in the section [money]
thanks in advance
This is the code, and what i am looking for is a better way to sort through the scroes, cause if i have 200 players, then the vars will be too long for sure, here is what i have:
Code:
alias settop5 { cplay -r top5 var %a = $ini(inplay.ini,money,0), %b while (%a > 0) { %b = %b $cplay(money,$ini(inplay.ini,money,%a)) $+ $chr(44) $+ $ini(inplay.ini,money,%a) dec %a } %b = $gettok($sorttok(%b,32,nr),1-5,32) var %c = 0, %d = $numtok(%b,32) while (%c < %d) { inc %c cplay top5 $gettok($gettok(%b,%c,32),2,44) $gettok($gettok(%b,%c,32),1,44) } }
cplay sets in $1 param The $2 param as $3- in an ini file,
$cplay gets the data from the $1 param section, for $2
An example of a few entries in the inifile would be:
nightchillz=250
tim=125
frank=200
etc
.
An example Of What "%b" Would look like is:
250,nightchillz 200,frank 125,tim
those are in the section [money]
thanks in advance