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

Update a leadboard

Discussion in 'Plugin Help' started by IvanCraft623, Nov 6, 2020.

  1. IvanCraft623

    IvanCraft623 Baby Zombie

    Messages:
    105
    GitHub:
    IvanCraft623
    Hello! I have made a plugin that contains leaderboards but I found the problem that the leadboard does not update (Im noob :D) and I wanted to know if any of you could help me ...

    Code:
    PHP:
    <?php

    namespace IvanCraft623\EnderHCF\Entity;

    use 
    pocketmine\entity\Monster;
    use 
    pocketmine\entity\EntityIds;
    use 
    pocketmine\scheduler\ClosureTask;

    use 
    IvanCraft623\EnderHCF\EnderHCF;

    class 
    TopKills extends Monster{

        const 
    NETWORK_ID EntityIds::CHICKEN;

        public 
    $height 0.7;
        public 
    $width 0.4;
        public 
    $gravity 0;

        protected 
    $plugin;

        public function 
    getName(): string {
            return 
    "TopKills";
        }

        public function 
    initEntity(): void {
            
    parent::initEntity();
            
    $this->setImmobile(true);
            
    $this->setHealth($this->getHealth());
            
    $this->setNameTagAlwaysVisible(true);
            
    $this->setScale(0.001);
        }

        public function 
    onUpdate(int $currentTick): bool {
            
    $kills EnderHCF::getInstance()->kills;
            
    $AllKills $kills->getAll();
            
    arsort($AllKills);
            
    $top 1;
            
    $nametag "§l§f✘ §6Leaderboard §eKills §f✘\n";
            foreach(
    $AllKills as $name => $value){
                if(
    $top 10)break;
                
    $nametag .= "§6#{$top} §f{$name} §7- §b{$value} §3kills\n";
                
    $top++;
            }
            
    $this->setNameTag($nametag);
            return 
    parent::onUpdate($currentTick);
        }
    }
    Plugin:
    http://www.mediafire.com/file/4zk3gznn0kgfnf0/EnderHCF.zip/file
     
  2. wolfdale

    wolfdale Zombie Pigman

    Messages:
    535
    GitHub:
    diamond-gold
    instead of
    PHP:
    return parent::onUpdate($currentTick);
    do
    PHP:
    parent::onUpdate($currentTick);
    return 
    true;
     
  3. IvanCraft623

    IvanCraft623 Baby Zombie

    Messages:
    105
    GitHub:
    IvanCraft623
    it does not work :(
     
  4. Ayzrix

    Ayzrix Witch

    Messages:
    66
    GitHub:
    Ayzrix
    "I have made a plugin" it's a copy paste letter by letter, space by space of my Speed Coding . And you don't have to make anything, the entity is updated automatically
     
  5. Pqoster

    Pqoster Spider Jockey

    Messages:
    25
    exposed
     
  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.