{"name":"onMapSingleClick","operator":null,"title":"onMapSingleClick","type":"command","url":"https://community.bistudio.com/wiki/onMapSingleClick","revid":377823,"updated":"2026-01-03T04:21:02Z","groups":["Map","Event Handlers"],"status":"ok","replaced_by":[],"games":[{"game":"ofp","name":"Operation Flashpoint","version":"1.85"},{"game":"ofpe","name":"Operation Flashpoint: Elite","version":"1.00"},{"game":"arma1","name":"Armed Assault","version":"1.00"},{"game":"arma2","name":"Arma 2","version":"1.00"},{"game":"arma2oa","name":"Arma 2: Operation Arrowhead","version":"1.50"},{"game":"tkoh","name":"Take On Helicopters","version":"1.00"},{"game":"arma3","name":"Arma 3","version":"0.50"}],"since":{"game":"ofp","name":"Operation Flashpoint","version":"1.85"},"arma3_since":"0.50","branch":null,"locality":{"argument":null,"effect":null,"server_exec":false},"exec":null,"description":"Defines the action performed when user clicks in map by executing command string. The code is executed on every click, until the **command** is\n- removed via `onMapSingleClick \"\"`, or\n- replaced by `onMapSingleClick \"SomeOtherCommand(s)\"`\n\nIn Arma 3 the code should return true only if you wish to override default engine handling of the mouse click on map (see #Example 4).\n\nFor older games, when click is processed, code should ultimately return true back to the engine. If false is returned, default processing by the game engine is done.\nReturn value of any other type (including Nothing) is an error. In such case default processing by the game engine is done, and error message may be displayed.\n\n> [!NOTE]\n> **Arma 3:** Since Arma 3 v1.58 the stackable MapSingleClick Mission Event Handler is available and should be used instead.","syntaxes":[{"syntax":"onMapSingleClick command","since":null,"effect":null,"exec":null,"params":[{"name":"command","type":"String or Code","optional":false,"default":null,"description":"code executed on click. The following variables are available:\n- _pos: Position2D - clicked position\n- _units: Array of Objects - units which were selected (via function keys) **before** opening the map (*may be non-functional in Arma*)\n- _shift: Boolean - Whether <kbd>Shift</kbd> was pressed when clicking on the map\n- _alt: Boolean - Whether <kbd>Alt</kbd> was pressed when clicking on the map","types":["String","Code"],"since":null,"text":"command: String or Code - code executed on click. The following variables are available:\n- _pos: Position2D - clicked position\n- _units: Array of Objects - units which were selected (via function keys) **before** opening the map (*may be non-functional in Arma*)\n- _shift: Boolean - Whether <kbd>Shift</kbd> was pressed when clicking on the map\n- _alt: Boolean - Whether <kbd>Alt</kbd> was pressed when clicking on the map"}],"returns":{"type":"Nothing","types":["Nothing"],"description":null,"text":"Nothing"},"form":"unary","operator":null,"left":null,"right":{"text":"command","types":["String","Code"]}},{"syntax":"params onMapSingleClick command","since":null,"effect":null,"exec":null,"params":[{"name":"params","type":"Anything","optional":false,"default":null,"description":null,"types":["Anything"],"since":null,"text":"params: Anything"},{"name":"command","type":"String or Code","optional":false,"default":null,"description":"code executed on click. The following variables are available:\n- _this: Anything - Params passed to onMapSingleClick\n- _pos: Position2D - clicked position\n- _units: Array of Objects - units which were selected (via function keys) **before** opening the map (*may be non-functional in Arma*)\n- _shift: Boolean - Whether <kbd>Shift</kbd> was pressed when clicking on the map\n- _alt: Boolean - Whether <kbd>Alt</kbd> was pressed when clicking on the map","types":["String","Code"],"since":null,"text":"command: String or Code - code executed on click. The following variables are available:\n- _this: Anything - Params passed to onMapSingleClick\n- _pos: Position2D - clicked position\n- _units: Array of Objects - units which were selected (via function keys) **before** opening the map (*may be non-functional in Arma*)\n- _shift: Boolean - Whether <kbd>Shift</kbd> was pressed when clicking on the map\n- _alt: Boolean - Whether <kbd>Alt</kbd> was pressed when clicking on the map"}],"returns":{"type":"Nothing","types":["Nothing"],"description":null,"text":"Nothing"},"form":"binary","operator":null,"left":{"text":"params","types":["Anything"]},"right":{"text":"command","types":["String","Code"]}}],"examples":[{"text":"**Armed Assault:** Creates a soldier unit at the position clicked:\n\n```sqf\nonMapSingleClick \"'SoldierWB' createUnit [_pos, group player]; true\";\n```","code":["onMapSingleClick \"'SoldierWB' createUnit [_pos, group player]; true\";"]},{"text":"**Armed Assault:** Orders \"grp1\" to move to position clicked. Disables further map-click actions:\n\n```sqf\nonMapSingleClick \"grp1 move _pos; onMapSingleClick ''; true\";\n```","code":["onMapSingleClick \"grp1 move _pos; onMapSingleClick ''; true\";"]},{"text":"**Operation Flashpoint:** Single quotes cannot be used for string definition, so two double-quotes have to be used instead:\n\n```sqf\nonMapSingleClick \"'SoldierWB' createUnit [_pos, group player]; true\";\n```","code":["onMapSingleClick \"'SoldierWB' createUnit [_pos, group player]; true\";"]},{"text":"```sqf\n// The following code will disable Shift+click waypoint marker creation\nonMapSingleClick {_shift};\n```","code":["// The following code will disable Shift+click waypoint marker creation\nonMapSingleClick {_shift};"]},{"text":"```sqf\n// Pass params to onMapSingleClick code\nplayer onMapSingleClick { hint (\"Hello \" + name _this) }; // Hello KK\n```","code":["// Pass params to onMapSingleClick code\nplayer onMapSingleClick { hint (\"Hello \" + name _this) }; // Hello KK"]},{"text":"```sqf\n// Pass params to onMapSingleClick code -and- disable Shift+click waypoint marker creation\n player onMapSingleClick \"hint (\"\"Hello \"\" + name _this); _shift\"; // Hello KK\n```","code":["// Pass params to onMapSingleClick code -and- disable Shift+click waypoint marker creation\n player onMapSingleClick \"hint (\"\"Hello \"\" + name _this); _shift\"; // Hello KK"]}],"multiplayer":null,"problems":null,"aliases":[],"see_also":["onGroupIconClick"],"notes":[{"user":"General Barron","date":"2009-07-08T02:25:00Z","text":"See my [Multiple OnMapSingleClick](http://www.ofpec.com/editors-depot/index.php?action=details&id=292&game=ArmA) script to allow you to add multiple events to the onMapSingleClick event. Some minor editing of the scripts would be required to use them in Arma."},{"user":"Killzone_Kid","date":"2016-04-01T00:25:00Z","text":"`_units` param is supposed to return what groupSelectedUnits returns. Player must be leader and some units in the group must be selected on the group bar. However selected units are connected with group orders menu, which interferes with map click. In other words, when you click on the main map, the map gets focus and group orders menu closes, deselecting any selected unit, so `_units` is [] pretty much all the time."}],"categories":["ArmA: Armed Assault: Scripting Commands","Arma 2: Operation Arrowhead: Scripting Commands","Arma 2: Scripting Commands","Arma 3: Scripting Commands","Command Group: Event Handlers","Command Group: Map","Introduced with Operation Flashpoint version 1.85","Operation Flashpoint: Elite: Scripting Commands","Operation Flashpoint: New Scripting Commands","Operation Flashpoint: Scripting Commands","Scripting Commands","Take On Helicopters: Scripting Commands"]}