NoGain wrote:
Many of the sites utilizing your XML feed or PHP API also show a percentage towards next rank. I haven't seen anything either in the XML and/or PHP API docs that provide this. So, my question is, are each of the various developers storing the various Ranks required scores locally, comparing the existing player score and determining the GAP in order to calculate percentage?
Or, is there some slick method?
I didn't seen an answer to your question (maybe I missed it?), but yes, at least that's how I did it. Now I can't speak to PHP, as I'm an ASP developer, but I stored all the ranks and their score requirements in a database table. I then simply compare the player's score and the next rank's score requirement (the next rank is determined by using the player's current rank number and adding one, of course, i.e. RankID + 1).
For anyone who needs help with this, here's the math:
CurrentRankScore = the score requirement of the player's current rank
NextRankScore = the score requirement of the next rank
PlayerScore = the player's current score
Range = NextRankScore - CurrentRankScore (i.e. the difference between the two rank's requirements
Needed = NextRankScore - PlayerScore (i.e. the difference between the player's score, and the score they need to make rank)
So then the final formula is:
Percentage = ((Range-Needed)/Range) * 100
PercentageNeeded = 100 - Percentage
Example: the player has a score of 400 (meaning he's a Private First Class). Given this scenario, the values of the above would be:
CurrentRankScore = 150
NextRankScore = 500
PlayerScore = 400
Range = 500 - 150 = 350
Needed = 500 - 400 = 100
Percentage = ((350-100)/350) * 100 = (250/350) * 100 = 0.7142... * 100 = 71.42...%
Then just round to the nearest one, using whatever method your programming language (php, asp, or whatever) provides. So in this case, the player has made it about 71% toward his next rank.
PercentageNeeded = 100 - 71 = 29
Then, to create a little progress bar for each player, I just used a simple HTML table, something like this...
... where [Percentage] and [PercentageNeeded] are supplied by variables containing the percentages calculated by the formulas above (in other words, those are replaced by the computed percentages). Thus, using the example player stats above, your final HTML for that player would look like this:
This will produce a 100 pixel wide box that is 12 pixels high, with a 1 pixel wide border. In the box will be a blue bar that will go 71% of the way across from the left; a white "background" will show in the remaining 29% of the box.
You could of course use style sheets, instead of the bgcolor= declarations, to better tweak the format of your table's background colors, border style and colors, etc.
For an example, see my gaming group's leaderboard here, written using ASP and SQL database (where you'll see I'm a better web developer than I am a BF2 player, heh heh heh):
http://www.sodabob.com/3DGames/Group/HO … ?MenuID=24Bob.