Needs update for new armor with inserts.

if you could add in this function that would be great. as is you get this error when trying to skin any armor with insert slots.

Failed to call hook 'OnItemAddedToContainer' on plugin 'Skins v2.2.3' (NullReferenceException: Object reference not set to an instance of an object)
at Oxide.Plugins.Skins+ContainerController.GetDuplicateItem (Item item, System.UInt64 skin) [0x0003c] in <ccdeaf96404d4dfb893daa0366d8adbb>:0

at Oxide.Plugins.Skins+ContainerController.UpdateContent (System.Int32 page) [0x001f7] in <ccdeaf96404d4dfb893daa0366d8adbb>:0

at Oxide.Plugins.Skins.OnItemAddedToContainer (ItemContainer itemContainer, Item item) [0x00094] in <ccdeaf96404d4dfb893daa0366d8adbb>:0

at Oxide.Plugins.Skins.DirectCallHook (System.String name, System.Object& ret, System.Object[] args) [0x002f3] in <ccdeaf96404d4dfb893daa0366d8adbb>:0

at Oxide.Plugins.CSharpPlugin.InvokeMethod (Oxide.Core.Plugins.HookMethod method, System.Object[] args) [0x00079] in <42f9bedc659b4f4786eb778d3cd58968>:0

at Oxide.Core.Plugins.CSPlugin.OnCallHook (System.String name, System.Object[] args) [0x000de] in <8cb2d664f1574f2b96d53f1c1869d96a>:0

at Oxide.Core.Plugins.Plugin.CallHook (System.String hook, System.Object[] args) [0x00060] in <8cb2d664f1574f2b96d53f1c1869d96a>:0

X  2
Yes,That would be Greate!

if your are an admin, i managed to skin those armored items, its kind of complicated, but i used another plugin, works with backpack and monumentaddons,(setting up a NPCVendingMachine at outpost) put your skinned item in there, and edit the json file add the line "Capacity": 3 , respect the "commas" and save and reload the plugin, and its done, and also can put 3 slot on metalfacemasks xd

update needed

Yes, a constant mistake :(

Hello can you update please?

bug skins with Armor Slot Manager plugin

Update GetDuplicateItem to handle ItemModContainerArmorSlot item mod.


            private Item GetDuplicateItem(Item item, ulong skin)
            {
                var duplicate = ItemManager.Create(item.info, item.amount, skin);
                if (item.hasCondition)
                {
                    duplicate._maxCondition = item._maxCondition;
                    duplicate._condition = item._condition;
                }

                if (item.contents != null)
                {
                    if (duplicate.contents == null)
                    {
                        ItemModContainerArmorSlot armorSlot = FindItemMod(duplicate);
                        if (armorSlot != null)
                        {
                            armorSlot.CreateAtCapacity(item.contents.capacity, duplicate);
                        }
                        else
                        {
                            item.contents = Pool.Get();
                            item.contents.ServerInitialize(duplicate, item.contents.capacity);
                            item.contents.GiveUID();
                        }
                    }
                    else
                    {
                        duplicate.contents.capacity = item.contents.capacity;
                    }
                }

                var projectile = duplicate.GetHeldEntity() as BaseProjectile;
                if (projectile != null)
                    projectile.primaryMagazine.contents = 0;

                return duplicate;
            }

            private T FindItemMod(Item item) where T : ItemMod
            {
                foreach (ItemMod itemMod in item.info.itemMods)
                {
                    if (itemMod is T mod)
                    {
                        return mod;
                    }
                }
                return null;
            }
elWXp65VsO8QJYV.jpg tierip

Update GetDuplicateItem to handle ItemModContainerArmorSlot item mod.


            private Item GetDuplicateItem(Item item, ulong skin)
            {
                var duplicate = ItemManager.Create(item.info, item.amount, skin);
                if (item.hasCondition)
                {
                    duplicate._maxCondition = item._maxCondition;
                    duplicate._condition = item._condition;
                }

                if (item.contents != null)
                {
                    if (duplicate.contents == null)
                    {
                        ItemModContainerArmorSlot armorSlot = FindItemMod(duplicate);
                        if (armorSlot != null)
                        {
                            armorSlot.CreateAtCapacity(item.contents.capacity, duplicate);
                        }
                        else
                        {
                            item.contents = Pool.Get();
                            item.contents.ServerInitialize(duplicate, item.contents.capacity);
                            item.contents.GiveUID();
                        }
                    }
                    else
                    {
                        duplicate.contents.capacity = item.contents.capacity;
                    }
                }

                var projectile = duplicate.GetHeldEntity() as BaseProjectile;
                if (projectile != null)
                    projectile.primaryMagazine.contents = 0;

                return duplicate;
            }

            private T FindItemMod(Item item) where T : ItemMod
            {
                foreach (ItemMod itemMod in item.info.itemMods)
                {
                    if (itemMod is T mod)
                    {
                        return mod;
                    }
                }
                return null;
            }

I inserted this into Skins.cs and recieved this error:
Error while compiling Skins: Constraints are not allowed on non-generic declarations | Line: 1306, Pos: 47
Which relates to this line:

private T FindItemMod(Item item) where T : ItemMod

Any ideas?

Ah, sorry, < and > got messed up when I copied this code snippet.

private Item GetDuplicateItem(Item item, ulong skin)
{
    var duplicate = ItemManager.Create(item.info, item.amount, skin);
    if (item.hasCondition)
    {
        duplicate._maxCondition = item._maxCondition;
        duplicate._condition = item._condition;
    }

    if (item.contents != null)
    {
        if (duplicate.contents == null)
        {
            ItemModContainerArmorSlot armorSlot = FindItemMod<ItemModContainerArmorSlot>(duplicate);
            if (armorSlot != null)
            {
                armorSlot.CreateAtCapacity(item.contents.capacity, duplicate);
            }
            else
            {
                item.contents = Pool.Get<ItemContainer>();
                item.contents.ServerInitialize(duplicate, item.contents.capacity);
                item.contents.GiveUID();
            }
        }
        else
        {
            duplicate.contents.capacity = item.contents.capacity;
        }
    }

    var projectile = duplicate.GetHeldEntity() as BaseProjectile;
    if (projectile != null)
        projectile.primaryMagazine.contents = 0;

    return duplicate;
}

private T FindItemMod<T>(Item item) where T : ItemMod
{
    foreach (ItemMod itemMod in item.info.itemMods)
    {
        if (itemMod is T mod)
        {
            return mod;
        }
    }
    return null;
}
elWXp65VsO8QJYV.jpg tierip

Ah, sorry, < and > got messed up when I copied this code snippet.

Awesome! It works. Thank you so much!!
elWXp65VsO8QJYV.jpg tierip

Ah, sorry, < and > got messed up when I copied this code snippet.

oh man , we love you! thank you very much!

Can someone give me the fix file?

AAAAA

Can someone give me the fix file?

sure, check your msgs!

@alexwakko would you kindly share it with me as well? Many thanks!