Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Solved How to send sound to player

Comments in 'Plugin Development' started by CaptainKenji17, Jan 25, 2016.

  1. CaptainKenji17
    Offline

    CaptainKenji17 Active Member

    Joined:
    Apr 22, 2014
    Posts:
    252
    Minecraft User:
    CaptainKenji17
    I want to spawn the sound to the target player only, Other players wont hear the sound.

    PHP:
    $ev->getDamager()->getLevel()->addSound(new AnvilFallSound($ev->getDamager()->getLocation()));
    this might work but I want only the damager hear the sound
  2. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    Send a packet to the player? BTW, Player is already a location. No need for the getLocation();
  3. CaptainKenji17
    Offline

    CaptainKenji17 Active Member

    Joined:
    Apr 22, 2014
    Posts:
    252
    Minecraft User:
    CaptainKenji17
    how to send packet to player
  4. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    You can only add them to the level, not to special players
    Vaivez66 likes this.
  5. Tim // robske Büba
    Offline

    Tim // robske Büba Notable Member

    Joined:
    Feb 26, 2014
    Posts:
    606
    Minecraft User:
    robske_110
    Sound Packet Search through the pocketmine code and you'll find the packet :)
    HyperCry likes this.
  6. Samueljh1H8sLag
    Offline

    Samueljh1H8sLag Active Member

    Joined:
    Jun 20, 2015
    Posts:
    168
    Minecraft User:
    Samueljh1_
    No, you can do this:

    PHP:
    $player->getLevel()->addSound(new AnvilSound($player), $player->getLevel()->getPlayers());
  7. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    There is no sound packet. Sounds are level events.
    PocketKiller and CraftYourBukkit like this.
  8. Tim // robske Büba
    Offline

    Tim // robske Büba Notable Member

    Joined:
    Feb 26, 2014
    Posts:
    606
    Minecraft User:
    robske_110
    What are "level events"
  9. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    An event that is notified by a LevelEventPacket.
    Muqsit likes this.
  10. korado531m7
    Offline

    korado531m7 Active Member

    Joined:
    Apr 4, 2015
    Posts:
    158
    Minecraft User:
    korado531m7
    PHP:
                $level $this->getServer()->getLevelByName("world"); //test world
                
    $player $this->getServer()->getPlayer(); //get player
                
    $sound "pocketmine\\level\\sound\\"."AnvilSound";
                
    $level->addSound(new $sound($player));
    CaptainKenji17 likes this.
  11. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    1. Why use $sound indirectly?"
    2. getPlayer() requires a parameter...
  12. korado531m7
    Offline

    korado531m7 Active Member

    Joined:
    Apr 4, 2015
    Posts:
    158
    Minecraft User:
    korado531m7
    Ans1: Its not have a mean.
    Ans2: I made a mistake. Sorry.
    PHP:
    $player Player data
  13. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Edit your post and stop letting the wrong code stay here.
  14. CrazedMiner
    Offline

    CrazedMiner Notable Member Plugin Developer

    Joined:
    Jan 31, 2015
    Posts:
    348
    Plugins:
    2
    Minecraft User:
    CrazedMinerYT
    The player class isn't in it self a possision, it extends the class therefore inheriting all its properties.
  15. CrazedMiner
    Offline

    CrazedMiner Notable Member Plugin Developer

    Joined:
    Jan 31, 2015
    Posts:
    348
    Plugins:
    2
    Minecraft User:
    CrazedMinerYT
    Why is it so hard to get a straight forward answer to such a simple question?
    PHP:
    // $player being a player instance and SoundName being a sound class
    $player->getLevel()->addSound(new SoundName($player), [$player]);
    Last edited: Jan 28, 2016
  16. Samueljh1H8sLag
    Offline

    Samueljh1H8sLag Active Member

    Joined:
    Jun 20, 2015
    Posts:
    168
    Minecraft User:
    Samueljh1_
    That's exactly the same as my answer lol
  17. CrazedMiner
    Offline

    CrazedMiner Notable Member Plugin Developer

    Joined:
    Jan 31, 2015
    Posts:
    348
    Plugins:
    2
    Minecraft User:
    CrazedMinerYT
    Well for some reason it didn't solve the thread so...
  18. Samueljh1H8sLag
    Offline

    Samueljh1H8sLag Active Member

    Joined:
    Jun 20, 2015
    Posts:
    168
    Minecraft User:
    Samueljh1_
    well he liked it and hasn't replied since so I'm guessing that counted xD
  19. CrazedMiner
    Offline

    CrazedMiner Notable Member Plugin Developer

    Joined:
    Jan 31, 2015
    Posts:
    348
    Plugins:
    2
    Minecraft User:
    CrazedMinerYT
    I guess but it doesn't really matter, neither of us gave a wrong answer :p
  20. CaptainKenji17
    Offline

    CaptainKenji17 Active Member

    Joined:
    Apr 22, 2014
    Posts:
    252
    Minecraft User:
    CaptainKenji17
    sorry i forgot to reply here :p it works btw thanks for the help!
    Samueljh1H8sLag likes this.

Share This Page

Advertisement