Can I see an example of a local chat when a certain command is triggered on behalf of a player? For example, I need to do the command "/me" and so that it is not on the entire server was visible but at a certain distance from the caller of the command.
What do you mean? Do you mean either of these: 1. you want the command to just send it to you and not the whole server 2. The /me you put is visible to the whole server and you want to only a certain amount of people to see it.
I want to make it so that the command was "/me [player action]" and the message was seen in a certain radius and not the whole world. Output: "Player1 sat on the steps".
So you want the command to be seen in a certain radius or the output? My best bet is to try using mtrand to create a radius like this. Code: $x = $player->x + mt_rand(10, 15); //radius is 10-15 blocks $z = $player->z + mt_rand(5, 15); $y = $player->getLevel()->getHighestBlockAt($x, $z);
Within a certain radius of whoever called the team. Can the code you provided help me with a solution?
This is quite simple to implement. OnChat event just get the players near the player coordinates. Then set the viewers from the array.
Couldn't you just do PHP: foreach($player->getLevel()->getNearbyEntities($player->getBoundingBox()->expandedCopy($maxX, $maxY, $maxZ)) as $entity) { if($entity instanceof \pocketmine\Player) {# If near by entity is a player // code }}
PHP: /** @var PlayerChatEvent */$event->setRecipients( array_filter($player->getLevel()->getNearbyEntities( $player->getBoundingBox()->expandedCopy($maxX, $maxY, $maxZ), fn($e) => $e instanceof Player) );); I've realised that there are so many times you can go by without foreach loops.