{"name":"weaponState","operator":null,"title":"weaponState","type":"command","url":"https://community.bistudio.com/wiki/weaponState","revid":378932,"updated":"2026-08-19T22:08:00Z","groups":["Weapons"],"status":"ok","replaced_by":[],"games":[{"game":"arma2oa","name":"Arma 2: Operation Arrowhead","version":"1.60"},{"game":"tkoh","name":"Take On Helicopters","version":"1.00"},{"game":"arma3","name":"Arma 3","version":"0.50"}],"since":{"game":"arma2oa","name":"Arma 2: Operation Arrowhead","version":"1.60"},"arma3_since":"0.50","branch":null,"locality":{"argument":null,"effect":null,"server_exec":false},"exec":null,"description":"Returns the given or currently selected weapon state for unit or vehicle.\nWith #Syntax 2, if no optional arguments are present, currently selected weapon is queried.\n\n> [!NOTE]\n> **Arma 3:** Since Arma 3 v1.70 this command has been improved and extended:\n> - A vehicle's weapon query doesn't need a weapon operator provided the weapon or muzzle is specified in optional param.\n> (keep in mind that by default a vehicle has no weapons selected)\n> - Driver turret can now be accessed as well with turret path [-1].\n> - Muzzle name is supported as well as weapon name. The command searches for weapon first, then if not found, muzzle is searched for.","syntaxes":[{"syntax":"weaponState unit","since":null,"effect":null,"exec":null,"params":[{"name":"unit","type":"Object","optional":false,"default":null,"description":null,"types":["Object"],"since":null,"text":"unit: Object"}],"returns":{"type":"Array with [weapon, muzzle, firemode, magazine, ammoCount, roundReloadPhase, magazineReloadPhase]","types":["Array"],"description":"weapon: String - muzzle: String - firemode: String - magazine: String - ammoCount: Number - Arma 3 v2.06 roundReloadPhase: Number in range -1 or 0..1 - current ammo round reload phase (see weaponReloadingTime). -1 when weapon has magazine removed - Arma 3 v2.06 magazineReloadPhase: Number in range 1..0 - current magazine reload phase, 0 - reload complete. > 0 - reload in progress","text":"Array with [weapon, muzzle, firemode, magazine, ammoCount, roundReloadPhase, magazineReloadPhase]\n- weapon: String\n- muzzle: String\n- firemode: String\n- magazine: String\n- ammoCount: Number\n- Arma 3 v2.06 roundReloadPhase: Number in range -1 or 0..1 - current ammo round reload phase (see weaponReloadingTime). -1 when weapon has magazine removed\n- Arma 3 v2.06 magazineReloadPhase: Number in range 1..0 - current magazine reload phase, 0 - reload complete. > 0 - reload in progress"},"form":"unary","operator":null,"left":null,"right":{"text":"unit","types":["Object"]}},{"syntax":"weaponState [vehicle, turretPath, weapon, muzzle, firemode]","since":null,"effect":null,"exec":null,"params":[{"name":"vehicle","type":"Object","optional":false,"default":null,"description":null,"types":["Object"],"since":null,"text":"vehicle: Object"},{"name":"turretPath","type":"Turret Path","optional":false,"default":null,"description":null,"types":["Turret Path"],"since":null,"text":"turretPath: Turret Path"},{"name":"weapon","type":"String","optional":true,"default":"`\"\"`","description":"weapon or muzzle name","types":["String"],"since":"arma3 1.70","text":"weapon: String - (Optional, default `\"\"`) weapon or muzzle name"},{"name":"muzzle","type":"String","optional":true,"default":"`\"\"`","description":"muzzle name","types":["String"],"since":"arma3 2.08","text":"muzzle: String - (Optional, default `\"\"`) muzzle name"},{"name":"firemode","type":"String","optional":true,"default":"`\"\"`","description":"firemode name","types":["String"],"since":"arma3 2.08","text":"firemode: String - (Optional, default `\"\"`) firemode name"}],"returns":{"type":"Array with [weapon, muzzle, firemode, magazine, ammoCount, roundReloadPhase, magazineReloadPhase]","types":["Array"],"description":"weapon: String - muzzle: String - firemode: String - magazine: String - ammoCount: Number - Arma 3 v2.06 roundReloadPhase: Number - current ammo round reload phase (see weaponReloadingTime) - Arma 3 v2.06 magazineReloadPhase: Number - current magazine reload phase from 1 to 0, 0 - reload complete. > 0 - reload in progress","text":"Array with [weapon, muzzle, firemode, magazine, ammoCount, roundReloadPhase, magazineReloadPhase]\n- weapon: String\n- muzzle: String\n- firemode: String\n- magazine: String\n- ammoCount: Number\n- Arma 3 v2.06 roundReloadPhase: Number - current ammo round reload phase (see weaponReloadingTime)\n- Arma 3 v2.06 magazineReloadPhase: Number - current magazine reload phase from 1 to 0, 0 - reload complete. > 0 - reload in progress"},"form":"unary","operator":null,"left":null,"right":{"text":"[vehicle, turretPath, weapon, muzzle, firemode]","types":["Array"]}},{"syntax":"unit weaponState weaponOrMuzzle","since":"arma3 2.06","effect":null,"exec":null,"params":[{"name":"unit","type":"Object","optional":false,"default":null,"description":null,"types":["Object"],"since":null,"text":"unit: Object"},{"name":"weaponOrMuzzle","type":"String","optional":false,"default":null,"description":null,"types":["String"],"since":null,"text":"weaponOrMuzzle: String"}],"returns":{"type":"Array with [weapon, muzzle, firemode, magazine, ammoCount, roundReloadPhase, magazineReloadPhase]","types":["Array"],"description":"weapon: String - muzzle: String - firemode: String - magazine: String - ammoCount: Number - Arma 3 v2.06 roundReloadPhase: Number - current ammo round reload phase (see weaponReloadingTime) - Arma 3 v2.06 magazineReloadPhase: Number - current magazine reload phase from 1 to 0, 0 - reload complete. > 0 - reload in progress","text":"Array with [weapon, muzzle, firemode, magazine, ammoCount, roundReloadPhase, magazineReloadPhase]\n- weapon: String\n- muzzle: String\n- firemode: String\n- magazine: String\n- ammoCount: Number\n- Arma 3 v2.06 roundReloadPhase: Number - current ammo round reload phase (see weaponReloadingTime)\n- Arma 3 v2.06 magazineReloadPhase: Number - current magazine reload phase from 1 to 0, 0 - reload complete. > 0 - reload in progress"},"form":"binary","operator":null,"left":{"text":"unit","types":["Object"]},"right":{"text":"weaponOrMuzzle","types":["String"]}}],"examples":[{"text":"```sqf\n_wsPlayer = weaponState player;                    // [\"arifle_MXC_ACO_F\",\"arifle_MXC_ACO_F\",\"Single\",\"30Rnd_65x39_caseless_mag\",30,0,0]\n```","code":["_wsPlayer = weaponState player;\t\t\t\t\t// [\"arifle_MXC_ACO_F\",\"arifle_MXC_ACO_F\",\"Single\",\"30Rnd_65x39_caseless_mag\",30,0,0]"]},{"text":"Query currently selected gunner weapon:\n\n```sqf\n_wsVehicle = weaponState [_apc, [0]];            // [\"autocannon_40mm_CTWS\",\"HE\",\"player\",\"60Rnd_40mm_GPR_Tracer_Red_shells\",60,0,0]\n```","code":["_wsVehicle = weaponState [_apc, [0]];\t\t\t// [\"autocannon_40mm_CTWS\",\"HE\",\"player\",\"60Rnd_40mm_GPR_Tracer_Red_shells\",60,0,0]"]},{"text":"```sqf\n_wsVehicle = weaponState [_apc, [0], \"AP\"];        // [\"autocannon_40mm_CTWS\",\"AP\",\"player\",\"40Rnd_40mm_APFSDS_Tracer_Red_shells\",40,0,0]\n```","code":["_wsVehicle = weaponState [_apc, [0], \"AP\"];\t\t// [\"autocannon_40mm_CTWS\",\"AP\",\"player\",\"40Rnd_40mm_APFSDS_Tracer_Red_shells\",40,0,0]"]},{"text":"```sqf\n_wsPlayer = player weaponState \"GL_3GL_F\";        // [\"arifle_MX_GL_ACO_F\",\"GL_3GL_F\",\"Single\",\"1Rnd_HE_Grenade_shell\",1,0,0]\n```","code":["_wsPlayer = player weaponState \"GL_3GL_F\";\t\t// [\"arifle_MX_GL_ACO_F\",\"GL_3GL_F\",\"Single\",\"1Rnd_HE_Grenade_shell\",1,0,0]"]}],"multiplayer":null,"problems":null,"aliases":[],"see_also":["weapons","selectWeaponTurret","loadMagazine","magazinesTurret","weaponsTurret","weaponReloadingTime"],"notes":[{"user":"AgentRev","date":"2022-03-31T04:08:09Z","text":"In the case of a GL rifle, if the rifle is currently in GL mode, syntax 3 will return the same result for either muzzle:\n\n```sqf\nplayer selectWeapon \"GL_3GL_F\";\n_state = player weaponState \"arifle_MX_GL_ACO_F\";    // [\"arifle_MX_GL_ACO_F\",\"GL_3GL_F\",\"Single\",\"1Rnd_HE_Grenade_shell\",1,0,0]\n_state = player weaponState \"GL_3GL_F\";                // [\"arifle_MX_GL_ACO_F\",\"GL_3GL_F\",\"Single\",\"1Rnd_HE_Grenade_shell\",1,0,0]\n```\n\nIn rifle mode, the result is different:\n\n```sqf\nplayer selectWeapon \"arifle_MX_GL_ACO_F\";\n_state = player weaponState \"arifle_MX_GL_ACO_F\";    // [\"arifle_MX_GL_ACO_F\",\"arifle_MX_GL_ACO_F\",\"Single\",\"30Rnd_65x39_caseless_mag\",30,0,0]\n_state = player weaponState \"GL_3GL_F\";                // [\"arifle_MX_GL_ACO_F\",\"GL_3GL_F\",\"Single\",\"1Rnd_HE_Grenade_shell\",1,0,0]\n```\n\nTherefore, in order to gather all states of one multi-muzzle weapon, we have to do some masochistic stuff:\n\n```sqf\nfn_getWeaponStates =\n{\n    params [\"_unit\", \"_weapon\"];\n    private _origState = weaponState _unit select [0,3];\n    private _muzzles = [_weapon] + (getArray (configFile >> \"CfgWeapons\" >> _weapon >> \"muzzles\") select { _x != \"this\" });\n    private _states = [];\n\n    {\n        _unit selectWeapon _x;\n        _states pushBack weaponState _unit;\n    } forEach _muzzles;\n\n    _unit selectWeapon _origState;\n    _states;\n};\n\nprivate _result = [player, primaryWeapon player] call fn_getWeaponStates;\n/*\n    [\n        [\"arifle_MX_GL_ACO_F\", \"arifle_MX_GL_ACO_F\", \"Single\", \"30Rnd_65x39_caseless_mag\", 30, 0, 0],\n        [\"arifle_MX_GL_ACO_F\", \"GL_3GL_F\", \"Single\", \"1Rnd_HE_Grenade_shell\", 1, 0, 0]\n    ]\n*/\n```"}],"categories":["Arma 2: Operation Arrowhead: New Scripting Commands","Arma 2: Operation Arrowhead: Scripting Commands","Arma 3: Scripting Commands","Command Group: Weapons","Introduced with Arma 2: Operation Arrowhead version 1.60","Scripting Commands","Take On Helicopters: Scripting Commands"]}