CreativeProduct 1 Posted March 17, 2017 Hello there. Im facing a difficult thing for my circumstances. Maybe im just to sleepy to get my mind right. However, im creating a script, which checks if any of the items in the array are in the players inventory. If that's the case, one of the items should be removed, but I just dont know how. This is what I've got sot so far: _unit = _this select 0; _foods = ["ARP_sandwich","ARP_twinkies","ARP_pineapples","ARP_soup","ARP_spaghettios","ARP_tuna","ARP_skittles","ARP_snickers","ARP_pitabread","ARP_potatobag","ARP_chili","ARP_beefjerky","ARP_dip"]; If ( {_x in _foods} foreach (items _unit) ) then { hint "Item exists, should be removed." } else {Hint "false"}; It's basically getting the _x for each item again. However, as you can propably tell, iI didnt get it to work. Thanks in advance. Best regards. Share this post Link to post Share on other sites
soolie 184 Posted March 17, 2017 { if (_x in (items player)) then { systemChat format ["Food - %1 found",_x]; }; }forEach _foods; change player to _unit Share this post Link to post Share on other sites
CreativeProduct 1 Posted March 17, 2017 15 minutes ago, soolie said: { if (_x in (items player)) then { systemChat format ["Food - %1 found",_x]; }; }forEach _foods; Well, it seems like this way it checks if those items are (Maybe all of them?) are in the inventory. After trying out a bit { if (_x in (items player)) then { hint "Worked"; } else { systemChat format ["Food - %1 found",_x];;}; } forEach _foods; i made this, to see if the condition was false - returning every item as found, obviously caused by the false condition - was made for debug reasons. Well, the purpose of the scirpt is to check if ANY item is in the inventory and then remove that item. Best regards Share this post Link to post Share on other sites
killzone_kid 1222 Posted March 17, 2017 _foods deleteAt (_foods find _item) Share this post Link to post Share on other sites
soolie 184 Posted March 17, 2017 { if (_x in (items _unit)) exitWith { systemChat format ["Food - %1 found",_x]; }; }forEach _foods; The exitWith will stop it from running again once it finds something Share this post Link to post Share on other sites
CreativeProduct 1 Posted March 17, 2017 3 minutes ago, soolie said: { if (_x in (items _unit)) exitWith { systemChat format ["Food - %1 found",_x]; }; }forEach _foods; The exitWith will stop it from running again once it finds something Works like a charm. Thank you very much. Best regards Share this post Link to post Share on other sites