addMagazine: Difference between revisions

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


| ofp |= Game name
|game1= ofp
|version1= 1.00


|1.00|= Game version
|game2= ofpe
|version2= 1.00


|arg= local |= Arguments in MP
|game3= arma1
|version3= 1.00


|eff= global |= Effects in MP
|game4= arma2
____________________________________________________________________________________________
|version4= 1.00


| Add a magazine to a person. Infantry units can only carry a specific number of magazines, once the magazine slots are filled, any further addMagazine commands are ignored.<br><br>
|game5= arma2oa
|version5= 1.50


''Note:'' When you add a new weapon via scripting commands as well as the magazines for it, the '''addMagazine''' command has to be given ''before'' the [[addWeapon]] command, otherwise the weapon won't be loaded. <br><br>
|game6= tkoh
|version6= 1.00


{{Feature arma3|In Arma 3, the alternative variant of this command (addMagazine ARRAY) accepts global arguments {{EffArg|cmd|arg|glob}}, i.e. you can use it on the server to give remote unit a magazine with limited ammo. }}
|game7= arma3
|= Description
|version7= 0.50
____________________________________________________________________________________________


| unitName '''addMagazine''' magazineName |= Syntax
|gr1= Unit Inventory


|p1= unitName: [[Object]] - person to add the magazines to |= Parameter 1
|descr= Adds a magazine to a person. Infantry units can only carry a specific number of magazines, once the magazine slots are filled (or uniform/vest/bagpack are full in {{arma3}}), any further [[addMagazine]] commands are ignored.
If class of magazine does not exist, an error message is printed in {{Link|Crash Files|.rpt}}:
<sqf>player addMagazine "dasdsa"; // .rpt: Given magazine[dasdsa] not found</sqf>
{{Feature|informative|Use [[addMagazine]] ''before'' [[addWeapon]] for the weapon to be loaded with the magazine automatically.}}


|p2= magazineName: [[String]] - magazine name. See the topic [[:Category:Weapons]] for reference about possible values. |= Parameter 2
|s1= unitName [[addMagazine]] magazineName<br>
{{Icon|localArgument|32}}{{Icon|globalEffect|32}}


| [[Nothing]] |= Return value
|p1= unitName: [[Object]] - person to add the magazines to


|s2= unitName [[addMagazine]] [magazineName, ammo count]                     ''(Since Arma 2 OA 1.62)''|= Alternative Syntax
|p2= magazineName: [[String]] - magazine name. See the topic [[:Category:Weapons]] for reference about possible values.


|p21= unitName: [[Object]] - person to add the magazines to |= Alternative Parameter 1
|r1= [[Nothing]]


|p22= [magazineName, ammo count]: [[Array]]|= Alternative Parameter 2
|s2= unitName [[addMagazine]] [magazineName, ammoCount]<br>
{{GVI|arma2oa|1.62}} {{Icon|localArgument|32}}{{Icon|globalEffect|32}}<br>
{{GVI|arma3|1.00}} {{Icon|globalArgument|32}}{{Icon|globalEffect|32}}


|p23= magazineName: [[String]] - magazine name. See the topic [[:Category:Weapons]] for reference about possible values. |= Alternative Parameter 3
|s2since= arma2oa 1.62


|p24= ammo count: [[Number]] - Ammo quantity to be added to magazine.|= Alternative Parameter 4
|p21= unitName: [[Object]] - person to add the magazines to


|r2= [[Nothing]] |= Alternative Return value
|p22= magazineName: [[String]] - magazine name. See the topic [[:Category:Weapons]] for reference about possible values.
____________________________________________________________________________________________
 
|x1= <code>[[player]] [[addMagazine]] "30Rnd_556x45_STANAG";</code> |= Example 1
|x2= <code>[[player]] [[addMagazine]] ["30Rnd_556x45_STANAG", 15];</code> |= Example 2
____________________________________________________________________________________________


| [[addMagazineGlobal]], [[addMagazine_array]], [[addMagazines]], [[addMagazineCargo]], [[addMagazineCargoGlobal]], [[addMagazinePool]], [[addMagazineTurret]], [[removeMagazine]], [[removeMagazines]], [[addWeapon]]|= See also
|p23= ammoCount: [[Number]] - ammo quantity to be added to magazine. If it goes beyond maximum magazine capacity, the magazine will be given full and not overloaded.


}}
|r2= [[Nothing]]


