{"name":"setAmmo","operator":null,"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","replaced_by":[],"games":[{"game":"arma3","name":"Arma 3","version":"0.50"}],"since":{"game":"arma3","name":"Arma 3","version":"0.50"},"arma3_since":"0.50","branch":null,"locality":{"argument":"local","effect":"global","server_exec":false},"exec":null,"description":"Sets custom ammo count in the currently loaded magazine of the specified weapon or muzzle.","syntaxes":[{"syntax":"unit setAmmo [weaponOrMuzzle, count]","since":null,"effect":null,"exec":null,"params":[{"name":"unit","type":"Object","optional":false,"default":null,"description":"gunner or vehicle.","types":["Object"],"since":null,"text":"unit: Object - gunner or vehicle."},{"name":"weaponOrMuzzle","type":"String","optional":false,"default":null,"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","types":["String"],"since":null,"text":"weaponOrMuzzle: String - weapon name. Muzzle name in case the weapon has more than one muzzle, e.g. weapon with grenade launcher. See CfgWeapons for muzzle names"},{"name":"count","type":"Number","optional":false,"default":null,"description":null,"types":["Number"],"since":null,"text":"count: Number"}],"returns":{"type":"Nothing","types":["Nothing"],"description":null,"text":"Nothing"},"form":"binary","operator":null,"left":{"text":"unit","types":["Object"]},"right":{"text":"[weaponOrMuzzle, count]","types":["Array"]}}],"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"]}],"multiplayer":null,"problems":null,"aliases":[],"see_also":["ammo","setVehicleAmmo","setFuel","setHit"],"notes":[],"categories":["Arma 3: New Scripting Commands","Arma 3: Scripting Commands","Command Group: Unit Inventory","Command Group: Vehicle Inventory","Introduced with Arma 3 version 0.50","Scripting Commands","Scripting Commands: Global Effect"]}