setAmmo: Difference between revisions
m (Text replacement - "<h3 style='display:none'>Notes</h3> <dl class='command_description'> <!-- Note Section BEGIN -->  <!-- Note Section END --> </dl>  <h3 style='display:none'>Bottom Section</h3>" to "")  | 
				Lou Montana (talk | contribs)  m (Text replacement - " *\| *([Cc]omments|COMMENTS|Game|[Gg]ame [Nn]ame( +[0-9])?|Game [Vv]ersion( +[0-9])?|Game Version \(number surrounded by NO SPACES\)|Arguments in MP|MP[Aa]rg|Multiplayer Arguments( \("local" or "global"\))?|Effects|Execution|Effects...)  | 
				||
| Line 1: | Line 1: | ||
{{Command  | {{Command  | ||
| arma3   | | arma3  | ||
|0.50  | |0.50  | ||
|arg= local   | |arg= local  | ||
|eff= global   | |eff= global  | ||
|gr1= Unit Inventory   | |gr1= Unit Inventory  | ||
|gr2= Vehicle Inventory   | |gr2= Vehicle Inventory  | ||
| Sets custom ammo count in the currently loaded magazine of the specified weapon. The unit must be [[local]] to the computer where command is executed.   | | Sets custom ammo count in the currently loaded magazine of the specified weapon. The unit must be [[local]] to the computer where command is executed.  | ||
| unit '''setAmmo''' [weapon, count]   | | unit '''setAmmo''' [weapon, count]  | ||
|p1= unit: [[Object]] - Gunner or vehicle.   | |p1= unit: [[Object]] - Gunner or vehicle.  | ||
|p2= [weapon, count]: [[Array]]   | |p2= [weapon, count]: [[Array]]  | ||
|p3= weapon: [[String]]   | |p3= weapon: [[String]]  | ||
|p4= count: [[Number]]   | |p4= count: [[Number]]  | ||
| [[Nothing]]   | | [[Nothing]]  | ||
|x1= Set player's handgun magazine ammo count to 10 rounds:  | |x1= Set player's handgun magazine ammo count to 10 rounds:  | ||
<code>[[player]] [[setAmmo]] [<nowiki/>[[handgunWeapon]] [[player]], 10];</code>  | <code>[[player]] [[setAmmo]] [<nowiki/>[[handgunWeapon]] [[player]], 10];</code>  | ||
|x2= Set player's current weapon magazine ammo count to 1 round:  | |x2= Set player's current weapon magazine ammo count to 1 round:  | ||
<code>[[player]] [[setAmmo]] [<nowiki/>[[currentWeapon]] [[player]], 1];</code>  | <code>[[player]] [[setAmmo]] [<nowiki/>[[currentWeapon]] [[player]], 1];</code>  | ||
|x3= If player is a gunner in a vehicle, set current weapon magazine ammo count to 5 rounds:  | |x3= If player is a gunner in a vehicle, set current weapon magazine ammo count to 5 rounds:  | ||
<code>[[if]] ([[local]] [[vehicle]] [[player]]) [[then]] {  | <code>[[if]] ([[local]] [[vehicle]] [[player]]) [[then]] {  | ||
| Line 37: | Line 37: | ||
} [[else]] {  | } [[else]] {  | ||
	[[hint]] "Vehicle must be local to this machine for 'setAmmo' to work";  | 	[[hint]] "Vehicle must be local to this machine for 'setAmmo' to work";  | ||
};</code>  | };</code>  | ||
|x4= If you try to set more ammo than the magazine can hold, it will be clipped at default magazine capacity:  | |x4= If you try to set more ammo than the magazine can hold, it will be clipped at default magazine capacity:  | ||
<code>[[player]] [[setAmmo]] [<nowiki/>[[primaryWeapon]] [[player]], 1000000]; //full mag with default ammo count  | <code>[[player]] [[setAmmo]] [<nowiki/>[[primaryWeapon]] [[player]], 1000000]; //full mag with default ammo count  | ||
</code>  | </code>  | ||
| [[ammo]], [[setVehicleAmmo]], [[setFuel]], [[setHit]]   | | [[ammo]], [[setVehicleAmmo]], [[setFuel]], [[setHit]]  | ||
|   | |  | ||
}}  | }}  | ||
Revision as of 11:05, 18 January 2021
Description
- Description:
 - Sets custom ammo count in the currently loaded magazine of the specified weapon. The unit must be local to the computer where command is executed.
 - Groups:
 - Unit InventoryVehicle Inventory
 
Syntax
- Syntax:
 - unit setAmmo [weapon, count]
 - Parameters:
 - unit: Object - Gunner or vehicle.
 - [weapon, count]: Array
 - weapon: String
 - count: Number
 - Return Value:
 - Nothing
 
Examples
- Example 1:
 - Set player's handgun magazine ammo count to 10 rounds:
player setAmmo [handgunWeapon player, 10]; - Example 2:
 - Set player's current weapon magazine ammo count to 1 round:
player setAmmo [currentWeapon player, 1]; - Example 3:
 - If player is a gunner in a vehicle, set current weapon magazine ammo count to 5 rounds:
if (local vehicle player) then { vehicle player setAmmo [currentWeapon vehicle player, 5]; } else { hint "Vehicle must be local to this machine for 'setAmmo' to work"; }; - Example 4:
 - If you try to set more ammo than the magazine can hold, it will be clipped at default magazine capacity:
player setAmmo [primaryWeapon player, 1000000]; //full mag with default ammo count 
Additional Information
- See also:
 - ammosetVehicleAmmosetFuelsetHit
 
Notes
- 
Report bugs on the Feedback Tracker and/or discuss them on the Arma Discord or on the Forums.
Only post proven facts here! Add Note