Malcain 35 Posted December 5, 2018 Hi. I have a goal to restrict faction to be able to wear specific gear only, I have achieved that via Spoiler _headgear = (_headgearArray select 0); _oldheadgear = (headgear player); if !(_oldheadgear in _headgearArray) then { removeheadgear player; player addheadgear _headgear; }; Problem is, it creates a duplicated gear if I put it on the ground/container or exchange it. To solve that, I am trying to add "take"/"put" eventhandler checks for duplicated gear (only headgear in this example for simplicity): Spoiler player addeventhandler ["take",{ _headgear = (headgear player); _player = _this select 0; _object = _this select 1; _type = _this select 2; if (_type == _headgear) then { deletevehicle _type }; Tried both with "put" and "take" EHs, but no luck so far. I am not very exp'd with EHs yet, so I appreciate any tips to achieve the goal. Share this post Link to post Share on other sites
davidoss 552 Posted December 6, 2018 You cant deletevehicle _type This works only with objects not strings Best way to achieve this is to store allowed inventory an add inventoryClosed EH which will check if player wear allowed gear and if not replace it Share this post Link to post Share on other sites
Malcain 35 Posted December 6, 2018 1 hour ago, davidoss said: You cant deletevehicle _type This works only with objects not strings Best way to achieve this is to store allowed inventory an add inventoryClosed EH which will check if player wear allowed gear and if not replace it Yes, I already got replacement of gear working fine. My prob is that when I put off/exchange the allowed gear for not allowed, it will create a duplicate item in an opened container. Let's say I am only allowed to wear headgear "A": In container I see headgear "B". When I try to put "B" on: 1. the headgear "A" which was on me, will now be put into the container 2. The headgear "B" will get replaced by headgear "A" as it fails the check for allowed gear. 3. As a result we have headgear "A" on a player and the same headgear "A" in a container. I need to get rid of "A" in the container. Isn't there a way to delete specific item from an opened container? Share this post Link to post Share on other sites
davidoss 552 Posted December 6, 2018 Yes CBA has function which will do that.But there are very strange behaviour that you have described 1 Share this post Link to post Share on other sites
killzone_kid 1333 Posted December 6, 2018 You can remove picked up headgear and add it back to the container. For example: allowedHeadgear = ["H_HelmetB"]; player addEventHandler ["Take", { params ["_unit", "_cont", "_item"]; if (getNumber (configFile >> "CfgWeapons" >> _item >> "ItemInfo" >> "type") == 605 && { !(_item in allowedHeadgear) }) then { removeHeadgear _unit; _cont addItemCargoGlobal [_item, 1]; }; }]; This will prevent player from picking up any headgear from container except H_HelmetB. Current player headgear will be placed in the container though, apparently Put EH doesn't fire when player exchanges headgear with container, one of too many bugs with inventory system. If you like long hours and no pay, then sure, try inventory modification. 1 1 Share this post Link to post Share on other sites
Malcain 35 Posted December 7, 2018 2 hours ago, killzone_kid said: Current player headgear will be placed in the container though, apparently Put EH doesn't fire when player exchanges headgear with container, one of too many bugs with inventory system. Yeah, looks like I got Arma'd. Well, the "Put" eventhandler coupled with "CBA_fnc_removeItemCargo" still partially solved what I was looking for, apart from the "exchange" case. If anyone knows workaround for the "exchange" case, let me know. This is the code example I've successfully tested to delete the duplicate items (so you cannot create infinite number of uniforms/headgear simply dropping them on the ground/in container). Spoiler allowedHeadgear = ["H_HelmetB"]; player addEventHandler ["Put", { params ["_unit", "_cont", "_item"]; if (getNumber (configFile >> "CfgWeapons" >> _item >> "ItemInfo" >> "type") == 605 && { !(_item in allowedHeadgear) }) then { removeHeadgear _unit; _unit addheadgear "H_HelmetB"; [_cont, _item, 1] call CBA_fnc_removeItemCargo; }; }]; Thanks for help and tips! Share this post Link to post Share on other sites