Equipping clothes with other commands won't equip the clothes

I created several .bat files to equip some clothes in my settlers, modded clothes, this way:

equipitem 51000d0f 1; suit 1
equipitem 51000xb4 1; suit 2

At first I was just equipping the clothes, so when I exited the game and returned, the settlers just changed to the default clothes, but the modded ones were still in the inventory. I quickly solved this by removing the default clothes from their inventory.

Well, I don't want to remove every default clothes from every settler every time I do this, so I edited the .bat files to do this automatically, based on a YouTube video I saw:

removeallitems; Remove previous suit from inventory
additem 0014831B; pipe revolver
equipitem 0001F66A 10; .45
unequipitem 0001F66A; In the video the guy says this is necessary so the NPC can use the ammo
equipitem 51000d0f 1; suit 1
equipitem 51000xb4 1; suit 2

The problem with this is that the NPC won't equip anything. All the clothes and items are added to the inventory, but the settler will be naked, not even wearing the default clothes.

I tried several combinations, without the gun and ammo, without removing all items and changing the orders, but the clothes will only equip if I run the .bat file only with them, nothing else.

What can I do to achieve this automatically?


Solution 1:

Well, the problem is linked with the additem code. Even after using the old code, if I manually add an item in npc inventory using just this code, the old clothes are equipped automatically.

If I change the code to:

removeallitems; Remove previous suit from inventory
equipitem 0014831B; pipe revolver <-- changed to equipitem, not additem
equipitem 0001F66A 10; .45
unequipitem 0001F66A; Necessary so the NPC can use the ammo
equipitem 51000d0f 1; suit 1
equipitem 51000xb4 1; suit 2

it works as expected.