Hey. I think I'm stopping my Scoreboard/Task wrong. Here is the Code: Main.php: PHP: <?phpnamespace Deeonix\DCore;use pocketmine\plugin\PluginBase;use pocketmine\event\player\PlayerJoinEvent;use pocketmine\event\player\PlayerQuitEvent;use pocketmine\event\Listener;use pocketmine\utils\TextFormat;class Main extends PluginBase implements Listener{ public $tasks = []; public function onEnable() { $this->getServer()->getPluginManager()->registerEvents($this, $this); $this->getLogger()->info(TextFormat::GREEN."Enabled!"); } public function onDisable() { $this->getLogger()->info(TextFormat::RED."Disabled!"); } public function onLoad() { $this->getLogger()->info(TextFormat::YELLOW."Loaded!"); } public function onJoin(PlayerJoinEvent $event) { $player = $event->getPlayer(); $name = $player->getName(); $event->setJoinMessage(TextFormat::GREEN.TextFormat::BOLD."» ".TextFormat::RESET.TextFormat::GREEN.$name); $this->enableSB($player); //Server::getInstance()->broadcastMessage(TextFormat::GREEN.TextFormat::BOLD."» ".TextFormat::RESET.TextFormat::GREEN.$name); } public function onQuit(PlayerQuitEvent $event) { $player = $event->getPlayer(); $name = $player->getName(); $event->setQuitMessage(TextFormat::RED.TextFormat::BOLD."« ".TextFormat::RESET.TextFormat::RED.$name); //Server::getInstance()->broadcastMessage(TextFormat::RED.TextFormat::BOLD."« ".TextFormat::RESET.TextFormat::GREEN.$name); } public function enableSB($player) { $task = new SB($this, $player); $taskid = $task->getTaskId(); $this->getServer()->getScheduler()->scheduleRepeatingTask($task, 20); $this->tasks[$taskid] = $taskid; } public function disableSB($id) { unset($this->tasks[$id]); $this->getServer()->getScheduler()->cancelTask($id); } } SB.php: PHP: <?phpnamespace Deeonix\DCore;use pocketmine\scheduler\PluginTask;use pocketmine\Player;use Deeonix\DCore\Main;class SB extends PluginTask { public $plugin; private $player; private $name; public function __construct(Main $plugin, Player $player) { parent::__construct($plugin); $this->plugin = $plugin; $this->player = $player; $this->name = $this->player->getName(); } public function getPlugin() { return $this->plugin; } public function onRun($tick) { while($this->plugin->getServer()->getPlayer($this->name)->isOnline()) { $this->plugin->getServer()->getPlayer($this->name)->sendTip(" Name: ".$this->name."\n Rang: Master"); } $this->plugin->disableSB($this->getTaskId()); } } When a player leava the server i get this message:
explanation: you cant do that because server will now keep spamming tip packet to the FIRST client that joins, and ignore everything else not even a second client can join nor anything because you used while(remember that blocks other background under the hood stuff) acceptable mistake for people who havent know PHP, but you should use a repeating task and use a IF player is online send tip else cancel task
Fixed: PHP: <?phpnamespace Deeonix\DCore;use pocketmine\scheduler\PluginTask;use pocketmine\utils\TextFormat;use pocketmine\Player;use Deeonix\DCore\Main;class SB extends PluginTask { public $plugin; private $player; private $name; public function __construct(Main $plugin, Player $player) { parent::__construct($plugin); $this->plugin = $plugin; $this->player = $player; $this->name = $this->player->getName(); } public function getPlugin() { return $this->plugin; } public function onRun($tick) { if($this->plugin->getServer()->getPlayer($this->name) === null) { $this->plugin->disableSB($this->getTaskId()); } else { $this->plugin->getServer()->getPlayer($this->name)->sendTip(" Name: ".$this->name."\n Rang: Master"); } } } Thanks for the hint