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 Aenteritas, Sep 19, 2019.

  1. Aenteritas

    Aenteritas Silverfish

    Messages:
    22
    Whats happen to the Scoreboard? Why the Score-Numbers are not on the right side?

    Picture:
    upload_2019-9-19_17-17-53.png

    Code (ScoreboardTask.php):
    PHP:
    <?php

    namespace phytonia\bedrock\scheduler;

    use 
    phytonia\bedrock\PTCore;
    use 
    pocketmine\scheduler\Task;

    class 
    ScoreboardTask extends Task {

        public 
    $plugin;

        public function 
    __construct(PTCore $plugin){
            
    $this->plugin $plugin;
        }

        public function 
    onRun(int $currentTick){
            
    $pl $this->plugin->getServer()->getOnlinePlayers();

            foreach (
    $pl as $player) {
                
    $this->plugin->rmScoreboard($player"objektName");

                
    $this->plugin->createScoreboard($player"§e§lPhytonia Network""objektName");
                
    $this->plugin->setScoreboardEntry($player1" ""objektName");
                
    $this->plugin->setScoreboardEntry($player2"§aName:""objektName");
                
    $this->plugin->setScoreboardEntry($player3"§e" $player->getName(), "objektName");
            }
        }
    }
    Code (PTCore.php):

    PHP:
    <?php

    namespace phytonia\bedrock;

    class 
    PTCore extends PluginBase {

    public function 
    onEnable(){
        
    WorldManager::loadWorlds(); //Irrevant for this post
        
    $this->unregisterCommands(); //Irrevant for this post
        
    $this->registerCommands(); //Irrevant for this post
        
    $this->registerEvents(); //Irrevant for this post

        
    $this->saveResource("config.yml"); //Irrevant for this post
        
    $this->saveResource("stats.yml"); //Irrevant for this post
        
    $cooldowns = new Config($this->getDataFolder(). "cooldowns.yml"Config::YAML); //Irrevant for this post

        
    $this->getScheduler()->scheduleRepeatingTask(new CooldownTask($this), 20); //Irrevant for this post
        
    $this->getScheduler()->scheduleRepeatingTask(new LobbyCountTask($this), 20); //Irrevant for this post
        
    $this->getScheduler()->scheduleRepeatingTask(new StatsTask($this), 100); //Irrevant for this post
        
    $this->getScheduler()->scheduleRepeatingTask(new PlayerRecordTask($this), 300); //Irrevant for this post
        
    $this->getScheduler()->scheduleRepeatingTask(new WelcomeText($this), 200); //Irrevant for this post
        
    $this->getScheduler()->scheduleRepeatingTask(new ResetTask($this), 20); //Irrevant for this post
        
    $this->getScheduler()->scheduleRepeatingTask(new ShopTask($this), 200); //Irrevant for this post
        
    $this->getScheduler()->scheduleRepeatingTask(new BroadcastTask($this), 2400); //Irrevant for this post
        
    $this->getScheduler()->scheduleRepeatingTask(new DetectHackerTask($this), 1); //Irrevant for this post

        
    self::$instance $this//Irrevant for this post
    }
    public function 
    setScoreboardEntry(Player $playerint $scorestring $msgstring $objName) {
            
    $entry = new ScoreboardIdentityPacketEntry();
            
    $entry->objectiveName $objName;
            
    $entry->type 3;
            
    $entry->customName $msg   ";
            
    $entry->score $score;
            
    $entry->scoreboardId $score;
            
    $pk = new SetScorePacket();
            
    $pk->type 0;
            
    $pk->entries[$score] = $entry;
            
    $player->sendDataPacket($pk);
        }

        public function 
    rmScoreboardEntry(Player $playerint $score) {
            
    $pk = new SetScorePacket();
            if(isset(
    $pk->entries[$score])) {
                unset(
    $pk->entries[$score]);
                
    $player->sendDataPacket($pk);
            }
        }

        public function 
    createScoreboard(Player $playerstring $titlestring $objNamestring $slot "sidebar"$order 0) {
            
    $pk = new SetDisplayObjectivePacket();
            
    $pk->displaySlot $slot;
            
    $pk->objectiveName $objName;
            
    $pk->displayName $title;
            
    $pk->criteriaName "dummy";
            
    $pk->sortOrder $order;
            
    $player->sendDataPacket($pk);
        }

        public function 
    rmScoreboard(Player $playerstring $objName) {
            
    $pk = new RemoveObjectivePacket();
            
    $pk->objectiveName $objName;
            
    $player->sendDataPacket($pk);
        }
    }
     
  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.