Jump to content
Sign in to follow this  
Aebian

How to find weapon index?

Recommended Posts

Searched the forums and got linked to: https://community.bistudio.com/wiki?title=Talk:ArmA:_Actions#weapon_index

I don't understand this script since its not working for me.

I have a RHS MSV Rifleman with:

removeAllWeapons this;  
removeAllItems this; 
removeAllAssignedItems this;  
removeUniform this;  
removeVest this; 
removeBackpack this;  
removeHeadgear this;  
removeGoggles this; 
this addWeapon "rhs_weap_ak74m_dtk";   
this forceAddUniform "rhs_uniform_flora";  
this addVest "rhs_vydra_3m";  
this addHeadgear "rhs_6b26_ess_bala";

I need the weapon-index for his weapon. The index will be used for:

{_x action ["useWeapon",_x,_x,2];} forEach _units;

Share this post


Link to post
Share on other sites

getWeaponIndex function:

private ["_index", "_unit", "_vehicle", "_weapon"];

_index = 0;

_unit = _this select 0;
_weapon = _this select 1;

_vehicle = vehicle _unit;

_unit action ["SwitchWeapon", _vehicle, _vehicle, _index];

while {(currentWeapon _unit) != _weapon} do {
_index = _index + 1;

_unit action ["SwitchWeapon", _vehicle, _vehicle, _index];
};

_index

Usage:

_weaponIndex = [player, "rhs_weap_ak74m_dtk"] call getWeaponIndex;

  • Like 1

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×