BIS fnc addWeapon: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - "|= |p4=" to "|PARAMETER3= |p4=")
Line 8: Line 8:
____________________________________________________________________________________________
____________________________________________________________________________________________


| 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 [[:Category:Weapons|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, quantity, type] call [[BIS_fnc_addWeapon]] |SYNTAX=


|p1= [[Object]] - Unit to add weapon to. |Parameter1=
|p1= unit: [[Object]] - Unit to add weapon to. |Parameter1=


|p2= [[String]] - Weapon Classname (found in CfgWeapons). |Parameter2=
|p2= weaponClassName: [[String]] - Weapon Classname (found in [[:Category:Weapons|CfgWeapons]]). |Parameter2=


|p3= [[Number]] - Amount of magazines. |PARAMETER3=
|p3= quantity: [[Number]] - Amount of magazines. |PARAMETER3=


|p4= ''[[Number]] - Index of magazine name that should be used, OR:''<br>
|p4= type: [[Number]] or [[String]] - (Optional, default 0)
''[[String]] - Magazine name to be used.''<br>
* [[Number]] - Index of magazine name that should be used - found in {{Inline code|magazines {{=}} {}<nowiki/>}} array.
''Optional parameter, default 0. Found in magazines={} array.'' |=
* [[String]] - Magazine name to be used.
|Parameter4=


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


|x1= <code>newGun = [player, "arifle_SDAR_F", 6] call BIS_fnc_addWeapon; // Adds 6 dual-purpose magazines and the underwater gun to the player.</code> |Example1=
|x1= Add 6 dual-purpose magazines and the underwater gun to the player:
<code>newGun = [<nowiki/>[[player]], "arifle_SDAR_F", 6] [[call]] [[BIS_fnc_addWeapon]];</code> |Example1=


|x2= <code>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.</code> |Example2=
|x2= Adds 2 &times; 30 Rnd Stanag Tracer (Red) magazines to bluforUnit, with an Mk20_F:
|x3= <code>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.</code> |=
<code>newGun = [bluforUnit, "arifle_Mk20_F", 2, 1] [[call]] [[BIS_fnc_addWeapon]];</code> |Example2=
 
|x3= Alternative syntax of second example, with magazine name written out:
<code>newGun = [bluforUnit, "arifle_Mk20_F", 2, "30Rnd_556x45_Stanag_Tracer_red"] [[call]] [[BIS_fnc_addWeapon]];</code> |Example3=
____________________________________________________________________________________________
____________________________________________________________________________________________


| [[addWeapon]], [[selectWeapon]] |SEEALSO=
| [[addWeapon]], [[selectWeapon]] |SEEALSO=
}}
}}



Revision as of 00:01, 22 December 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, quantity, type] call BIS_fnc_addWeapon
Parameters:
unit: Object - Unit to add weapon to.
weaponClassName: String - Weapon Classname (found in CfgWeapons).
quantity: Number - Amount of magazines.
type: Number or String - (Optional, default 0)
  • Number - Index of magazine name that should be used - found in magazines = {} array.
  • String - Magazine name to be used.
Return Value:
String - Primary(!) muzzle name of weapon.

Examples

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

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.