{"name":"primaryWeaponMagazine","operator":null,"title":"primaryWeaponMagazine","type":"command","url":"https://community.bistudio.com/wiki/primaryWeaponMagazine","revid":377142,"updated":"2026-01-01T10:31:18Z","groups":["Unit Inventory"],"status":"ok","replaced_by":[],"games":[{"game":"arma3","name":"Arma 3","version":"0.70"}],"since":{"game":"arma3","name":"Arma 3","version":"0.70"},"arma3_since":"0.70","branch":null,"locality":{"argument":null,"effect":null,"server_exec":false},"exec":null,"description":"Collects all loaded magazines from all primaryWeapon muzzles and returns them in Array, otherwise it returns []. This command is used for infantry weapons only.","syntaxes":[{"syntax":"primaryWeaponMagazine 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 of Strings","types":["Array","String"],"description":null,"text":"Array of Strings"},"form":"unary","operator":null,"left":null,"right":{"text":"unit","types":["Object"]}}],"examples":[{"text":"```sqf\nhint str primaryWeaponMagazine player; //[\"30Rnd_65x39_caseless_mag\"]\n```","code":["hint str primaryWeaponMagazine player; //[\"30Rnd_65x39_caseless_mag\"]"]},{"text":"```sqf\n_array = primaryWeaponMagazine player;\nif (count _array > 0) then {\n    hint (\"Primary weapon is loaded with \" + (_array select 0) + \"!\");\n} else {\n    if (primaryWeapon player != \"\") then {\n        hint \"Primary weapon is not loaded!\";\n    } else {\n        hint \"Player doesn't have a primary weapon!\";\n    };\n};\n```","code":["_array = primaryWeaponMagazine player;\nif (count _array > 0) then {\n\thint (\"Primary weapon is loaded with \" + (_array select 0) + \"!\");\n} else {\n\tif (primaryWeapon player != \"\") then {\n\t\thint \"Primary weapon is not loaded!\";\n\t} else {\n\t\thint \"Player doesn't have a primary weapon!\";\n\t};\n};"]}],"multiplayer":null,"problems":null,"aliases":[],"see_also":["primaryWeapon","primaryWeaponItems","addPrimaryWeaponItem","removePrimaryWeaponItem","removeAllPrimaryWeaponItems","handgunMagazine","secondaryWeaponMagazine","binocularMagazine"],"notes":[{"user":"Pierre MGI","date":"2014-06-08T21:52:00Z","text":"This function returns an array like [\"type of magazine loaded in primary weapon\", \"type of grenade loaded in launcher if exist\"]\n\nFor example [\"30Rnd_556x45_Stanag\", \"1Rnd_HE_Grenade_shell\"], with no consideration about amount of these ammo.\n\nHowever, be careful if you intend to use it in expression like : (magazines _unit) - (primaryWeaponMagazine _unit), i.e. magazines \"minus\" this array,\n\nThe result will inventory all magazines (with grenades, chemlights...) except ALL magazines (and grenades eventually) belonging to the TYPE of the loaded one! i.e. you suppress ALL \"30Rnd_556x45_Stanag\" but the \"30Rnd_556x45_Stanag_Tracer_Green\" are still remaining.\n\nIf you kill the unit, the same expression will return a consistent inventory as primary weapon \"disappears\" and primaryWeaponMagazine is empty. \"30Rnd_556x45_Stanag\" are back!"}],"categories":["Arma 3: New Scripting Commands","Arma 3: Scripting Commands","Command Group: Unit Inventory","Introduced with Arma 3 version 0.70","Scripting Commands"]}