Help with PlaySound() parameters?

Discussion in 'Plugin Development' started by ryanhamshire, Nov 6, 2012.

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

    ryanhamshire

    PlaySound() has volume and pitch parameters, which are floats. But the java docs just say "pitch is pitch and volume is volume". Is it 1.0 for normal volume and pitch? 100 for normal volume and pitch? Some other number for normal volume and pitch?

    I'm adding the ender teleportation sound for a teleporting player. I don't want it to be crazy loud or crazy quiet - I know I can guess at and experiment with this, but if anyone happens to know the answer, I will very much appreciate a share. :) And so will some who come after me, I'd expect.
     
  2. Offline

    david_rosales

    Figured it out. Its actually quite simple.
    So based on what you said, your command would look like this:

    Code:
    public void onCommand(Command cmd, CommandSender sender, String commandLabel, String[] args)
    {
    //command name
      if(commandLabel.equalsIgnoreCase("TpEnderSound"))
    {
        Player p = (Player) sender;
        World w = player.getWorld();
        Player t = player.getServer().getPlayer(args[0]);
        p.teleport(t);
    //Sound.ENDERMAN_TELEPORT is the sound. Just type in Sound. and it should give u a
    //on eclipse
    //player.getLocation() is where the sound will originate so make sure u put this after the teleport takes place.
    //or else no one would hear it
    //10 is the volume so this is loud enough to hear
    //1 is the pitch. i wouldnt change it.
        w.playSound(player.getLocation(), Sound.ENDERMAN_TELEPORT, 10, 1);
    }
    }
    Hope that helped! If so, like my comment.
     
Thread Status:
Not open for further replies.

Share This Page