{"name":"agents","title":"agents","type":"command","url":"https://community.bistudio.com/wiki/agents","revid":378915,"updated":"2026-08-12T19:46:48Z","groups":["Teams","Object Detection"],"status":"ok","games":{"arma2":"1.00","arma2oa":"1.50","tkoh":"1.00","arma3":"0.50"},"since":"arma2 1.00","arma3_since":"0.50","description":"Return a list of agents in the current mission.","syntaxes":[{"syntax":"agents","params":[],"returns":{"type":"Array of Team Members","type_expr":"Array<Team Member>"},"form":"nullary"}],"examples":[{"code":["{ agent _x moveTo position player } forEach agents;"]},{"code":["agents apply {typeOf agent _x}; // [\"Snake_random_F\",\"Snake_random_F\",\"Snake_random_F\",\"Rabbit_F\"]"]}],"see_also":["teams","agent","createAgent","isAgent","forEachMemberAgent","entities","allCurators","allGroups","allDead","playableUnits","switchableUnits","vehicles","allUnitsUAV","allDeadMen"],"notes":[{"user":"Rocket","date":"2012-04-04T10:48:00Z","text":"Note that agents returns a reference to the agent itself, not the object. For example:\n\n```sqf\n{ alive _x } count agents;\n```\n\nwould return an error\n\n```\nBut you can assign the agent a reference using setVariable, and then reference it, for example:\n```\n\n```sqf\n{ alive (_x getVariable [\"agentObject\", objNull]) } count agents;\n```\n\n```\n would return the number of agents still alive - BUT you would need to define \"agentObject\" after you create the agent, for example:\n```\n\n```sqf\n_agent = createAgent [_type, _position, [], _radius, \"NONE\"];_agent setVariable[\"agentObject\",_agent,true];\n```"},{"user":"Killzone_Kid","date":"2013-08-01T21:55:00Z","text":"Alternatively, to get object from agent reference use agent command."},{"user":"PierreMGI","date":"2020-05-26T14:10:00Z","text":"In debug console, pointing at an agent:\n\n```sqf\ncursorObject;                                            // seems to refer to an agent (ex.: Agent 0xcbce41c0), but it is an object\nteamMember cursorObject;                                // returns the same value Agent 0xcbce41c0, but now it is the agent\ncursorObject in agents;                                    // will return false (even if you can read the value Agent 0xcbce41c0 in the agents array)\nteamMember cursorObject in agents;                        // returns true. TeamMember allows to refer to the agent under the cursorObject\nagent teamMember cursorObject isEqualTo cursorObject;    // true, same object.\n```"}]}