1. Oxide 1.18 has been discontinued and is no longer supported. Please do not post requests for Oxide 1.18 plugins or support.
    We recommend upgrading to Oxide 2.0 as able. Plugins can be easily updated to support it as well.
  1. P0LENT4

    P0LENT4 Wood Hoarder Plugin Developer

    Hello, I wonder if you have the possibility to accurately measure the distance between two points (positions)?

    Example: I teleported the player to a map position, I command him to walk for 15 seconds in any direction and stop, so I want to measure the distance he traveled ...

    Thank you in advance
     
  2. Jakkee

    Jakkee Scavenger Plugin Developer

    Code (Text):
    float distance = Vector3.Distance(object1.transform.position, object2.transform.position);
    // 1 float = 1 metre (ish)
     
    tugamano likes this.
  3. tugamano

    tugamano Shack Builder Plugin Developer

    Distance from player to player:
    Code (Text):
    [ChatCommand("distanceplayer")]
            void cmdDistancePlayer(NetUser netuser, string command, string[] args){
                if(args.Length == 0){rust.Notice(netuser, "Use /distanceplayer (PlayerName)");return;}
                NetUser tragetUser = rust.FindPlayer(args[0]);
                if(tragetUser == null){rust.Notice(netuser, "Player name not found!");return;}
                var distance = Math.Floor(Vector3.Distance(netuser.playerClient.lastKnownPosition, tragetUser.playerClient.lastKnownPosition));
                rust.SendChatMessage(netuser, "position", string.Format("You are at a distance of {0} meter/s from {1}", distance,  tragetUser.displayName));
            }
     
    Distance from player to position:
    Code (Text):
            [ChatCommand("distanceplayerposition")]
            void cmdDistancePlayerposition(NetUser netuser, string command, string[] args){
                var positionSmallRodtown = new Vector3(6099f, 386f, -3555f);
                var distance = Math.Floor(Vector3.Distance(netuser.playerClient.lastKnownPosition, positionSmallRodtown));
                rust.SendChatMessage(netuser, "position", string.Format("You are at a distance of {0} meter/s from position Small Rodtown", distance));
            }
    Distance from positions:
    Code (Text):
            [ChatCommand("distancepositions")]
            void cmdDistanceposition(NetUser netuser, string command, string[] args){
                var positionSmallRodtown = new Vector3(6099f, 386f, -3555f);
                var positionHangar = new Vector3(6569f, 368f, -4297f);
                var distance = Math.Floor(Vector3.Distance(positionSmallRodtown, positionHangar));
                rust.SendChatMessage(netuser, "position", string.Format("Small Radtown is a distance of {0} meter/s from the hangar ", distance));
            }
     
    Last edited: Nov 29, 2016
  4. P0LENT4

    P0LENT4 Wood Hoarder Plugin Developer

    Thank you very much. both