1. Hi, im trying to spawn items inside a chest as soon as a player loots it.
    Code:
          void OnPlayerLoot(PlayerLoot inventory, BaseEntity target)
            {
                var definition = ItemManager.FindItemDefinition("stones");
                StorageContainer box = inventory.GetComponent("StorageContainer") as StorageContainer;
                Item stenitem = ItemManager.CreateByItemID((int)definition.itemid, 500, false);
                stenitem.MoveToContainer(inventory.containers[0], 1, true);        }
    I tried this, and can't see why it wont work.. Thanks!
     
  2. Here you go:
    Code:
    void OnPlayerLoot(PlayerLoot inventory, BaseEntity target)
    {
        StorageContainer container = target.GetComponent<StorageContainer>();
        Item item = ItemManager.CreateByName("stones", 500);    item.MoveToContainer(container.inventory, 0, true);
    }
     
  3. Thanks sir.. Any idea how add a codelock to any chest deployed into the game?
     
  4. This only works if you have at least one free slot:
    Code:
    void OnItemDeployed(Deployer deployer, BaseEntity entity)
    {
        StorageContainer container = deployer.GetDeployable()?.GetComponent<StorageContainer>();
        if (container == null || !container.isLockable) return;    Item item = ItemManager.CreateByName("lock.code", 1);
        item.MoveToContainer(deployer.ownerPlayer.inventory.containerMain);
               
        Deployer toDeploy = item.GetHeldEntity() as Deployer;
        toDeploy.DoDeploy_Slot(toDeploy.GetDeployable(), deployer.ownerPlayer.eyes.BodyRay(), entity.net.ID);
    }
    It's by no means perfect, but it's a start.
     
  5. Thank you so much