<h3 style="display:none">Notes</h3>
|x1= <sqf>player addMagazine "30Rnd_556x45_STANAG";</sqf>
<dl class="command_description">
<!-- Note Section BEGIN -->


<dd class="notedate">Posted on August 2, 2006 - 06:59
|x2= <sqf>player addMagazine ["30Rnd_556x45_STANAG", 15]; // since {{Name|arma2oa|short}} 1.62</sqf>
<dt class="note">'''[[User:Hoz|Hoz]]'''<dd class="note">If the unit has magazines already, you may need to use the commands [[removeMagazine]] or [[removeMagazines]] to make space for the mags you want to add.


<dd class="notedate">Posted on September 11, 2007 - 15:39
|x3= <sqf>nonLocalUnit addMagazine ["30Rnd_556x45_STANAG", 15]; // global argument since {{arma3}}</sqf>
<dt class="note">'''[[User:Lester|Lester]]'''<dd class="note">The command doesn't stop adding magazines if the slots are full, it's possible do add much more magazines as slots are defined.
::This command no longer adds magazines if the unit magazine slots are filled in Arma 3. Version: 1.34.128075 --[[User:Patriot821|Patriot821]] (Posted on November 14, 2014 - 09:27 (UTC))


<dd class="notedate">Posted on February 21, 2010 - 20:13
|x4= <sqf>player addMagazine ["30Rnd_556x45_STANAG", 9999]; // will give a 30 rounds magazine anyway</sqf>
<dt class="note">'''[[User:Vigilante|Vigilante]]'''<dd class="note">In turreted vehicles the magazine is added to the first turret with >> primaryGunner = 1; << set in the Vehicles turret config part (and the magazine is ONLY added to the very first turret if more than one is configged with >> primaryGunner = 1; << ).


<dd class="notedate">Posted on May 12, 2010 - 20:09
|seealso= [[addMagazineGlobal]] [[addMagazines]] [[addMagazineCargo]] [[addMagazineCargoGlobal]] [[addMagazinePool]] [[addMagazineTurret]] [[removeMagazine]] [[removeMagazines]] [[addWeapon]] [[loadMagazine]]
<dt class="note">'''[[User:Inkompetent|Inkompetent]]'''<dd class="note">When wanting to add many magazines to an object's init-line it can be easier to use loops than to just repeat the addMagazine command.
}}


If you want to add N magazines to an object either of the two below ways are handy, the first for fewer magazines, and the latter when you want to add many since it then is the easiest of the two to read.
{{Note
<code>{this [[addMagazine]] "magazineClassName"} [[forEach]] [1,2,3,...,N];
|user= Hoz
[[for]] "_i" [[from]] 0 [[to]] (N - 1) [[do]] {this [[addMagazine]] "magazineClassName"};</code>
|timestamp= 20060802065900
<!-- Note Section END -->
|text=  If the unit has magazines already, you may need to use the commands [[removeMagazine]] or [[removeMagazines]] to make space for the mags you want to add.
</dl>
}}
 
{{Note
|user= PhilippRauch
|timestamp= 20100221201300
|text= In turreted vehicles the magazine is added to the first turret with >> primaryGunner = 1; << set in the Vehicles turret config part (and the magazine is ONLY added to the very first turret if more than one is configged with >> primaryGunner = 1; << ).
}}


<h3 style="display:none">Bottom Section</h3>
{{Note
|user= Inkompetent
|timestamp= 20100512200900
|text= When wanting to add many magazines to an object's init-line it can be easier to use loops than to just repeat the [[addMagazine]] command.


If you want to add N magazines to an object either of the two below ways are handy, the first for fewer magazines, and the latter when you want to add many since it then is the easiest of the two to read.
<sqf>
{ this addMagazine "magazineClassName" } forEach [1,2,3, /*..., */ N];
for "_i" from 1 to N do { this addMagazine "magazineClassName" };
</sqf>
}}


