dr_eyeball 16 Posted March 4, 2007 How do you obtain the map grid reference (eg: Fg52) for a given position, or the position reference displayed on your GPS? Is there a command for it or do you have to calculate it yourself? Edit: Thanks for the code, Wolfrug. Share this post Link to post Share on other sites
Wolfrug 0 Posted March 4, 2007 Open notepad, copy-paste the "code" section this into it, save as something like 'gridRcoord.sqf'. Call by initing a unit. From readme : (Also available with demo mission from OFPEC - alas these forums don't allow attachements! Quote[/b] ]HOW TO USE IT:Either check out the demo-mission on Rahmadi, included in this zip and find out how to implement it or use the following lines. Use these lines to get the function to work: fAdd = compile loadFile "getRCoord.sqf"; --> to compile the function and attach a name hint format ["%1",[soldier] call fAdd]; --> shows a hint with the grid coordinates or titleText [format ["%1",[soldier] call fAdd],"PLAIN",1]; --> shows a titleText with the grid coordinates Or any other use you can give to the function output. Just remember to use the first line to compile and load the function. <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">comment "Cheetah, 6th of January 2007 - contact: forum www.ofpec.com or cheetah99 [at] hotmail [dot] com"; comment "V1.00"; private ["_unit","_x","_upperArray","_lowerArray","_numberArray","_xLeft","_yLeft","_s1","_s2","_s3","_s4","_xCoordB","_xCoordS","_yCoordB","_yCoordS","_coord"]; _unit = _this select 0; _xLeft = (getPos _unit) select 0; _yLeft = (getPos _unit) select 1; _upperArray = ["V","W","X","Y","Z","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P"]; _lowerArray = ["a","b","c","d","e","f","g","h","i","j"]; _numberArray = ["4","3","2","1","0","9","8","7","6","5","4","3","2","1","0","9","8","7","6"]; _numbersArray = ["1","0","9","8","7","6","5","4","3","2","1","0","9"]; _s1 = -10000; _s2 = -8000; _s3 = 0; while { (_xLeft >= _s1) } do { if (abs(_xLeft) < _s2) then { if (_xLeft > 0) then { _xLeft = _xLeft - ((_s3-5) * 2000); }; }; _s1 = _s1 + 2000; _s2 = _s2 + 2000; _s3 = _s3 + 1; }; if (abs(_xLeft) >= 2000) then { _xLeft = _xLeft + (abs(_s3-5) * 2000); _x = 1; }; _s4 = (abs(_xLeft) / 200); _s4 = (_s4 - (_s4 mod 1)); _xCoordB = (_upperArray select (_s3-1)); if(_x == 1) then { _s4 = 9-_s4; }; if(_xCoordB == "Z") then { _s4 = 9-_s4; }; _xCoordS = (_lowerArray select _s4); _s1 = -9520; _s2 = -7520; _s3 = 0; while { (_yLeft >= _s1) } do { if (_yLeft < _s2) then { if (_yLeft < 0) then { _yLeft = _yLeft + (_s3 * 2000); _yLeft = _yLeft * -1; } else { _yLeft = _yLeft - ((_s3-5) * 2000); }; }; _s1 = _s1 + 2000; _s2 = _s2 + 2000; _s3 = _s3 + 1; }; _s4 = ((_yLeft-80) / 200); _yCoordS = (_numbersArray select (_s4 - (_s4 mod 1))); _yCoordB = (_numberArray select (_s3-1)); _coord = format ["%1%2%3%4",_xCoordB,_xCoordS,_yCoordB,_yCoordS]; _coord Good luck. Regards, Wolfrug Share this post Link to post Share on other sites