setAmmo: Difference between revisions
Jump to navigation
Jump to search
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...) |
Lou Montana (talk | contribs) m (Text replacement - "<sqf>([^↵][^<]*↵[^<]*)<\/sqf>" to "<sqf> $1 </sqf>") |
||
(37 intermediate revisions by 4 users not shown) | |||
Line 1: | Line 1: | ||
{{ | {{RV|type=command | ||
| arma3 | |game1= arma3 | ||
|version1= 0.50 | |||
|0.50 | |||
|arg= local | |arg= local | ||
Line 13: | Line 12: | ||
|gr2= Vehicle Inventory | |gr2= Vehicle Inventory | ||
| Sets custom ammo count in the currently loaded magazine of the specified weapon | |descr= Sets custom ammo count in the currently loaded magazine of the specified weapon or muzzle. | ||
| unit | |s1= unit [[setAmmo]] [weaponOrMuzzle, count] | ||
|p1= unit: [[Object]] - | |p1= unit: [[Object]] - gunner or vehicle. | ||
|p2= [weapon, | |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= | |p3= count: [[Number]] | ||
| | |r1= [[Nothing]] | ||
| [ | |x1= Set player's handgun magazine ammo count to 10 rounds: | ||
<sqf>player setAmmo [handgunWeapon player, 10];</sqf> | |||
|x2= Set player's current weapon magazine ammo count to 1 round: | |||
<sqf>player setAmmo [currentWeapon player, 1];</sqf> | |||
|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: | ||
< | <sqf> | ||
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"; | ||
}; | |||
</sqf> | |||
|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: | ||
< | <sqf>player setAmmo [primaryWeapon player, 1000000]; // full mag with default ammo count</sqf> | ||
</ | |||
| [ | |x5= Some weapons has more than one muzzles: | ||
<sqf> | |||
_marshall setAmmo ["autocannon_40mm_CTWS", 0];// won't work | |||
_marshall setAmmo ["HE", 0];// works | |||
</sqf> | |||
| | |seealso= [[ammo]] [[setVehicleAmmo]] [[setFuel]] [[setHit]] | ||
}} | }} | ||
Latest revision as of 19:42, 3 September 2024
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:
- Example 2:
- Set player's current weapon magazine ammo count to 1 round:
- Example 3:
- If player is a gunner in a vehicle, set current weapon magazine ammo count to 5 rounds:
- Example 4:
- If you try to set more ammo than the magazine can hold, it will be clipped at default magazine capacity:
- 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:
- ammo setVehicleAmmo setFuel setHit
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