This seems to work great. Thanks for sharing your snippet @Pattoh.
I was wondering if anybody's found a workaround for attachments to stop magically appearing in vehicles whenever the inventory is updated? Say I have an RHS AKM in the trunk of a car without a muzzle attachment, and I sell a can of dog food out of the car, suddenly a DTK appears. And then another if I sell another can, and on, and on, and on... Most of these muzzles can't be sold but after a big haul I've had players with 30-40 DTKs in there. It's a real pain when you have to drag them all onto the ground one by one when you don't have access to the waste dump.
An example: I had two empty AKMs in the car and started selling smoke grenades.
I know these weapons spawn with DTKs, and every time the vehicle updates its inventory it basically just wipes it and spawns a new one. And I know the easy way to get rid of this is to just remove the AKM and others like it, but there has to be a better way.
Solution Edit:
For anybody having this problem, what I did to fix it was make an array of the items that I know get duplicated (it's surprisingly small) and hooked into the ExileClient_util_containerCargo_deserialize function much the same way this thread hooks into the updateInventoryListBox function. At line 21 you should see the start of a loop that iterates over all the items passed to the function. Simply wrap everything in that loop in an if statement like so:
Package that file up into your custom code folder and call it just like you did with the original. That's all there is to it. It's certainly not elegant, but it's functional.