[[Category:Scripting Commands|ADDMAGAZINE]]
{{Note
[[Category:Scripting Commands OFP 1.99|ADDMAGAZINE]]
|user= Pisces_72
[[Category:Scripting Commands OFP 1.96|ADDMAGAZINE]]
|timestamp= 20171128131000
[[Category:Scripting Commands OFP 1.46|ADDMAGAZINE]]
|text= If adding a magazine to an empty artillery support with this command in Arma 3, use [[reload]]. If you do not reload, Artillery calls will not fire rounds, because the AI won't reload automatically (tested with 82mm mortar)
[[Category:Scripting Commands ArmA|ADDMAGAZINE]]
}}
[[Category:Command_Group:_Weapons|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands ArmA2|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands Arma 3|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting_Commands_Take_On_Helicopters|{{uc:{{PAGENAME}}}}]]

Latest revision as of 19:43, 3 September 2024

Hover & click on the images for description

Description

Description:
Adds a magazine to a person. Infantry units can only carry a specific number of magazines, once the magazine slots are filled (or uniform/vest/bagpack are full in Arma 3), any further addMagazine commands are ignored. If class of magazine does not exist, an error message is printed in .rpt:
player addMagazine "dasdsa"; // .rpt: Given magazine[dasdsa] not found
Use addMagazine before addWeapon for the weapon to be loaded with the magazine automatically.
Groups:
Unit Inventory

Syntax

Syntax:
unitName addMagazine magazineName
LALocalGEGlobal
Parameters:
unitName: Object - person to add the magazines to
magazineName: String - magazine name. See the topic Category:Weapons for reference about possible values.
Return Value:
Nothing

Alternative Syntax

Syntax:
unitName addMagazine [magazineName, ammoCount]
A2 OA Logo.png1.62 LALocalGEGlobal
Arma 3 logo black.png1.00 GAGlobalGEGlobal
Parameters:
unitName: Object - person to add the magazines to
magazineName: String - magazine name. See the topic Category:Weapons for reference about possible values.
ammoCount: Number - ammo quantity to be added to magazine. If it goes beyond maximum magazine capacity, the magazine will be given full and not overloaded.
Return Value:
Nothing

Examples

Example 1:
player addMagazine "30Rnd_556x45_STANAG";
Example 2:
player addMagazine ["30Rnd_556x45_STANAG", 15]; // since Arma 2:OA 1.62
Example 3:
nonLocalUnit addMagazine ["30Rnd_556x45_STANAG", 15]; // global argument since Arma 3
Example 4:
player addMagazine ["30Rnd_556x45_STANAG", 9999]; // will give a 30 rounds magazine anyway

Additional Information

See also:
addMagazineGlobal addMagazines addMagazineCargo addMagazineCargoGlobal addMagazinePool addMagazineTurret removeMagazine removeMagazines addWeapon loadMagazine

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
Hoz - c
Posted on Aug 02, 2006 - 06:59 (UTC)
If the unit has magazines already, you may need to use the commands removeMagazine or removeMagazines to make space for the mags you want to add.
PhilippRauch - c
Posted on Feb 21, 2010 - 20:13 (UTC)
In turreted vehicles the magazine is added to the first turret with >> primaryGunner = 1; << set in the Vehicles turret config part (and the magazine is ONLY added to the very first turret if more than one is configged with >> primaryGunner = 1; << ).
Inkompetent - c
Posted on May 12, 2010 - 20:09 (UTC)
When wanting to add many magazines to an object's init-line it can be easier to use loops than to just repeat the addMagazine command. If you want to add N magazines to an object either of the two below ways are handy, the first for fewer magazines, and the latter when you want to add many since it then is the easiest of the two to read.
{ this addMagazine "magazineClassName" } forEach [1,2,3, /*..., */ N]; for "_i" from 1 to N do { this addMagazine "magazineClassName" };
Pisces_72 - c
Posted on Nov 28, 2017 - 13:10 (UTC)
If adding a magazine to an empty artillery support with this command in Arma 3, use reload. If you do not reload, Artillery calls will not fire rounds, because the AI won't reload automatically (tested with 82mm mortar)