SA-MP Forums Archive
How to get the highest score of all players? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: How to get the highest score of all players? (/showthread.php?tid=575266)



How to get the highest score of all players? - MOSensei - 25.05.2015

Hello, Just want to ask a question, how do I get my player rankings in my server? I mean, how can I know if players has the highest score/level & over all highest bank account of a player automatically.. Is there any script for that? If who ever can help, thanks in advance..


Re: How to get the highest score of all players? - PowerPC603 - 25.05.2015

This depends on your account system.
Do you use any INI system or do you use mysql?

In case of mysql, it can be done very easily by creating the proper query.
Like: "SELECT * FROM playerdata ORDER BY Score DESC LIMIT 10"
This query would select all fields from the table "playerdata", sorts them descending based on scorepoints and limits the result to only 10 players.
These will then be the top 10 players with highest score on your entire server.
To sort them by rank, just replace the "Score" by "Rank" (or whatever your column would be called) and you're done.


For INI systems, you may have to create a separate file that holds the top 10 players for example, as browsing ALL existing playerfiles makes your server lag very badly if you have +1000 registered players.
Using plain samp code, it's not even possible to browse all files in a directory, you need a plugin that can handle that.