{"name":"Example Code: Convert Position To Map Grid","title":"Example Code: Convert Position To Map Grid","type":"topic","url":"https://community.bistudio.com/wiki/Example_Code:_Convert_Position_To_Map_Grid","revid":378162,"updated":"2026-02-28T20:46:00Z","aliases":["Converting position to map grid"],"markdown":"### Arma 3 (Arma 3 v1.00 Arma 2 v1.04)\n\n> [!NOTE]\n> - mapGridPosition has been introduced in Arma 2 v1.04\n\n```sqf\nprivate _mapGridPosition = mapGridPosition player;\n```\n\n### Arma 2 (Arma 2 v1.00)\n\n> [!NOTE]\n> - BIS_fnc_posToGrid has been introduced in Arma 2 v1.00\n\n```sqf\nlocal _mapGridPosition = player call BIS_fnc_posToGrid;\n```\n\n### Armed Assault (Armed Assault v1.00)\n\n> [!NOTE]\n> - floor has been introduced in Armed Assault v1.00\n\n```sqf\nprivate [\"_gridSize\", \"_yOffset\", \"_xPos\", \"_yPos\"]\nprivate [\"_letter1Index\", \"_letter2Index\", \"_letter1Choice\", \"_letter2Choice\", \"_letter1\", \"_letter2\"]\nprivate [\"_numbers\", \"_mapGridPosition\"]\n\n_gridSize = 200; // given grid squares are 200 × 200\n_yOffset = -280; // position [0,0,0] is somewhere in the middle of second big grid on Y axis\n\n_xPos = floor ((_this select 0) / _gridSize);\n_yPos = floor (((_this select 1) + _yOffset) / _gridSize);\n\n_letter1Index = floor (_xPos / 10);\n_letter2Index = floor (_xPos % 10);\n_letter1Choice = [\"A\", \"B\", \"C\", \"D\", \"E\", \"F\", \"G\", \"H\", \"I\", \"J\"];\n_letter2Choice = [\"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\", \"i\", \"j\"];\n_letter1 = _letter1Choice select _letter1Index;\n_letter2 = _letter2Choice select _letter2Index;\n\n_numbers = 100 - _yPos; // coordinate numbers start from top-left of the map\n\n_mapGridPosition = format [\"%1%2%3\", _letter1, _letter2, _numbers];\n```\n\n### Operation Flashpoint (Operation Flashpoint v1.00)\n\n```sqs\nprivate [\"_gridSize\", \"_yOffset\", \"_xPos\", \"_yPos\"]\nprivate [\"_letter1Index\", \"_letter2Index\", \"_letter1Choice\", \"_letter2Choice\", \"_letter1\", \"_letter2\"]\nprivate [\"_numbers\", \"_mapGridPosition\"]\n\n; given grid squares are 200 × 200\n_gridSize = 200\n\n; position [0,0,0] is somewhere in the middle of second big grid on Y axis\n_yOffset = -280\n\n_xPos = (_this select 0) / _gridSize\n_yPos = ((_this select 1) + _yOffset) / _gridSize\n_xPos = _xPos - (_xPos mod 1)\n_yPos = _yPos - (_yPos mod 1)\n\n_letter1Index = _xPos / 10\n_letter2Index = _xPos % 10\n_letter1Index = _letter1Index - (_letter1Index mod 1)\n_letter2Index = _letter2Index - (_letter2Index mod 1)\n_letter1Choice = [\"A\", \"B\", \"C\", \"D\", \"E\", \"F\", \"G\", \"H\", \"I\", \"J\"]\n_letter2Choice = [\"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\", \"i\", \"j\"]\n_letter1 = _letter1Choice select _letter1Index\n_letter2 = _letter2Choice select _letter2Index\n\n; coordinate numbers start from top-left of the map\n_numbers = 100 - _yPos\n\n_mapGridPosition = format [\"%1%2%3\", _letter1, _letter2, _numbers]\n```","sections":[{"heading":"Arma 3 (Arma 3 v1.00 Arma 2 v1.04)","level":3,"markdown":"> [!NOTE]\n> - mapGridPosition has been introduced in Arma 2 v1.04\n\n```sqf\nprivate _mapGridPosition = mapGridPosition player;\n```"},{"heading":"Arma 2 (Arma 2 v1.00)","level":3,"markdown":"> [!NOTE]\n> - BIS_fnc_posToGrid has been introduced in Arma 2 v1.00\n\n```sqf\nlocal _mapGridPosition = player call BIS_fnc_posToGrid;\n```"},{"heading":"Armed Assault (Armed Assault v1.00)","level":3,"markdown":"> [!NOTE]\n> - floor has been introduced in Armed Assault v1.00\n\n```sqf\nprivate [\"_gridSize\", \"_yOffset\", \"_xPos\", \"_yPos\"]\nprivate [\"_letter1Index\", \"_letter2Index\", \"_letter1Choice\", \"_letter2Choice\", \"_letter1\", \"_letter2\"]\nprivate [\"_numbers\", \"_mapGridPosition\"]\n\n_gridSize = 200; // given grid squares are 200 × 200\n_yOffset = -280; // position [0,0,0] is somewhere in the middle of second big grid on Y axis\n\n_xPos = floor ((_this select 0) / _gridSize);\n_yPos = floor (((_this select 1) + _yOffset) / _gridSize);\n\n_letter1Index = floor (_xPos / 10);\n_letter2Index = floor (_xPos % 10);\n_letter1Choice = [\"A\", \"B\", \"C\", \"D\", \"E\", \"F\", \"G\", \"H\", \"I\", \"J\"];\n_letter2Choice = [\"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\", \"i\", \"j\"];\n_letter1 = _letter1Choice select _letter1Index;\n_letter2 = _letter2Choice select _letter2Index;\n\n_numbers = 100 - _yPos; // coordinate numbers start from top-left of the map\n\n_mapGridPosition = format [\"%1%2%3\", _letter1, _letter2, _numbers];\n```"},{"heading":"Operation Flashpoint (Operation Flashpoint v1.00)","level":3,"markdown":"```sqs\nprivate [\"_gridSize\", \"_yOffset\", \"_xPos\", \"_yPos\"]\nprivate [\"_letter1Index\", \"_letter2Index\", \"_letter1Choice\", \"_letter2Choice\", \"_letter1\", \"_letter2\"]\nprivate [\"_numbers\", \"_mapGridPosition\"]\n\n; given grid squares are 200 × 200\n_gridSize = 200\n\n; position [0,0,0] is somewhere in the middle of second big grid on Y axis\n_yOffset = -280\n\n_xPos = (_this select 0) / _gridSize\n_yPos = ((_this select 1) + _yOffset) / _gridSize\n_xPos = _xPos - (_xPos mod 1)\n_yPos = _yPos - (_yPos mod 1)\n\n_letter1Index = _xPos / 10\n_letter2Index = _xPos % 10\n_letter1Index = _letter1Index - (_letter1Index mod 1)\n_letter2Index = _letter2Index - (_letter2Index mod 1)\n_letter1Choice = [\"A\", \"B\", \"C\", \"D\", \"E\", \"F\", \"G\", \"H\", \"I\", \"J\"]\n_letter2Choice = [\"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\", \"i\", \"j\"]\n_letter1 = _letter1Choice select _letter1Index\n_letter2 = _letter2Choice select _letter2Index\n\n; coordinate numbers start from top-left of the map\n_numbers = 100 - _yPos\n\n_mapGridPosition = format [\"%1%2%3\", _letter1, _letter2, _numbers]\n```"}],"categories":["Example Code"],"groups":["Scripting"]}