{"name":"agents","operator":null,"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","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":"Return a list of agents in the current mission.","syntaxes":[{"syntax":"agents","since":null,"effect":null,"exec":null,"params":[],"returns":{"type":"Array of Team Members","types":["Array","Team Member"],"description":null,"text":"Array of Team Members"},"form":"nullary","operator":null,"left":null,"right":null}],"examples":[{"text":"```sqf\n{ agent _x moveTo position player } forEach agents;\n```","code":["{ agent _x moveTo position player } forEach agents;"]},{"text":"```sqf\nagents apply {typeOf agent _x}; // [\"Snake_random_F\",\"Snake_random_F\",\"Snake_random_F\",\"Rabbit_F\"]\n```","code":["agents apply {typeOf agent _x}; // [\"Snake_random_F\",\"Snake_random_F\",\"Snake_random_F\",\"Rabbit_F\"]"]}],"multiplayer":null,"problems":null,"aliases":[],"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\n would return an error\n But you can assign the agent a reference using setVariable, and then reference it, for example: \n\n```sqf\n{ alive (_x getVariable [\"agentObject\", objNull]) } count agents;\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```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```"}],"categories":["Arma 2: New Scripting Commands","Arma 2: Operation Arrowhead: Scripting Commands","Arma 2: Scripting Commands","Arma 3: Scripting Commands","Command Group: Object Detection","Command Group: Teams","Introduced with Arma 2 version 1.00","Scripting Commands","Take On Helicopters: Scripting Commands"]}