Solved Playing Sounds

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

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

    AaronL98

    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:
    Code:java
    1. player.playSound(loc, Sound.ENDERDRAGON_HIT, 1, 10);
     
  2. Offline

    Ivan

  3. Offline

    AaronL98

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

    Ivan

    Works automatically depending on the volume.
     
  5. Offline

    AaronL98

    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

    Ivan

    plugin.getServer().getWorld("worldname");
     
  7. Offline

    minoneer

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

    Garris0n

    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 file...you probably know this but I'm making sure OP does.
     
    Hoolean likes this.
  9. Offline

    AaronL98

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


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

    Zaane

    Whole code please?
     
  11. Offline

    AaronL98

    Solved:
    Code:java
    1. player.getWorld().playSound(loc, Sound.ENDERDRAGON_HIT, 1, 10);
     
  12. Offline

    Hoolean Retired Staff

    AaronL98

    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

    AaronL98

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

Share This Page