[Unsolved]Play a Sound

Discussion in 'Plugin Development' started by ASHninja1997, Jul 14, 2013.

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

    ASHninja1997

    I am wondering how to play a sound only to a certain player.
    Lets say you have a Bow and when you run out of arrows its plays a sound to you not the whole server.
    Any suggestion
     
  2. Offline

    SugarCraft

    Maybe packets? Not sure.
     
  3. Offline

    fanaticmw2

    Look into the playSound and playEffect methods
     
  4. Offline

    Mycrowut

    ASHninja1997
    Use this as a template. I hope this helps.
    Code:java
    1. player.playSound(player.getLocation(), Sound.AMBIENCE_CAVE, 1, 0);
     
  5. Offline

    Blah1

    Mycrowut what do "1" and "0" mean here?
     
  6. Offline

    Skyost

    ASHninja1997
    Play a sound to all players :
    Code:
    for(Player player : Bukkit.getOnlinePlayers()) {
        player.playSound(player.getLocation(), Sound.WITHER_SPAWN, 1, 10);
    }
    Play a sound to one player :
    Code:
    player.playSound(player.getLocation(), Sound.WITHER_SPAWN, 1, 10);
    
    Play a sound to all players who have permission test.sound :
    Code:
    for(Player player : Bukkit.getOnlinePlayers()) {
        if(player.hasPermission("test.sound") {
            player.playSound(player.getLocation(), Sound.WITHER_SPAWN, 1, 10);
        }
    }
     
Thread Status:
Not open for further replies.

Share This Page