<b>EDIT: Look at SaMatra's comment below, his suggestion is much better.</b>
<u>Short</u>: Add new functions to access and remove inventory items by ID.
<u>Long</u>: As of right now, inventory items can only be managed by their class name, regardless of which container they are in (uniform, vest, backpack). This makes it very difficult to try managing individual items from a player's inventory.
For example, I am trying to make a selling system, so that players can sell things directly from their inventory in exchange for money usable in my custom mission. Let's say a player has a bunch 6.5mm STANAG mags spread out in his inventory, many of which are partially used.
Now, the player wants to give one of these mags that, for example, is located in his vest, and has 14 rounds out of 30 left. At the moment, the only functions to remove magazines from an unit's inventory are <i>removeMagazine</i> and its variants, which only accept class names. This also applies to item and weapon functions. As a result, we cannot remove an item based on its inventory location or ammo state; the current remove functions will simply remove the first one from the inventory, regardless of its location.
The solution to this, is to add a set of functions to manage inventory items with IDs. As evidenced by the output of the <i>magazinesDetail</i> function, inventory items already have IDs, so adding such functions shouldn't be hard.
Here are my suggestions:
<b>inventoryItems _unit</b>
Outputs an array of arrays in the format [<item name>, <item ID>, <item location>], similar to <i>magazinesAmmoFull</i>
Example output:
[
["FirstAidKit", 3, "Uniform"],
["16Rnd_9x21_Mag", 4, "Uniform"],
["30Rnd_556x45_Stanag", 14, "Vest"],
["30Rnd_556x45_Stanag", 17, "Vest"],
["acc_flashlight", 21, "Vest"],
["Medikit", 25, "Backpack"],
["SMG_01_F", 30, "Backpack"],
["30Rnd_45ACP_Mag_SMG_01", 34, "Backpack"],
]
<b>_unit removeInventoryItem _itemID</b>
Removes a specific item by its ID returned from the former function
<b>_unit inventoryWeaponItems _itemID</b>
Outputs an array corresponding to accessories attached to a weapon in the inventory and its loaded magazine(s), similar to <i>weaponsItems</i>
Example output:
[
"arifle_MX_GL_F",
"muzzle_snds_H",
"acc_pointer_IR",
"optic_Aco",
[
"30Rnd_65x39_caseless_mag", 30
],
[
"1Rnd_HE_Grenade_shell", 1
]
]
Also, the <b><i>magazinesAmmoFull</i></b> function should be modified to include the inventory ID of each magazine. Example output:
[
["30Rnd_65x39_caseless_mag",30,false,-1,"Uniform", 11],
["30Rnd_65x39_caseless_mag",30,false,-1,"Vest", 14],
["16Rnd_9x21_Mag",16,false,-1,"Vest", 15],
["SmokeShellGreen",1,true,0,"SmokeShellGreenMuzzle", 17],
["Chemlight_green",1,true,0,"ChemlightGreenMuzzle", 21],
["HandGrenade",1,true,0,"HandGrenadeMuzzle", 25],
["30Rnd_65x39_caseless_mag",30,true,1,"arifle_MX_ACO_pointer_F", -1], // -1 since it's loaded inside a weapon
["16Rnd_9x21_Mag",16,true,2,"hgun_P07_F", -1]
]
Sorry if this looks very technical, but it is mostly oriented at coders. In the end, it's all about having more flexibility.