Play sound to player?

Discussion in 'Development' started by Moonafic, Jan 13, 2021 at 3:59 PM.

  1. Moonafic

    Moonafic Spider

    Messages:
    6
    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?
     
  2. ethaniccc

    ethaniccc Baby Zombie

    Messages:
    164
    GitHub:
    ethaniccc
    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
     
  3. RicardoMilos384

    RicardoMilos384 Slime

    Messages:
    80
    GitHub:
    ricardomilos384
    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->$player->x
    $pk->$player->y;
    $pk->$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
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.