BIS fnc addWeapon: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (1 revision)
(Added examples, proper syntax, and parameters.)
Line 8: Line 8:
____________________________________________________________________________________________
____________________________________________________________________________________________


| <pre>/*
| Adds a weapon to the specified unit, with magazine classnames taken from the weapon's config (in CfgWeapons).
File: addWeapon.sqf
This function does not remove magazines nor weapons prior to adding the new weapon, so that still has to be done manually. |= Description
Description:
Add a weapon to a unit with the right magazines. Magazine class is fetched from the weapon's config.
Parameter(s):
_this select 0: <object> unit that is issued new equipment
_this select 1: <string> weapon classname
_this select 2: <scalar> number of magazines
_this select 3 (Optional): <scalar> index of magazine class in weapon's config (default 0) OR <string> magazine classname
Returns:
Primary muzzle name for a followup selectWeapon.
How to use:
_muzzle = [player, "arifle_SDAR_F", 6] call BIS_fnc_addWeapon;
Equips the player with an underwater rifle and six dual purpose magazines.
_muzzle = [player, "arifle_SDAR_F", 6, 1] call BIS_fnc_addWeapon;
OR
_muzzle = [player, "arifle_SDAR_F", 6, "30Rnd_556x45_Stanag"] call BIS_fnc_addWeapon;
Equips the player with an underwater rifle and six normal magazines.
*/
 
</pre><small>''(Placeholder description extracted from the function header by [[BIS_fnc_exportFunctionsToWiki]])''</small> |= Description
____________________________________________________________________________________________
____________________________________________________________________________________________


| <!-- [] call [[BIS_fnc_addWeapon]]; --> |= Syntax
| [unit, "weaponClassName", 1, ''0''] call '''BIS_fnc_addWeapon''';|= Syntax


|p1= |= Parameter 1
|p1= [[Object]] - Unit to add weapon to. |=
|p2= [[String]] - Weapon Classname (found in CfgWeapons). |=
|p3= [[Number]] - Amount of magazines. |=
|p4= ''[[Number]] - Index of magazine name that should be used, OR:''<br>
''[[String]] - Magazine name to be used.''<br>
''Optional parameter, default 0. Found in magazines={} array.'' |=


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


|x1= <code></code> |=  
|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> |=
|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> |=
|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> |=
____________________________________________________________________________________________
____________________________________________________________________________________________


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


}}
}}

Revision as of 19:09, 29 September 2014


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