1. i want to access barrels's loot when they spawn and add 1 scrap to them, i still dont know exactly how to do this but i was thinking something like

    Code:
    void OnEntitySpawned(BaseNetworkable entity, ItemContainer container)
            {
                if (entity.name == "loot-barrel-1" || entity.name == "loot-barrel-2")
                {
                    Item item = ItemManager.CreateByItemID(109266897, 1);//create scrap item
                    item.MoveToContainer(container);
                }
            }
    i know the syntaxis is wrong and that is what i am needing, this is kind of a pseudocode
     
  2. I'm not sure but i think SimpleLoot might have some answers.
     
  3. Hello, you must use "Contains" instead of "==" OR you may compare to the "ShortPrefabName" instead of "name"
    entity.name will give you the complete prefab name as ShortPrefabName give you only the name "loot-barrel-1"
    Also, when you create an item with CreateByItemID or similar method, you may verify if your item as successfully been created
    You have to get container from entity as the hook changed

    Code:
    void OnEntitySpawned(BaseNetworkable entity)
    {
        var containers = entity as LootContainer;
        if (entity.ShortPrefabName == "loot-barrel-1" || entity.ShortPrefabName == "loot-barrel-2")
        {
            if (containers != null)
            {
                Item item = ItemManager.CreateByItemID(109266897, 1); //create scrap item
                item?.MoveToContainer(containers.inventory);
            }
        }
    }
     
  4. thanks! one question, when you move the item you put a ?, is that to verify if the item was successfully created?
     
  5. The "?" is to avoid any error if your item isn't created it's like :
    Code:
    if(item != null)
       item.MoveToContainer(containers.inventory);