-
Notifications
You must be signed in to change notification settings - Fork 148
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add CBA_fnc_uniqueUnitItems #902
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* ---------------------------------------------------------------------------- | ||
Function: CBA_fnc_getUniquePlayerItems | ||
|
||
Description: | ||
A function used to retrieve a unique list of items in the units inventory | ||
|
||
Parameters: | ||
_unit - Unit to retrieve the items from | ||
_weaponItems - Include weapons, attachments, loaded magazines (Default: false) | ||
_backpack - Include items in backpack (Default: true) | ||
_vest - Include items in vest (Default: true) | ||
_uniform - Include items in uniform (Default: true) | ||
|
||
Example: | ||
(begin example) | ||
_allItems = [player, true, false] call CBA_fnc_getUniquePlayerItems | ||
(end) | ||
|
||
Returns: | ||
Array of item classnames <ARRAY> | ||
|
||
Author: | ||
Dedmen | ||
---------------------------------------------------------------------------- */ | ||
#include "script_component.hpp" | ||
SCRIPT(getUniquePlayerItems); | ||
|
||
params [["_unit", objNull, [objNull]], ["_weaponItems", true, [true]], ["_backpack", true, [true]], ["_vest", true, [true]], ["_uniform", true, [true]]]; | ||
|
||
private _allItems = (assignedItems _unit); | ||
if (_uniform) then {_allItems append ((getItemCargo (uniformContainer _unit)) select 0);}; | ||
if (_vest) then {_allItems append ((getItemCargo (vestContainer _unit)) select 0);}; | ||
if (_backpack) then {_allItems append ((getItemCargo (backpackContainer _unit)) select 0);}; | ||
|
||
if (_weaponItems) then { | ||
_allItems append (primaryWeaponItems _unit); | ||
_allItems append (secondaryWeaponItems _unit); | ||
_allItems append (handgunItems _unit); | ||
_allItems append [ primaryWeapon _unit, secondaryWeapon _unit, handgunWeapon _unit, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Array contents to new line, one indent right. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Or
? I'm confused now. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. _allItems append [
primaryWeapon _unit, secondaryWeapon _unit, handgunWeapon _unit,
primaryWeaponMagazine _unit, secondaryWeaponMagazine _unit, handgunMagazine _unit
]; |
||
primaryWeaponMagazine _unit, secondaryWeaponMagazine _unit, handgunMagazine _unit | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Only one indent right. |
||
]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same indent as |
||
}; | ||
|
||
_allItems arrayIntersect _allItems //Remove duplicates |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A function used to[R]etrieve[s] a unique list of items in the units inventory[.]