Dogs

Discussion in 'Plugin Development' started by killerzz1, Jul 20, 2015.

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

    killerzz1

    Hello, I am making a plugin so that when a player comes close to a player they will hear a dog bark.

    How would i get the near by players location and if they are within a set amount it will play a sound?
     
  2. @killerzz1 PlayerMoveEvent is called when a player is moving. you can get the location the player is moving to and you can get a list of all online players of the class Bukkit or of the Serverobject. Then you loop through all online players and check if their current location is in bounds with the player who moved. if there is a player in bounds, play the sound at his location. so far everything clear?
     
  3. Offline

    Larsn

    PlayerMoveEvent is the one your looking for.

    Good luck not making it lagg.
     
  4. Offline

    Rambokatt

    Excited for this one, lol. Register every single player move event on the server. Lagcauser 2000
     
  5. Offline

    killerzz1

    Lol yea not doing that XD
     
  6. Offline

    ChipDev

    Lets say e.getPlayer() = pl, and you loop through all the players in the server except pl.Thats called loop
    Do what he said, then find the code for example:
    if(pl.getLocation().distanceSquared(loop.getLocation)<=radius*radius) { (bark) }
     
  7. @Rambokatt @killerzz1 Well sure, PlayerMoveEvent is fired every time any player moved, but with the correct checks it wont laag. it is simply creating a few rectangles (done in less than 1 millisecond) and checking their borders (maximum 2 milliseconds). This wont cause laags. and only if the second check where you check the borders is true, you will do something. so up to this point it will cause like at a full bad luck maybe 5 milliseconds "laag". You won't die from that. And when you execute your code, it has to be done anyways, so there is no way to get arround that except for threading, scheduling or multiple processes.
     
Thread Status:
Not open for further replies.

Share This Page