javad_iran Posted September 11, 2018 Share Posted September 11, 2018 (edited) hi please send example code for ( if in range ) I want to be able to use a cmd when the player is in a certain range sorry for bad english Edited September 11, 2018 by javad_iran Link to comment Share on other sites More sharing options...
skazi Posted September 11, 2018 Share Posted September 11, 2018 public static bool IsInRangeOfPoint(Vector3 playerPos, Vector3 target, float range) { var direct = new Vector3(target.X - playerPos.X, target.Y - playerPos.Y, target.Z - playerPos.Z); var len = direct.X * direct.X + direct.Y * direct.Y + direct.Z * direct.Z; return range * range > len; } Example of usage: if(IsInRangeOfPoint(player.position, new Vector3(0, 0, 0), 5f)) { // the player is close to the coordinates >> (0, 0, 0) } else { // the player is not close to the coordinates. } Link to comment Share on other sites More sharing options...
javad_iran Posted September 12, 2018 Author Share Posted September 12, 2018 14 hours ago, skazi said: public static bool IsInRangeOfPoint(Vector3 playerPos, Vector3 target, float range) { var direct = new Vector3(target.X - playerPos.X, target.Y - playerPos.Y, target.Z - playerPos.Z); var len = direct.X * direct.X + direct.Y * direct.Y + direct.Z * direct.Z; return range * range > len; } Example of usage: if(IsInRangeOfPoint(player.position, new Vector3(0, 0, 0), 5f)) { // the player is close to the coordinates >> (0, 0, 0) } else { // the player is not close to the coordinates. } thanks. how to get time for your cmd? example: if(IsInRangeOfPoint(player.position, new Vector3(0, 0, 0), 5f)) { console.log(`${player.name} use the cmd in ${time} `); } for ${time} please help sorry for bad english Link to comment Share on other sites More sharing options...
javad_iran Posted September 13, 2018 Author Share Posted September 13, 2018 (edited) ... Edited September 14, 2018 by javad_iran Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now