How to make leaderboards with this code? PHP: $this->PlayerFile = new Config($this->getDataFolder()."Players/".$ign."_Stats.yml", Config::YAML);if($this->PlayerFile->get("Kills") > 0 && $this->PlayerFile->get("Deaths") > 0){ On command this thing worked by checking your own stats and the code is PHP: public function onCommand(CommandSender $sender, Command $cmd, $label, array $args) { $name = $sender->getName(); $ign = $sender->getName(); $this->PlayerFile = new Config($this->getDataFolder()."Players/".$ign."_Stats.yml", Config::YAML); if(strtolower($cmd->getName()) === 'stats'){ if($sender->hasPermission("mcpemmo.stats")) { if($this->PlayerFile->get("Kills") > 0 && $this->PlayerFile->get("Deaths") > 0){ $sender->sendMessage("§8> §l§7YOUR STATS M8 §8<"."\n§8> §5Kills§8: §c".$this->PlayerFile->get("Kills")."\n§8> §5Deaths§8: §c".$this->PlayerFile->get("Deaths")."\n§8> §5KDR§8: §c".round($this->PlayerFile->get("Kills")/$this->PlayerFile->get("Deaths"), 2)); } else { $sender->sendMessage("§8> §l§7YOUR STATS M8 §8<"."\n§8> §5Kills§8: §c".$this->PlayerFile->get("Kills")."\n§8> §5Deaths§8: §c".$this->PlayerFile->get("Deaths")."\n§8> §5KDR§8: §c".round($this->PlayerFile->get("Kills")/$this->PlayerFile->get("Deaths"), 2)/*."\n§8> ".$time*/); } } } } I think its something asort, how to do it?
Use an SQLite3 database. It is much better and easier if you want collective management on your data.
I'll try soon, can you give me a code here saying "TOP KILLERS\n1. name\n2.name..." up to 10? when you type a command /top
And I was telling you that not using an SQL-family database would make storing top killers much harder... Well, without using SQL it is still possible. You can create a separate array for storing the top 10 players. Then if you refresh the top 10 list every time a list entry changes, it will be more efficient. Try this every time an entry updates: 1. Merge new entry with existing kills 2. Sort the array with rsort() 3. Store the top 10 entries using array_slice. I won't give you code directly, but here is an example of how to do it: https://gist.githubusercontent.com/...ac7b79ce20a3eafc9d9c08a0c27f9/SKC_Rewrite.php especially search "topkill". Although it is written in the old API, what matters here is the PHP functions and algorithm used, so you should still be able to understand it. Right, you asked me for code, I gave you code. Just that you cannot use the code directly, but if you can copy with understanding what it does, you should have no difficulties understanding how the updateTopKills() function my my code works.