{"name":"targetsQuery","operator":null,"title":"targetsQuery","type":"command","url":"https://community.bistudio.com/wiki/targetsQuery","revid":377711,"updated":"2026-01-02T09:03:51Z","groups":["Object Detection"],"status":"ok","replaced_by":[],"games":[{"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":"arma2","name":"Arma 2","version":"1.00"},"arma3_since":"0.50","branch":null,"locality":{"argument":null,"effect":null,"server_exec":false},"exec":null,"description":"Returns sorted array of targets, **known** to the enquirer (including own troops), where the accuracy coefficient reflects how close the result matches the query. This command could be CPU intensive.","syntaxes":[{"syntax":"enquirer targetsQuery [targetIgnore, targetSide, targetType, targetPosition, targetMaxAge]","since":null,"effect":null,"exec":null,"params":[{"name":"enquirer","type":"Object","optional":false,"default":null,"description":"for whom the query will be made","types":["Object"],"since":null,"text":"enquirer: Object - for whom the query will be made"},{"name":"targetIgnore","type":"Object","optional":false,"default":null,"description":"target object to exclude from results. objNull - return every target","types":["Object"],"since":null,"text":"targetIgnore: Object - target object to exclude from results. objNull - return every target"},{"name":"targetSide","type":"Side","optional":false,"default":null,"description":"desired side of the target. sideUnknown - any side","types":["Side"],"since":null,"text":"targetSide: Side - desired side of the target. sideUnknown - any side"},{"name":"targetType","type":"String","optional":false,"default":null,"description":"desired target typeOf. \"\" - any type","types":["String"],"since":null,"text":"targetType: String - desired target typeOf. \"\" - any type"},{"name":"targetPosition","type":"Position2D or Position3D","optional":false,"default":null,"description":"desired target position (only [x,y] is considered). Position tolerance is 200m from the actual position of the target. [] - any position","types":["Position2D","Position3D"],"since":null,"text":"targetPosition: Position2D or Position3D - desired target position (only [x,y] is considered). Position tolerance is 200m from the actual position of the target. [] - any position"},{"name":"targetMaxAge","type":"Number","optional":false,"default":null,"description":"desired max age of the target. This will limit returned results to the targets younger than specified age. 0 - any age","types":["Number"],"since":null,"text":"targetMaxAge: Number - desired max age of the target. This will limit returned results to the targets younger than specified age. 0 - any age"}],"returns":{"type":"Array of Arrays with [accuracy, target, targetSide, targetType, targetPosition, targetAge]","types":["Array"],"description":"accuracy: Number in range 0..1 - a coefficient, which reflects how close the returned result to the query filter. (1 - best match) - target: Object - the actual target object - targetSide: Side - side of the target - targetType: String - target typeOf - targetPosition: Array - [x,y] of the target - targetAge: Number - the actual target age in seconds (can be negative)","text":"Array of Arrays with [accuracy, target, targetSide, targetType, targetPosition, targetAge]\n- accuracy: Number in range 0..1 - a coefficient, which reflects how close the returned result to the query filter. (1 - best match)\n- target: Object - the actual target object\n- targetSide: Side - side of the target\n- targetType: String - target typeOf\n- targetPosition: Array - [x,y] of the target\n- targetAge: Number - the actual target age in seconds (can be negative)"},"form":"binary","operator":null,"left":{"text":"enquirer","types":["Object"]},"right":{"text":"[targetIgnore, targetSide, targetType, targetPosition, targetMaxAge]","types":["Array"]}}],"examples":[{"text":"Return all known targets for player:\n\n```sqf\n_targets = player targetsQuery [objNull, sideUnknown, \"\", [], 0];\n```","code":["_targets = player targetsQuery [objNull, sideUnknown, \"\", [], 0];"]},{"text":"Prioritise all known OPFOR targets and return targets less than 10 seconds old:\n\n```sqf\n_targets = player targetsQuery [objNull, east, \"\", [], 10];\n```","code":["_targets = player targetsQuery [objNull, east, \"\", [], 10];"]}],"multiplayer":null,"problems":null,"aliases":[],"see_also":["targets","nearTargets","targetsAggregate","targetKnowledge","knowsAbout","reveal","forgetTarget","setTargetAge","getHideFrom"],"notes":[],"categories":["Arma 2: New Scripting Commands","Arma 2: Operation Arrowhead: Scripting Commands","Arma 2: Scripting Commands","Arma 3: Scripting Commands","Command Group: Object Detection","Introduced with Arma 2 version 1.00","Scripting Commands","Take On Helicopters: Scripting Commands"]}