BIS fnc addWeapon: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
No edit summary
m (template:command argument fix)
Line 9: Line 9:


| Adds a weapon to the specified unit, with magazine classnames taken from the weapon's config (in CfgWeapons).
| Adds a weapon to the specified unit, with magazine classnames taken from the weapon's config (in CfgWeapons).
This function does not remove magazines nor weapons prior to adding the new weapon, so that still has to be done manually. |= Description
This function does not remove magazines nor weapons prior to adding the new weapon, so that still has to be done manually. |DESCRIPTION=
____________________________________________________________________________________________
____________________________________________________________________________________________


| [unit, "weaponClassName", 1, ''0''] call '''BIS_fnc_addWeapon''';|= Syntax
| [unit, "weaponClassName", 1, ''0''] call '''BIS_fnc_addWeapon''';|SYNTAX=


|p1= [[Object]] - Unit to add weapon to. |=  
|p1= [[Object]] - Unit to add weapon to. |=  
Line 21: Line 21:
''Optional parameter, default 0. Found in magazines={} array.'' |=
''Optional parameter, default 0. Found in magazines={} array.'' |=


| [[String]] - Primary'''(!)''' muzzle name of weapon. |= Return value
| [[String]] - Primary'''(!)''' muzzle name of weapon. |RETURNVALUE=
____________________________________________________________________________________________
____________________________________________________________________________________________


Line 29: Line 29:
____________________________________________________________________________________________
____________________________________________________________________________________________


| [[addWeapon]], [[selectWeapon]] |= See also
| [[addWeapon]], [[selectWeapon]] |SEEALSO=


}}
}}

Revision as of 12:26, 7 April 2019


Hover & click on the images for description

Description

Description:
Adds a weapon to the specified unit, with magazine classnames taken from the weapon's config (in CfgWeapons). This function does not remove magazines nor weapons prior to adding the new weapon, so that still has to be done manually.
Execution:
call
Groups:
Uncategorised

Syntax

Syntax:
[unit, "weaponClassName", 1, 0] call BIS_fnc_addWeapon;
Parameters:
Object - Unit to add weapon to.
String - Weapon Classname (found in CfgWeapons).
Number - Amount of magazines.
Number - Index of magazine name that should be used, OR:
String - Magazine name to be used.
Optional parameter, default 0. Found in magazines={} array.
Return Value:
String - Primary(!) muzzle name of weapon.

Examples

Example 1:
newGun = [player, "arifle_SDAR_F", 6] call BIS_fnc_addWeapon; // Adds 6 dual-purpose magazines and the underwater gun to the player.
Example 2:
newGun = [bluforUnit, "arifle_Mk20_F", 2, 1] call BIS_fnc_addWeapon; // Adds 2 30 Rnd Stanag Tracer (Red) magazines to bluforUnit, with an Mk20_F.
Example 3:
newGun = [player, "arifle_Mk20_F", 2, "30Rnd_556x45_Stanag_Tracer_red"] call BIS_fnc_addWeapon; // Alternative syntax of second example, with magazine name written out.

Additional Information

See also:
addWeaponselectWeapon

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

Notes

Bottom Section

Posted on September 29, 2014 - 18:13 (UTC)
Tryteyker-
This function only returns the primary muzzle name of a gun. For more info on how to select guns' secondary muzzle names (like an underhand grenade launcher), view the notes on selectWeapon.