{"name":"setAmmo","title":"setAmmo","type":"command","url":"https://community.bistudio.com/wiki/setAmmo","revid":369275,"updated":"2024-09-03T18:42:45Z","groups":["Unit Inventory","Vehicle Inventory"],"status":"ok","games":{"arma3":"0.50"},"since":"arma3 0.50","arma3_since":"0.50","locality":{"argument":"local","effect":"global"},"description":"Sets custom ammo count in the currently loaded magazine of the specified weapon or muzzle.","syntaxes":[{"syntax":"unit setAmmo [weaponOrMuzzle, count]","params":[{"name":"unit","type":"Object","description":"gunner or vehicle.","type_expr":"Object"},{"name":"weaponOrMuzzle","type":"String","description":"weapon name. Muzzle name in case the weapon has more than one muzzle, e.g. weapon with grenade launcher. See CfgWeapons for muzzle names","type_expr":"String"},{"name":"count","type":"Number","type_expr":"Number"}],"returns":{"type":"Nothing","type_expr":"Nothing"},"form":"binary","left":{"text":"unit"},"right":{"text":"[weaponOrMuzzle, count]"}}],"examples":[{"text":"Set player's handgun magazine ammo count to 10 rounds:\n\n```sqf\nplayer setAmmo [handgunWeapon player, 10];\n```","code":["player setAmmo [handgunWeapon player, 10];"]},{"text":"Set player's current weapon magazine ammo count to 1 round:\n\n```sqf\nplayer setAmmo [currentWeapon player, 1];\n```","code":["player setAmmo [currentWeapon player, 1];"]},{"text":"If player is a gunner in a vehicle, set current weapon magazine ammo count to 5 rounds:\n\n```sqf\nif (local vehicle player) then {\n    vehicle player setAmmo [currentWeapon vehicle player, 5];\n} else {\n    hint \"Vehicle must be local to this machine for 'setAmmo' to work\";\n};\n```","code":["if (local vehicle player) then {\n\tvehicle player setAmmo [currentWeapon vehicle player, 5];\n} else {\n\thint \"Vehicle must be local to this machine for 'setAmmo' to work\";\n};"]},{"text":"If you try to set more ammo than the magazine can hold, it will be clipped at default magazine capacity:\n\n```sqf\nplayer setAmmo [primaryWeapon player, 1000000]; // full mag with default ammo count\n```","code":["player setAmmo [primaryWeapon player, 1000000]; // full mag with default ammo count"]},{"text":"Some weapons has more than one muzzles:\n\n```sqf\n_marshall setAmmo [\"autocannon_40mm_CTWS\", 0];// won't work\n_marshall setAmmo [\"HE\", 0];// works\n```","code":["_marshall setAmmo [\"autocannon_40mm_CTWS\", 0];// won't work\n_marshall setAmmo [\"HE\", 0];// works"]}],"see_also":["ammo","setVehicleAmmo","setFuel","setHit"]}