meatball 25 Posted January 7, 2014 Looking at tweaking something in a script and I'm messing with map clicking and coordinates. Anyone know of a way to take a set of coordinates and then compare those coordinates to the coordinates of all markers in game and return the closest marker? Share this post Link to post Share on other sites
iceman77 18 Posted January 7, 2014 Maybe CBA_fnc_mapGridToPos could get you started? Then you can easily compare the distances between the positions. Share this post Link to post Share on other sites
mikie boy 18 Posted January 7, 2014 distance command can do that - Returns the distance in meters between two Objects, Positions or Locations. it will take an array as positions - assuming that what you want - player position. or failing that when you click on map - make a marker - get its position and compare not tried the CBA function - failing both of these you can use a bit of the olde Pythagoras' Theorem :) Share this post Link to post Share on other sites
iceman77 18 Posted January 8, 2014 Yeah distance command for sure. But, he's working with actual map coordinates and wants to compare the distance between coordinates. I think he will need to turn the coordinates into an actual position before he can make a distance check. Share this post Link to post Share on other sites
mikie boy 18 Posted January 9, 2014 distance = suareroot of sum (x2-x1)2 + (y2-y1)2 remember doing this a long time ago - cant find it so from the top of my head -a really awful work around - im sure there is a command for this _returnDistValue = [[1234.000, 4321.000],[2222.000,3333.000]] call coordcheck; coordCheck = { _coord1x = _this select 0 (select 0); _coord1y = _this select 0 (select 1); _coord2x = _this select 1 (select 0); _coord2y = _this select 2 (select 1); partX = _coord2x - _coord1x; partX = partX * partX; partY = _coord2y - _coord1y; partY = partY * partY; FinalDistance = partX + partY; FinalDistance = sqrt FinalDistance; //return Final distance FinalDistance }; Share this post Link to post Share on other sites
meatball 25 Posted January 9, 2014 Clarified what I'm actually trying to do in a new post. Share this post Link to post Share on other sites