PHP: public function onPlayerChat(PlayerChatEvent $e){$e->setCancelled(true);//Cancell player chat$this->getServer()->broadcastMessage("Hello Players!");// broadcast "hello players!" to all the players online}
PHP: public function onPlayerChat(\pocketmine\event\player\PlayerChatEvent $event){ $event->setCancelled();} But what do you mean by "broadcasts"? Are you trying to make a chat mute plugin? Please be more specific, that way we can help you solve your problem faster.
he means like the /chat-off on GrabBag https://github.com/alejandroliu/poc...ter/GrabBag/src/aliuly/grabbag/CmdChatMgr.php
PHP: public function onPlayerChat(\pocketmine\event\player\PlayerChatEvent $event){ $event->setCancelled(); foreach($this->getServer()->getOnlinePlayers() as $p){ $p->send........................... }}
What's the point of cancelling PlayerChatEvent and then broadcasting it again? You should use PlayerChatEvent->setRecipients() instead.
Keep an array of players that are muted and player's that can't receive messages, when a player chats that is muted cancel the event and for the players that can't receive messages do: PHP: foreach($server->getOnlinePlayers() as $player) { if(!isset($doNotReciveChat[$player->getName()])) { $player->sendMessage($message); }}