Teleport between certain coordinates

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

  1. Offline

    Hutifall

    Hello,
    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.
    Hutiii.
     
  2. Offline

    Kars

    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

    Hutifall


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

    Kars

    @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.
    PHP:
    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. Online

    KarimAKL

    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.
     

Share This Page