setAmmo: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
mNo edit summary
m (Text replacement - "<sqf>([^↵][^<]*↵[^<]*)<\/sqf>" to "<sqf> $1 </sqf>")
 
(43 intermediate revisions by 4 users not shown)
Line 1: Line 1:
{{Command|Comments=
{{RV|type=command
____________________________________________________________________________________________


| arma3 |Game name=
|game1= arma3
|version1= 0.50


|0.50|Game version=
|arg= local


|arg= local |Multiplayer Arguments=
|eff= global


|eff= global |Multiplayer Effects=
|gr1= Unit Inventory


|gr1= Unit Inventory |GROUP1=
|gr2= Vehicle Inventory


|gr2= Vehicle Inventory |GROUP2=
|descr= Sets custom ammo count in the currently loaded magazine of the specified weapon or muzzle.
____________________________________________________________________________________________


| 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=
|s1= unit [[setAmmo]] [weaponOrMuzzle, count]
____________________________________________________________________________________________


| unit '''setAmmo''' [weapon, count] |SYNTAX=
|p1= unit: [[Object]] - gunner or vehicle.


|p1= unit: [[Object]] - Gunner or vehicle. |PARAMETER1=
|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


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


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


|p4= count: [[Number]]  |PARAMETER4=
|x1= Set player's handgun magazine ammo count to 10 rounds:
<sqf>player setAmmo [handgunWeapon player, 10];</sqf>


| [[Nothing]] |RETURNVALUE=
|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:
<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>


|x1= Set player's handgun magazine ammo count to 10 rounds:
<code>[[player]] [[setAmmo]] [<nowiki/>[[handgunWeapon]] [[player]], 10];</code>|EXAMPLE1=
|x2= Set player's current weapon magazine ammo count to 1 round:
<code>[[player]] [[setAmmo]] [<nowiki/>[[currentWeapon]] [[player]], 1];</code>|EXAMPLE2=
|x3= If player is a gunner in a vehicle, set current weapon magazine ammo count to 5 rounds:
<code>[[if]] ([[local]] [[vehicle]] [[player]]) [[then]] {
[[vehicle]] [[player]] [[setAmmo]] [<nowiki/>[[currentWeapon]] [[vehicle]] [[player]], 5];
} [[else]] {
[[hint]] "Vehicle must be local to this machine for 'setAmmo' to work";
};</code>|EXAMPLE3=
|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
<sqf>player setAmmo [primaryWeapon player, 1000000]; // full mag with default ammo count</sqf>
</code>|EXAMPLE4=
____________________________________________________________________________________________


| [[ammo]], [[setVehicleAmmo]], [[setFuel]], [[setHit]] |SEEALSO=
|x5= Some weapons has more than one muzzles:
<sqf>
_marshall setAmmo ["autocannon_40mm_CTWS", 0];// won't work
_marshall setAmmo ["HE", 0];// works
</sqf>


| |MPBEHAVIOUR=  
|seealso= [[ammo]] [[setVehicleAmmo]] [[setFuel]] [[setHit]]
____________________________________________________________________________________________
}}
}}
<h3 style='display:none'>Notes</h3>
<dl class='command_description'>
<!-- Note Section BEGIN -->
<!-- Note Section END -->
</dl>
<h3 style='display:none'>Bottom Section</h3>
[[Category:Arma_3:_New_Scripting_Commands_List|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands Arma 3|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands|{{uc:{{PAGENAME}}}}]]

Latest revision as of 19:42, 3 September 2024

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:
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:
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