javad_iran 0 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 Share this post Link to post Share on other sites
skazi 1 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. } Share this post Link to post Share on other sites
javad_iran 0 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 Share this post Link to post Share on other sites
javad_iran 0 Posted September 13, 2018 (edited) ... Edited September 14, 2018 by javad_iran Share this post Link to post Share on other sites