Teleport between certain coordinates

Discussion in 'Plugin Development' started by Hutifall, Jul 6, 2019.

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


    I use google translation so sorry if there are mistakes.
    I would like to add a line of code on a plugin ffa that allows me to teleport a player in a certain area for example x: 0, y: 50, z: 0 and x: 100, y: 50, z: 100.

    Could you help me as soon as possible please?

    Thank you.
  2. Offline


    You mean teleport a player to a random location within a certain range? Or teleport a player that is in a certain area to somewhere else?
  3. Offline


    Exactly, I would like to teleport a player in a random location in a certain delimitation.
  4. Offline


    @Hutifall I still don't understand which one lol. You either want to:
    1. Find a player within a delimitation. Then teleport them somewhere.
    2. Teleport a player to random location within a certain delimitation.
    I'm guessing you mean the second one. What you do is this:
    You define the range of the area. Probably by defining values for Xmin, Xmax, Zmin and Zmax. Then you generate 4 random numbers within that range and teleport the player there.
    import java.util.Random;

    Random rand = new Random();

    // Obtain a number.
    int n rand.nextInt(Xmax Xmin);

    += Xmin;
    //n is now a number between Xmin and Xmax
    Do this for both coordinates.
  5. Offline


    Just a little reminder: To teleport someone to the middle of the block you simply add '0.5' to the x and z of the location.
Thread Status:
Not open for further replies.

Share This Page