Hi guys, I am trying to make a simple plugin that sends chat to everyone is a selected world, in this case the world where the message is from. Although this simple code: PHP: <?php/*__PocketMine Plugin__name=MultiChatversion=1.0description=Separate chat for each worldauthor=Lamboclass=multichatapiversion=11*/class multichat implements Plugin{ private $api; public function __construct(ServerAPI $api, $server = false){ $this->api = $api; } public function __destruct(){} public function init(){ $this->api->addHandler("player.chat", array($this,"onChat")); } public function onChat($data){ foreach($this->api->player->getAll($data["player"]->level) as $plyers){ $plyers->sendChat($data["player"]->username.": ".$data["message"]); } return false; }} The problem is, this sends the message to everyone in the world but the player himself, and sometimes otherwise. I cannot figure out why. Can anyone help? Thanks.
That was added in the main code, I just posted the code that wasn't working here. I will add it now. But I still don't understand why the code doesn't work.
I already made this plugin, and many others, but for some reason they reject. Here is my chat plugin here for each of the world their own, but if you want to write in global chat just put ! in a message.
I would, but it seems that this changes when you change world and go back. And I would still like to know why this happens.
When you send a message, everyone in the word gets the message but the sender doesn't. And sometimes only the sender gets the message...
Try this: PHP: foreach($this->api->player->getAll($data["player"]->level) as $players){if($players instanceof Player){$players->sendChat($data["player"]->username.": ".$data["message"]);}}