setAmmo: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - "\| *((\[\[[a-zA-Z0-9_ |()]+\]\],? ?)+) * \}\}" to "|seealso= $1 }}")
(Muzzle important note, Example 5)
Line 14: Line 14:


| 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.
{{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]
| unit '''setAmmo''' [weapon, count]
Line 38: Line 40:
};</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]; {{cc|full mag with default ammo count}}
</code>
|x5= Some weapons has more than one muzzles:
<code>_marshall [[setAmmo]] ["autocannon_40mm_CTWS", 0];{{cc|won't work}}
_marshall [[setAmmo]] ["HE", 0];{{cc|works}}
</code>
</code>



Revision as of 06:23, 24 March 2021

Hover & click on the images for description

Description

Description:
Description needed
Groups:
Unit InventoryVehicle Inventory

Syntax

Syntax:
Syntax needed
Parameters:
unit: Object - Gunner or vehicle.
[weapon, count]: Array
weapon: String
count: Number
Return Value:
Return value needed

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