setAmmo: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
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 "")
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|Comments=
{{Command


| arma3 |Game name=
| arma3


|0.50|Game version=
|0.50


|arg= local |Multiplayer Arguments=
|arg= local


|eff= global |Multiplayer Effects=
|eff= global


|gr1= Unit Inventory |GROUP1=
|gr1= Unit Inventory


|gr2= Vehicle Inventory |GROUP2=
|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. |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.


| unit '''setAmmo''' [weapon, count] |SYNTAX=
| unit '''setAmmo''' [weapon, count]


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


|p2= [weapon, count]: [[Array]] |PARAMETER2=
|p2= [weapon, count]: [[Array]]


|p3= weapon: [[String]] |PARAMETER3=
|p3= weapon: [[String]]


|p4= count: [[Number]] |PARAMETER4=
|p4= count: [[Number]]


| [[Nothing]] |RETURNVALUE=
| [[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>|EXAMPLE1=
<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>|EXAMPLE2=
<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>|EXAMPLE3=
};</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>|EXAMPLE4=
</code>


| [[ammo]], [[setVehicleAmmo]], [[setFuel]], [[setHit]] |SEEALSO=
| [[ammo]], [[setVehicleAmmo]], [[setFuel]], [[setHit]]


| |MPBEHAVIOUR=
|
}}
}}



Revision as of 12:05, 18 January 2021

Hover & click on the images for description

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