BIS fnc addWeapon: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (1 revision)
m (Text replacement - "(\|[pr][0-9]+ *= *[^- ]*) *- *W([a-z ])" to "$1 - w$2")
 
(51 intermediate revisions by 4 users not shown)
Line 1: Line 1:
{{RV|type=function


{{Function|= Comments
|game1= arma3
____________________________________________________________________________________________
|version1= 1.00


| arma3 |= Game name
|gr1= Inventory


|1.00|= Game version
|gr2= Weapons
____________________________________________________________________________________________


| <pre>/*
|descr= Adds a weapon to the specified unit, with magazine classnames taken from the weapon's config (in [[:Category:Weapons|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:
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
|s1= [unit, weaponClassName, quantity, type] call [[BIS_fnc_addWeapon]]
____________________________________________________________________________________________


| <!-- [] call [[BIS_fnc_addWeapon]]; --> |= Syntax
|p1= unit: [[Object]] - unit to add weapon to.


|p1= |= Parameter 1
|p2= weaponClassName: [[String]] - weapon Classname (found in [[:Category:Weapons|CfgWeapons]]).


| |= Return value
|p3= quantity: [[Number]] - amount of magazines.
____________________________________________________________________________________________


|x1= <code></code> |=
|p4= type: [[Number]] or [[String]] - (Optional, default 0)
____________________________________________________________________________________________
* [[Number]] - Index of magazine name that should be used - found in <syntaxhighlight lang="cpp" inline>magazines = {}</syntaxhighlight> array.
* [[String]] - Magazine name to be used.


| |= See also
|r1= [[String]] - primary'''(!)''' muzzle name of weapon.


}}
|x1= Add 6 dual-purpose magazines and the underwater gun to the player:
<sqf>[player, "arifle_SDAR_F", 6] call BIS_fnc_addWeapon;</sqf>
 
|x2= Adds 2 &times; 30 Rnd Stanag Tracer (Red) magazines to bluforUnit, with an Mk20_F:
<sqf>[bluforUnit, "arifle_Mk20_F", 2, 1] call BIS_fnc_addWeapon;</sqf>


<h3 style="display:none">Notes</h3>
|x3= Alternative syntax of second example, with magazine name written out:
<dl class="command_description">
<sqf>[bluforUnit, "arifle_Mk20_F", 2, "30Rnd_556x45_Stanag_Tracer_red"] call BIS_fnc_addWeapon;</sqf>
<!-- Note Section BEGIN -->


<!-- Note Section END -->
|seealso= [[addWeapon]] [[selectWeapon]]
</dl>
}}


<h3 style="display:none">Bottom Section</h3>
{{Note
[[Category:Function Group: Inventory|{{uc:addWeapon}}]]
|user= Tryteyker-
[[Category:Functions|{{uc:addWeapon}}]]
|timestamp= 20140929181300
[[Category:{{Name|arma3}}: Functions|{{uc:addWeapon}}]]
|text= 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]].
}}

Latest revision as of 16:35, 8 November 2023

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

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:
[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:
[bluforUnit, "arifle_Mk20_F", 2, 1] call BIS_fnc_addWeapon;
Example 3:
Alternative syntax of second example, with magazine name written out:
[bluforUnit, "arifle_Mk20_F", 2, "30Rnd_556x45_Stanag_Tracer_red"] call BIS_fnc_addWeapon;

Additional Information

See also:
addWeapon selectWeapon

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
Tryteyker- - c
Posted on Sep 29, 2014 - 18:13 (UTC)
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.