1. I had this working last week, using OnEntitySpawned to clear a corpses inventory on death but now its stopped working. Any help would be appreciated. Thanks.
     
  2. Maybe with the code, it will be easier to see what happend
     
  3. Sorry was on iDevice.

    It defiantly worked at one point then stopped after last weeks update.

    Thanks.

    May have the wrong bit but im sure it had
    if (entity is BaseCorpse)

    Code:
    void OnEntitySpawned(ItemContainer container)
            {
                if (container.itemList.Count > 0)
                {
                    var items = container.itemList[0];
                    item.RemoveFromContainer();
                    item.Remove(0f);
                }
            }
    
     
    Last edited by a moderator: Jan 24, 2017
  4. Some evident error first you have to loop for getting all items in container and next using a correct variable like you declare items but use item without "s"
     
  5. Yeah some of it may have issues, i tried editing it after it stopped working and might of caused a bigger problem. It worked when a friend F1 killed and the player model clothes disappeared but as of last weeks update it stopped.
     
  6. Loads but gives some cannot cast issue.
    Code:
          void OnEntitySpawned(BaseNetworkable entity)
            {
                if (entity is BaseCorpse)
                {
                    var corpse = entity.GetComponent<LootableCorpse>();
                    if (corpse != null)
                    {
                        if (corpse.playerSteamID != 0)
                        {    
                    items.RemoveFromContainer();
                    items.Remove(0f);
                      }
                  }
              }
         }
     
    Last edited by a moderator: Jan 24, 2017
  7. Getting this to work but then get object issue. Hmmm.
    Code:
    void OnEntitySpawned(BaseNetworkable entity, ItemContainer container)
            {
                if (entity is BaseCorpse)
                {
                    var corpse = entity.GetComponent<LootableCorpse>();
                    if (corpse != null)
                    {
                                containerMain.Kill();
                        }
              }
          }
    
    Also getting this

    `item.Remove(0f)' is inaccessible due to its protection level
     
    Last edited by a moderator: Jan 25, 2017
  8. Wulf

    Wulf Community Admin

    It helps when you use variables that exist. ;)
    Code:
    void OnEntitySpawned(BaseNetworkable entity, ItemContainer container)
    {
        var corpse = entity as LootableCorpse;
        if (corpse == null) return;    container.itemList.Clear();
    }
    container.Kill() may work too.
     
  9. Oh wow, Thanks. You wouldn't believe the amount of times i've tried to get it working, unfortunately getting
    (NullReferenceException: Object reference not set to an instance of an object) that now.
     
  10. Wulf

    Wulf Community Admin

    Well, I assumed ItemContainer was actually an argument for the hook, but it isn't, so you'd need to get the container from the corpse instead.
    [DOUBLEPOST=1485309725,1485309163][/DOUBLEPOST]Here's a working example, may be a more direct way to clear all, but it works:
    Code:
    void OnEntitySpawned(BaseNetworkable entity)
    {
        var corpse = entity as LootableCorpse;
        if (corpse == null) return;    foreach (var container in corpse.containers)
        container.itemList.Clear();
    }
    container 0 = main
    container 1 = wear
    container 2 = belt
     
  11. You dude are amazing. It works. :)

    Thanks