Im trying to play sound to player with LevelSoundEventPacket but the sound stays on given position so when i leave him i cant hear it. Is there a way to play sound to player but not to position?
If you want to broadcast a sound to all online players, just foreach Server->getOnlinePlayers() and make a LevelSoundEventPacket for each with their current position
you gan also do like this PHP: use pocketmine\network\protocol\mcpe\PlayerSoundPacket;$pk = PlaySoundPacket;$pk->soundName = "random.pop"; // string$pk->volume = 1; // numeric$pk->pitch = 1; // numeric$pk->x = $player->x; $pk->y = $player->y;$pk->z = $player->z;$player->dataPacket($pk); // send sound only to one player sound list can be found here https://www.digminecraft.com/lists/sound_list_pe.php
You can set $pk->disableRelativeVolume to true then anyone who receive the packet will hear it at full volume regardless of position
nah thats not helping. im trying to make ambients for server and they are 50 secs long but when you play sound to player with any method the sound stays on given coords and if you go far from it you wont hear it anymore
you should send data packet for all of players with there own coord like this: PHP: use pocketmine\network\protocol\mcpe\PlayerSoundPacket;foreach($this->getServer()->getOnlinePlayers() as $player){$pk = PlaySoundPacket;$pk->soundName = "random.pop"; // string$pk->volume = 1; // numeric$pk->pitch = 1; // numeric$pk->x = $player->x;$pk->y = $player->y;$pk->z = $player->z;$player->dataPacket($pk);}