1. Hey,

    i get a ObjectReferenceExcpetion on my hook:
    How to get the item name?
    The exception comes from "string name = i.info.shortname;"
    Code:
            void OnExplosiveThrown(BasePlayer player, BaseEntity entity)
            {
                if (entity == null)
                {
                    rust.BroadcastChat("", "no item");
                }
                else
                {
                    Item i = entity.GetItem();
                    string name = i.info.shortname;
                }
            }
     
  2. Calytic

    Calytic Community Admin Community Mod

    The entity that is received by OnExplosiveThrown method is a separate prefab generated by throwing the explosive. Technically this prefab is not an item or in any way attached to an item once its thrown.

    What you can do is create a key-value-pair (or dictionary) keyed by the thrown prefabName with the values of item shortnames they are associated with, then cross-reference them in OnExplosiveThrown to determine which item it originally was.