Hello it's been 2 days I'm struggling to make sure to update a scoreboard, it really does not want and I do not understand why, I was therefore inspired by the poggit plugin but the method does not work either, I must surely do something wrong. Here are my functions and how I use them: Create, first time PHP: public static function createScoreboard($order = 0) : void { //Imagine $players is already set with a list of player, I tested it it works (I cut the part where I create $ players) foreach ($players as $player) { $packet = new SetDisplayObjectivePacket(); $packet->displaySlot = "sidebar"; $packet->objectiveName = "jumpleague"; $packet->displayName = JumpLeague::getMessage("namescoreboard", [], 1); $packet->criteriaName = "dummy"; $packet->sortOrder = $order; var_dump($player->sendDataPacket($packet)); } } Create works well the problem is the 2nd time I want to enter the information in the table. Update, and set the first time : PHP: public static function setScoreboardEntry(string $msg, int $score) : void { //Imagine $players is already set with a list of player, I tested it it works (I cut the part where I create $ players) foreach ($players as $player) { $entry = new ScorePacketEntry(); $entry->objectiveName = "jumpleague"; $entry->type = 3; $entry->customName = " $msg"; $entry->score = $score; $entry->scoreboardId = $score; $packet = new SetScorePacket(); $packet->type = 0; $packet->entries[$score] = $entry; $player->sendDataPacket($packet); //By ayzrix the haxor } } No error, the packet is sent because it returns true, the scoreboard has been created, etc. Besides, to wonder why pocketmine does not contain an API for scoreboard
As written in my first post, the scoreboard is created, the lines are put correctly, but when I want to update it nothing changes
I don't know if you allready done it but here is how i make my scoreboard. First I create the scoreboard the code looks like this PHP: public function setScoreboardEntry(Player $player, int $score, string $msg, string $objName) { $entry = new ScorePacketEntry(); $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 $player, int $score) { $pk = new SetScorePacket(); if (isset($pk->entries[$score])) { unset($pk->entries[$score]); $player->sendDataPacket($pk); } } public function createScoreboard(Player $player, string $title, string $objName, string $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 $player, string $objName) { $pk = new RemoveObjectivePacket(); $pk->objectiveName = $objName; $player->sendDataPacket($pk); } public function onScore() { $this->rmScoreboard($player, "objektName"); //Scoreboard Title $this->createScoreboard($player, "ScoreBoard Lol", "objektName"); //Lines $this->setScoreboardEntry($player, 1, " ", "objektName"); $this->setScoreboardEntry($player, 2, " ", "objektName"); } } After this actually at first tbh I start the Task like this in onEnable PHP: $this->getScheduler()->scheduleRepeatingTask(new ScoreBoard($this), 20); The content of the task is basicly very short PHP: <?phpnamespace ahmad\Tasks;use ahmad\buildFFA;use pocketmine\scheduler\Task;class ScoreBoard extends Task{ /** * @var buildFFA */ private $main; public function __construct(buildFFA $main) { $this->main = $main; } public function onRun(int $currentTick) { $this->main->onScore(); }}