Need some help here !

Discussion in 'Plugin Development' started by yustinv2, Mar 10, 2016.

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

    yustinv2

    Hey, im having some problems with my plugin im making it and i cant resolve how to do when i die i got teleported to the nearest checkpoint (Marked by me) a little example:

    I got Death Point, Point1, Point2 and Point3

    When i die i need to be teleported to the nearest point, lets say what DeathPoint is in coords x 20 64 z 20 and the checkpoints are:

    Point1 = x 50 70 z 50 Point2 = x 100 80 z 100 Point3 = x 10 50 z 10

    Now when i die i need to be teleported to of course Point3 because is the mostly close from the deathpoint, Now, how i can do this in code ? I were trying but no idea how to do this,

    ¿Someone can help me?
     
  2. Offline

    XxTimexX

    You would need to declare the spot in your code.
     
  3. Offline

    Lordloss

    You just get the distance between the death location an the checkpoints, and then set the respawn location of the player to the closest one.
     
    Gonmarte likes this.
  4. Offline

    yustinv2

    Thats is what i need, but, how i exactly convert the distance to a location for teleport? i cant just put p.teleport(distance)
    and when i convert it i just take an error maybe im not doing it right
     
  5. Offline

    cluter123

    p.getLocation().distance(x);

    Where x is the location of your death spot.

    Declare a Location variable, and set it to the place where you want a player to respawn.
    Do the same for other respawn points.
    Then make it check the closest by using a for loop and checking the distance to see which one is the closest. Then p.teleport the player to the location.
     
  6. Offline

    yustinv2

    Oh thanks, but how i can do the for loop ? i really not use it, can you help about it?
     
Thread Status:
Not open for further replies.

Share This Page