1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

[SOLVED] PlaySoundPacket doesn't work

Discussion in 'Facepalm' started by matcracker, Aug 10, 2017.

  1. matcracker

    matcracker Spider

    Messages:
    13
    GitHub:
    matcracker
    Hi guys, I'm trying to send sounds to players by using PlaySoundPacket but it doesn't send anything and I don't know how to fix... This is my code:

    PHP:
    public static function playSound(Player $playerstring $soundNamefloat $volume 0float $pitch 0)
        {
            
    $pk = new PlaySoundPacket();
            
    $pk->soundName $soundName;
            
    $pk->= (int)$player->x;
            
    $pk->= (int)$player->y;
            
    $pk->= (int)$player->z;
            
    $pk->volume $volume;
            
    $pk->pitch $pitch;
            
    $player->dataPacket($pk);
        }
    PHP:
    Utils::playSound($p"game.player.hurt"10.8);
    Thank you for you help! :D
     
  2. matcracker

    matcracker Spider

    Messages:
    13
    GitHub:
    matcracker
    @dktapps sorry, I realized now that I accidentally created the thread in the facepalm section. Can you move it? Thank you! xD
     
  3. matcracker

    matcracker Spider

    Messages:
    13
    GitHub:
    matcracker
    Anyone know how to help me?

    EDIT:
    I tried to broadcast the packet, but nothing...
    PHP:
    if ($pk !== null) {
        if (!
    is_array($pk)) {
             
    Server::getInstance()->broadcastPacket($player->getLevel()->getPlayers(), $pk);
        } else {
             
    Server::getInstance()->batchPackets($player->getLevel()->getPlayers(), $pk);
        }
    }
     
    Last edited: Aug 11, 2017
  4. CreeperFace

    CreeperFace Witch

    Messages:
    58
    GitHub:
    creeperface01
    tested on local MCPE vanilla server and MCPE and there it works well, with volume 1 and pitch 1, but if I send exactly same packet on pocketmine it doesn't work... probably pocketmine bug
     
  5. matcracker

    matcracker Spider

    Messages:
    13
    GitHub:
    matcracker
    I know that in vanilla works but in pocketmine not. Or for string "soundName" it means something else or I don't know...
     
  6. CreeperFace

    CreeperFace Witch

    Messages:
    58
    GitHub:
    creeperface01
    I tested this packet with Minet client and MCPE sent exactly same packet like we do, so I really don't know what's wrong
     
  7. matcracker

    matcracker Spider

    Messages:
    13
    GitHub:
    matcracker
    Anyone else?
     
  8. matcracker

    matcracker Spider

    Messages:
    13
    GitHub:
    matcracker
  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.