1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

How To Create Leaderboard

Discussion in 'Plugin Help' started by RicardoMilos384, Jan 19, 2020.

  1. RicardoMilos384

    RicardoMilos384 Slime

    Messages:
    82
    GitHub:
    ricardomilos384
    Please Help Me To create Leaderboard Like TopMoney i don't know how to make
    Please Help me :v
     
  2. GamakCZ

    GamakCZ Zombie Pigman

    Messages:
    598
    GitHub:
    GamakCZ
    Just store player names and stats in arrays and then display them sorted. I'd reccommend to use this function for sorting.
     
    RicardoMilos384 likes this.
  3. RicardoMilos384

    RicardoMilos384 Slime

    Messages:
    82
    GitHub:
    ricardomilos384
    I've tried it but the floating text doesn't appear and the plugin is also in normal condition
     
  4. HimbeersaftLP

    HimbeersaftLP Fish

    Messages:
    2,402
    GitHub:
    HimbeersaftLP
    If you need help developing a plugin please send us your code (also in the future use the Development section)
     
    RicardoMilos384 likes this.
  5. RicardoMilos384

    RicardoMilos384 Slime

    Messages:
    82
    GitHub:
    ricardomilos384
    _____________
    <?php

    namespace statistic;

    use pocketmine\Player;
    use pocketmine\Server;
    use pocketmine\math\Vector3;
    use pocketmine\level\Level;
    use pocketmine\scheduler\Task;
    use pocketmine\scheduler\ServerScheduler;
    use pocketmine\plugin\PluginBase;
    use pocketmine\level\Position;
    use statistic\Main;

    use pocketmine\entity\Effect;
    use pocketmine\entity\EffectInstance;
    use pocketmine\utils\Config;

    use pocketmine\item\Item;
    use pocketmine\item\enchantment\Enchantment;
    use pocketmine\item\enchantment\EnchantmentInstance;
    use onebone\economyapi\EconomyAPI;
    use pocketmine\inventory\Inventory;
    use pocketmine\level\particle\FloatingTextParticle;

    class LeadTask extends Task {

    public $plugin;

    public function __construct(Main $plugin, Player $player) {
    $this->plugin = $plugin;
    $this->player = $player;
    }

    public function onRun(int $currentTick){
    $player = $this->player;
    $x = $this->getConfig()->get("x");
    $y = $this->getConfig()->get("y");
    $z = $this->getConfig()->get("z");

    $name = $player->getName();
    $money = $this->eco->myMoney($player);
    $online = $this->getServer->getOnlinePlayers();
    $message = " §bYour Money: §c{$money} ";
    $message1 = " §bOnline Players: §c{$online} ";
    $lead = " §c{$name}'s §aStatistic ";
    $lead1 = " §c{$name}'s §aStatistic ";
    $p = new FloatingTextParticle(new Vector3($x, $y, $z), $message,$message1, $lead);
    $player->getLevel()->addParticle($p);
    }
    }
     
  6. HimbeersaftLP

    HimbeersaftLP Fish

    Messages:
    2,402
    GitHub:
    HimbeersaftLP
    There were so many mistakes in this, I can't mention every single change, please just see for yourself:

    PHP:
    <?php

    namespace statistic;

    use 
    onebone\economyapi\EconomyAPI;
    use 
    pocketmine\level\particle\FloatingTextParticle;
    use 
    pocketmine\math\Vector3;
    use 
    pocketmine\Player;
    use 
    pocketmine\scheduler\Task;
    use 
    statistic\Main;

    class 
    LeadTask extends Task {

         private 
    $plugin;
         private 
    $player;
         private 
    $eco;

         public function 
    __construct(Main $pluginPlayer $player) {
              
    $this->plugin $plugin;
              
    $this->player $player;
              
    $this->eco EconomyAPI::getInstance();
         }

         public function 
    onRun(int $currentTick) {
              
    $player $this->player;

              
    $x $this->plugin->getConfig()->get("x");
              
    $y $this->plugin->getConfig()->get("y");
              
    $z $this->plugin->getConfig()->get("z");

              
    $name     $player->getName();

              
    $money    $this->eco->myMoney($player);

              
    $online   count($this->plugin->getServer()->getOnlinePlayers());

              
    $title    "§bYour Money: §c{$money}";

              
    $message  "§bOnline Players: §c{$online}\n";
              
    $message .= "§c{$name}'s §aStatistic\n";
              
    $message .= "§c{$name}'s §aStatistic";

              
    $p = new FloatingTextParticle(new Vector3($x$y$z), $message$title);
              
    $player->getLevel()->addParticle($p, [$player]);
         }
    }
    Why didn't you show us the error it shows in the console?

    Also in the future use the "+" button to add a code block, it makes code more readable in the forums.
     
    RicardoMilos384 likes this.
  7. RicardoMilos384

    RicardoMilos384 Slime

    Messages:
    82
    GitHub:
    ricardomilos384
    Thank You So Much
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.