How do i add sound using LevelSoundEventPacket? i get no errors, but the code doesn't work and i don't here the sound PHP: use pocketmine\network\mcpe\protocol\LevelSoundEventPacket; PHP: $sound = new LevelSoundEventPacket();$sound->evid = LevelSoundEventPacket::SOUND_EXPLODE;$sound->data = 0;$sound->position = $this->player->asVector3();$player->dataPacket($sound);
Try this maybe? PHP: /** * @param LevelSoundEventPacket $sound * @param Player $player */ public function sound(LevelSoundEventPacket $sound, Player $player) { $sound = new LevelSoundEventPacket(); $sound->evid = LevelSoundEventPacket::SOUND_EXPLODE; $sound->data = 0; $sound->position = $this->player->asVector3(); $player->dataPacket($sound); } ( dont quote me on this if it does not work )
PHP: function sendSound(Player $player, int $sound){ $pk = new LevelSoundEventPacket(); $pk->position = $player->asVector3(); $pk->sound = 81; $pk->extraData = $type; $pk->pitch = $pitch; $player->dataPacket($pk);} $sound->position = $this->player->asVector3();