Jump to content
🛡️FORUMS ARE IN READ-ONLY MODE Read more... ×
Robustcolor

Removing items from inventory

Recommended Posts

Question, when searching in player inventory for items that has a specific string in them, in this case mine and then removing only one of it. Is this the right approach?

First code i select all items with mine then removing one of it (seems unnecessary to select all when only one is needed to be removed) , second code is more of a BOOL but works for some reason. Is there a better way of doing this?

player removeItem selectRandom (items player select {"mine" in _x})
player removeitem selectRandom items player in ['mine'];

 

Share this post


Link to post
Share on other sites

Not sure you'll find more than a mine detector in items player (Arma vanilla). Usually mines are returned by magazines player
Anyway, items player select  {"mine" in toLowerANSI _x}  could return  : ["MineDetector"] ...

  or, in case of mines: magazines player {"mine" in toLowerANSI _x}  // returns something like ["SLAMDirectionalMine_Wire_Mag","SLAMDirectionalMine_Wire_Mag","SLAMDirectionalMine_Wire_Mag","ATMine_Range_Mag","APERSTripMine_Wire_Mag"]

 

You can use removeItem for removing the mine detector. Logically, you know which item you want to remove: player removeItem "MineDetector"  // will remove the first (or unique) detector.
Or removeItemS  for removing all detectors (or specified class of item)

 

For magazines (like mines):
player removeMagazine "SLAMDirectionalMine_Wire_Mag"; // will remove one SLAM directional mine

player removeMagazine selectRandom ( magazines player select {"mine" in toLowerANSI _x}); // will remove one of mines at random

 

 


 

 

  • Like 1

Share this post


Link to post
Share on other sites

×