I finally managed to corner the weapon trader bug, the culprit is the torch (item 406). When loading an inventory with a torch in it the program won't work, likely because of one of the triggers attacked to the torch. Possible solutions are:
1. Change torches so that they don't appear at the merchants. You have to wait until already existing torches are removed from the trader's inventory.
2. Remove the triggers from the torch. Now it's just a club with another name.
3. Do both changes.
4. Fix the triggers. But don't ask me how that's done.
Torch with merchandise flag - this is the original code from the items file
itm_torch Torch Torch 1 club 0 4259842 9223388529554358286 11 0 2.500000 100 0 0 0 0 11264 95 0 95 0 256 523
1
-50.000000 5 1955 3 0 60 0 1965 1 1008806316530991114 1965 1 1008806316530991117 1950 3 150 130 70 1960 2 10 30
Torch without merchandise flag - reduce the item flags
4259842 by 65536 to 4194306
itm_torch Torch Torch 1 club 0 4194306 9223388529554358286 11 0 2.500000 100 0 0 0 0 11264 95 0 95 0 256 523
1
-50.000000 5 1955 3 0 60 0 1965 1 1008806316530991114 1965 1 1008806316530991117 1950 3 150 130 70 1960 2 10 30
Torch without triggers - change the triggers flag from
1 to 0 and remove the triggers
-50.000000 5 1955 3 0 60 0 1965 1 1008806316530991114 1965 1 1008806316530991117 1950 3 150 130 70 1960 2 10 30
itm_torch Torch Torch 1 club 0 4259842 9223388529554358286 11 0 2.500000 100 0 0 0 0 11264 95 0 95 0 256 523
0
Torch without triggers and merchandise flag
itm_torch Torch Torch 1 club 0 4194306 9223388529554358286 11 0 2.500000 100 0 0 0 0 11264 95 0 95 0 256 523
0