setAmmo: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
(Muzzle important note, Example 5)
m (formatting)
Line 1: Line 1:
{{RV|type=command
{{RV|type=command


| arma3
|game1= arma3


|0.50
|version1= 0.50


|arg= local
|arg= local
Line 13: Line 13:
|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.
|descr= Sets custom ammo count in the currently loaded magazine of the specified weapon or muzzle.
{{Feature|important|The command takes a muzzleName instead of weaponName, if the weapon has more than one muzzles. (Example 5)
* For muzzle names see [[:Category:Weapons|CfgWeapons]].}}


| unit '''setAmmo''' [weapon, count]
|s1= unit '''setAmmo''' [weaponOrMuzzle, count]


|p1= unit: [[Object]] - Gunner or vehicle.
|p1= unit: [[Object]] - Gunner or vehicle.


|p2= [weapon, count]: [[Array]]
|p2= weaponOrMuzzle: [[String]] - Weapon name. Muzzle name in case the weapon has more than one muzzle, e.g. weapon with grenade launcher. See [[:Category:Weapons|CfgWeapons]] for muzzle names


|p3= weapon: [[String]]
|p3= count: [[Number]]


|p4= count: [[Number]]
|r1= [[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 39: Line 37:
[[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]; {{cc|full mag with default ammo count}}
<code>[[player]] [[setAmmo]] [<nowiki/>[[primaryWeapon]] [[player]], 1000000]; {{cc|full mag with default ammo count}}</code>
</code>
 
|x5= Some weapons has more than one muzzles:
|x5= Some weapons has more than one muzzles:
<code>_marshall [[setAmmo]] ["autocannon_40mm_CTWS", 0];{{cc|won't work}}
<code>_marshall [[setAmmo]] ["autocannon_40mm_CTWS", 0];{{cc|won't work}}
_marshall [[setAmmo]] ["HE", 0];{{cc|works}}
_marshall [[setAmmo]] ["HE", 0];{{cc|works}}</code>
</code>


|seealso= [[ammo]], [[setVehicleAmmo]], [[setFuel]], [[setHit]]
|seealso= [[ammo]], [[setVehicleAmmo]], [[setFuel]], [[setHit]]
}}
}}
{{GameCategory|arma3|New Scripting Commands}}
{{GameCategory|arma3|Scripting Commands}}
[[Category:Scripting Commands|{{uc:{{PAGENAME}}}}]]

Revision as of 10:36, 24 March 2021

Hover & click on the images for description

Description

Description:
Sets custom ammo count in the currently loaded magazine of the specified weapon or muzzle.
Groups:
Unit InventoryVehicle Inventory

Syntax

Syntax:
unit setAmmo [weaponOrMuzzle, count]
Parameters:
unit: Object - Gunner or vehicle.
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
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
Example 5:
Some weapons has more than one muzzles: _marshall setAmmo ["autocannon_40mm_CTWS", 0];// won't work _marshall setAmmo ["HE", 0];// works

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