Jump to content
Sign in to follow this  
serena

Way to determine where the binoculars

Recommended Posts

Is there a legal way to detect item in binocular slot  separate with same items in unit gear containers, without using getUnitLoadout command?

 

Weapons and weaponsItems return all unit weapons include stored in gear.

 

 

 

 

First approach:

_onlyAssignedWeaponsIncludeOneInBinocularSlot = player call Fn_Gear_GetUnitAssignedWeaponsItems;


Fn_Gear_GetUnitAssignedWeaponsItems = {
	private _res = [];
	
	{	private _wpc = _x select 0;
		if (_this hasWeapon _wpc) then {
			if (isNil {{if (_x select 0 isEqualTo _wpc) exitWith {_x}} forEach _res}) then {
				_res pushBack _x}
		}
	} forEach weaponsItems _this;	
	_res
};

Share this post


Link to post
Share on other sites

Yes, this is what I need. Thank you

 

Second approach:

Fn_Gear_GetUnitAssignedWeaponsItems = {
	private _unt = _this;
	private _wis = weaponsItems _unt;
	
	[primaryWeapon _unt, secondaryWeapon _unt, handgunWeapon _unt, binocular _unt]
		apply {
			private _wpc = _x;
			if (_wpc isEqualTo "")
				then {[]}
				else {{if (_x select 0 isEqualTo _wpc) exitWith {_x}} forEach _wis}}
};

Share this post


Link to post
Share on other sites
fnc = 
{
	private _weaponsItems = getUnitLoadout _this;
	(_weaponsItems select [0, 3]) + [_weaponsItems select 8]
};

Don't understand why you are against using getUnitLoadout

Share this post


Link to post
Share on other sites

I'm just trying to operate with only a necessary minimum amount of data

Share this post


Link to post
Share on other sites
Guest

Those commands, getUnitLoadout and setUnitLoadout are amazing. Best way to save players on DB and get from. Transform many, many lines, in one line.

But they are safe to use?

 

Sorry for off-topic.

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  

×