Solved Playing Sounds

Discussion in 'Plugin Development' started by AaronL98, Jun 19, 2013.

Thread Status:
Not open for further replies.
  1. Offline


    Hey, I just started creating bukkit plugins today and I'd say I'm doing great! Though I need help on something. I know how to play sounds to a player, "player.playsound(loc, sound.(name), 1, 10);"
    But i don't know and would like to know how to play a sound in a radius. What I'm trying to create is when i right click the hoe it shoots a snowball (DONE) and play a sound to the player, maybe a gunshot noise (DONE) but I'd like other players to hear the gunshots who are in the vicinity (btw im using sound ENDERDRAGON_HIT) Isthere a way i can allow other players to hear the gunshots within the vacinity and the farther away they got the lower the sound went? Heres my code:
    1. player.playSound(loc, Sound.ENDERDRAGON_HIT, 1, 10);
  2. Offline


  3. Offline


    Would that require any more arguments for a radius or does it work automatically depending on the volume?
  4. Offline


    Works automatically depending on the volume.
  5. Offline


    Plus how would i create the world variable cause world is introducing errors. As i said, I'm kinda new :l

    World world = what now :p
  6. Offline


  7. Offline


    The world, you want to play the sound in. I.E. player.getLocation().getWorld()
  8. Offline


    That's generally a bad way to do it, in this case player.getWorld() would be the best, but I don't recommend ever using getWorld("worldname") unless you're loading from a config probably know this but I'm making sure OP does.
    Hoolean likes this.
  9. Offline


    Im getting errors on world.getWorld(); when using
    1. World world = player.getWorld();

    Its giving me a quick fix for "Change type of 'world' to 'CraftWorld'"
  10. Offline


    Whole code please?
  11. Offline


    1. player.getWorld().playSound(loc, Sound.ENDERDRAGON_HIT, 1, 10);
  12. Offline

    Hoolean Retired Staff


    Make sure you added bukkit.jar to your build-path when making the project on Eclipse, not craftbukkit.jar (there is a difference :p)

    EDIT: Nevermind, you posted while I was typing (ninja'd ;))
  13. Offline


    I've solved the puzzle :p
Thread Status:
Not open for further replies.

Share This Page