1. Hello,

    I would like to give a player a water filled Bota bag using a chat command.
    I can give him a Bota bag, but I can't fill it ... any advice ?

    -> I can use item.GetHeldEntity() to get the BaseEntity and cast it into BaseLiquiVessel .... but after that, all attributes are NullPointerReference
    -> I tried to AddItem to its container but it didn't work

    EDIT : This code prints "Amount 10" but doesn't fill the bota bag
    Code:
    // Bota bag
     if (item.info.itemid == 68998734)
    {
        // ItemDefinition of water
        ItemDefinition def = ItemManager.CreateByItemID(112903447, 1).info;
        // Add to the container
        item.contents.AddItem(def, 10);    // Watch how many water is in the container
        int amount = 0;
        foreach (Item i in item.contents.itemList)
        {
            amount += i.amount;
        }
       // Prints "Amount 10"
        Puts("Amount " + amount);
    }
    // Add the bota bag to the inventory
    player.inventory.containerBelt.AddItem(item.info, item.amount);
    
     
    Last edited by a moderator: May 13, 2017
  2. You can use AddLiquid(ItemDefinition, Amount):
    Code:
    Item item = ItemManager.CreateByItemID(68998734);
    player.GiveItem(item);BaseLiquidVessel bota = item.GetHeldEntity().GetComponentInChildren<BaseLiquidVessel>();
    bota.AddLiquid(ItemManager.FindItemDefinition(112903447), 10);
    Note: It's important that you first give the item to the player and then fill it with water. Otherwise you get a null reference exception.
     
  3. It works like a charm !!
    Thanks a lot !