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

Scoreboard

Discussion in 'Development' started by xXNiceAssassinlo YT, Jan 25, 2019.

  1. xXNiceAssassinlo YT

    xXNiceAssassinlo YT Zombie Pigman

    Messages:
    499
    GitHub:
    xXNiceYT
    Hello, my name is Nice and I am 25.

    You know the scoreboard flicking idk how to example but scoreboard disappear, ya that do u know how to fix it.

    Idk if it’s possible
     
  2. Shelly7w7

    Shelly7w7 Spider

    Messages:
    6
    GitHub:
    Shelly7w7
    Like, it disappears and shows up again when it refreshes?
     
    xXNiceAssassinlo YT likes this.
  3. xXNiceAssassinlo YT

    xXNiceAssassinlo YT Zombie Pigman

    Messages:
    499
    GitHub:
    xXNiceYT
    Yup
     
  4. MalakasPlayzMCPE

    MalakasPlayzMCPE Zombie Pigman

    Messages:
    667
    I don't think anything like that is possible. We are using an old, modified version of ScoreboardsPE. What we did was addLine() once, and then remove the ones who refresh and add them back updated, but some of the lines were duplicating. If you really need to get rid of that, this is the only thing I know that would help.
     
    xXNiceAssassinlo YT likes this.
  5. xXNiceAssassinlo YT

    xXNiceAssassinlo YT Zombie Pigman

    Messages:
    499
    GitHub:
    xXNiceYT
    WhT is it
     
  6. MalakasPlayzMCPE

    MalakasPlayzMCPE Zombie Pigman

    Messages:
    667
    [​IMG]
    That's the bug, old screenshot, from 1.7 probably, because we changed the system within 2-3 days.
    Here is how our old code works (found that from an abandoned plugin):
    PHP:
                                $scoreboard $this->scoreboard;
                                
    $scoreboard->setLine($player1" ");
                                
    $scoreboard->removeLine($player2);
                                
    $scoreboard->setLine($player2C::GOLD." Hello, ".C::AQUA.$player->getDisplayName());
                                
    $scoreboard->setLine($player3"  ");
                                
    $scoreboard->removeLine($player4);
                                
    $scoreboard->setLine($player4C::GOLD." Your Health: ".C::AQUA.$player->getHealth());
                                
    $scoreboard->removeLine($player5);
                                
    $scoreboard->setLine($player5C::GOLD." Bot's Health: ".C::AQUA.$bot->getHealth());
                                
    $scoreboard->removeLine($player6);
                                
    $scoreboard->setLine($player6C::GOLD." Time Left: ".C::AQUA.$time);
                                
    $scoreboard->removeLine($player7);
                                
    $scoreboard->setLine($player7C::GOLD." Online: ".C::AQUA.count($this->plugin->getServer()->getOnlinePlayers()));
                                
    $scoreboard->setLine($player8"   ");
                                
    $scoreboard->removeLine($player9);
                                
    $scoreboard->setLine($player9C::GOLD." Shop: ".C::GREEN.$shop);
                                
    $scoreboard->addDisplay($playerScoreboardDisplaySlot::SIDEBARScoreboardSort::DESCENDING);
    PHP:
        public function __construct(Main $plugin) {
            
    $this->plugin $plugin;
            
    $scoreboard = new Scoreboard($this->plugin->getServer()->getPluginManager()->getPlugin("ScoreboardsPE")->getPlugin(), C::BOLD.C::RED."Bot PracticePvP"ScoreboardAction::CREATE);
            
    $scoreboard->create(ScoreboardDisplaySlot::SIDEBARScoreboardSort::DESCENDING);
            
    $this->scoreboard $scoreboard;
        }
     
    Muqsit likes this.
  7. Kyd

    Kyd Zombie Pigman

    Messages:
    678
    GitHub:
    boi1216
    Or don't use ScoreboardPE and use your own API so you avoid doing hacks like @MalakasPlayzMCPE showed
     
  8. xXNiceAssassinlo YT

    xXNiceAssassinlo YT Zombie Pigman

    Messages:
    499
    GitHub:
    xXNiceYT
    Wait than if its not possible how is NetherGames doing it
     
  9. MalakasPlayzMCPE

    MalakasPlayzMCPE Zombie Pigman

    Messages:
    667
    luck? it happens sometimes
     
  10. Astro

    Astro Slime

    Messages:
    78
    GitHub:
    RealAstro
    this is how i created mine
    PHP:
        public function showScoreboard(): void{
            
    $pk = new SetDisplayObjectivePacket();
            
    $pk->displaySlot "sidebar";
            
    $pk->objectiveName $this->getName();
            
    $pk->displayName "§l§6Hestra§8PvP";
            
    $pk->criteriaName "dummy";
            
    $pk->sortOrder 0;
            
    $this->sendDataPacket($pk);
            
    $this->scoreboardVisible true;
        }

        public function 
    getScoreboardLine(int $score): ?string{
            return empty(
    $this->scoreboardLines[$score]) ? null $this->scoreboardLines[$score];
        }

        public function 
    updateScoreboard(): void{
            
    $data $this->getData();
            
    $lines = [
                
    => " ",
                
    => " §l§6Head Hunting: ",
                
    => "  §l§e* §r§7Level:§f " $this->getHHLevel() . " ",
                
    => "  §l§e* §r§7Experience:§f " $this->getHHProgress() . " ",
                
    => "  ",
                
    => " §l§6Information: ",
                
    => "  §l§e*§r§7 Realm:§f Overlord",
                
    => "  §l§e* §r§7Balance:§f $" round($data->get("balance")) . " ",
                
    => "  §l§e* §r§7Faction:§f No-Faction",
                
    10 => "  §l§e* §r§7Online:§f " count($this->getServer()->getOnlinePlayers()) . " ",
                
    11 => "   ",
                
    12 => " §eplay.HestraPvP.net "
            
    ];
            foreach(
    $lines as $score => $line){
                
    $this->setScoreboardLine($score$line);
            }
        }
        public function 
    setScoreboardLine(int $scorestring $line): void{
            if(!
    $this->scoreboardVisible) return;
            
    $entry = new ScorePacketEntry();
            
    $entry->objectiveName $this->getName();
            
    $entry->type $entry::TYPE_FAKE_PLAYER;
            
    $entry->customName $line;
            
    $entry->score $score;
            
    $entry->scoreboardId $score;
            if(isset(
    $this->scoreboardLines[$score])){
                
    $pk = new SetScorePacket();
                
    $pk->type $pk::TYPE_REMOVE;
                
    $pk->entries[] = $entry;
                
    $this->sendDataPacket($pk);
            }
            
    $pk = new SetScorePacket();
            
    $pk->type $pk::TYPE_CHANGE;
            
    $pk->entries[] = $entry;
            
    $this->sendDataPacket($pk);
            
    $this->scoreboardLines[$score] = $line;
        }
    it works fine because i don't need a task to update it each time
     
  11. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    The bug you were experiencing might be due to the fact that each score name must be unique.
    For example, if two "Chest Refill" score entries have the same name...
    Code:
    Chest Refill: 2:30
    Chest Refill: 2:30
    
    ...then the client hides one of them (not sure which one). It sucks, yeah. In my case, I added a hack by NUL-concatenating the lines, like so:
    PHP:
    public function setLine(int $linestring $text) : void{
        
    //...
        
    $entry = new ScorePacketEntry();
        
    $entry->type ScorePacketEntry::TYPE_FAKE_PLAYER;
        
    $entry->objectiveName $this->objective;
        
    $entry->customName $text str_repeat("\0"$line); //<-- concatenating with "\0" so each score name is unique. The "\0" won't show up in the scoreboard.
        
    $entry->score $line;
        
    //...
    }
     
  12. MalakasPlayzMCPE

    MalakasPlayzMCPE Zombie Pigman

    Messages:
    667
    It refreshes each second, it cannot be same. Also, if it was the same, the new line would not appear.
     
  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.