1. Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the comminuty!

    Now, what are you waiting for? Join the community now!

Dismiss Notice
This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Find Nearest Person

Discussion in 'Requests' started by Crocie, Jul 29, 2021.

  1. Crocie

    Crocie Member

    Joined:
    Jul 2, 2021
    Messages:
    29
    Likes Received:
    0
    Line 8:
    I need an expression similar to that.

    Code (Text):
    1. command /eventstart:
    2.     permission: "event.admin"
    3.     trigger:
    4.         loop players in radius 200 of {eventpos}:
    5.             set {target} to loop-player
    6.             if {target} is set:
    7.                 set {eventpos} to location at (0, 4, 0) in world "world"
    8.                 message "&9%closest player to {eventpos}%"
    9.         if {target} is not set:
    10.             message "&9No Players Within 200 blocks."
     
  2. Crocie

    Crocie Member

    Joined:
    Jul 2, 2021
    Messages:
    29
    Likes Received:
    0
  3. Vasture

    Vasture Member

    Joined:
    Jul 30, 2021
    Messages:
    1
    Likes Received:
    0
    message "%loop-player%"?
     
  4. DieHollander_

    DieHollander_ Active Member

    Joined:
    Mar 25, 2018
    Messages:
    188
    Likes Received:
    12
    Code (Text):
    1. function nearestPlayer(p:player,range:number=100) :: player:
    2.     set {_loc} to location of {_p}
    3.     set {_pllist::*} to all players in radius {_range} around {_loc} where [player input is not {_p}]
    4.     set {_nearest} to first element of {_pllist::*}
    5.     loop {_pllist::*}:
    6.         if distance between location of loop-value and {_loc} is less than distance between {_loc} and {_nearest}:
    7.             set {_nearest} to loop-value
    8.     return {_nearest}
     

Share This Page

Loading...