1. I've had a looked around but I can't find the variable that the reason of death is store under (for pve death, eg Cold, Bear, Suicide, Wolf etc)

    Using the OnEntityDeath hook

    Anyone able to provide the insight, not too shabby with my c# and had a look at wulfs Death Notes, but it's a little convoluted as it's entirely split up into classes and I can't track down where the reason gets set
     
  2. Wulf

    Wulf Community Admin

    DeathNotes isn't my plugin. ;)

    You can get the attacker and such from Rust's HitInfo that is one of the arguments for the hook. If you'd like to see what HitInfo is, you can open up Rust's Assembly-CSharp.dll in a .NET decompiler such as JustDecompile.
     
  3. its in the hitinfo
    Code:
    private void OnEntityDeath(BaseCombatEntity basecombatentity, HitInfo hitinfo)
    {
     Rust.DamageType dmg = hitinfo.damageTypes.GetMajorityDamageType();
    }
     
  4. Thanks, but I'm trying to get the name of the Initiator and I can't find it >.<
     
  5. Well if its a player or animal that did the killing you could go about it like this
    Code:
    private void OnEntityDeath(BaseCombatEntity basecombatentity, HitInfo hitinfo)
    {
        string AttackerName = "";
        try
        {
            AttackerName = hitinfo.Initiator.ToPlayer().displayName; // attacker is player
        }
        catch { }
        if (AttackerName == "")
        {
            try
            {
                Dictionary<string, string> AnimalTypes = new Dictionary<string, string>();
                AnimalTypes.Add("bear", "Bear");
                AnimalTypes.Add("boar", "Boar");
                AnimalTypes.Add("chicken", "Chicken");
                AnimalTypes.Add("horse", "Horse");
                AnimalTypes.Add("stag", "Stag");
                AnimalTypes.Add("wolf", "Wolf");
                if (AnimalTypes.ContainsKey(hitinfo.Initiator.ShortPrefabName))
                {
                    AttackerName = AnimalTypes[hitinfo.Initiator.ShortPrefabName]; // attacker is known animal
                }
            }
            catch { }
        }
    }
    but you would need a different method for traps killing players and another for suicides and another for the heli kills ect which is why the death notes plugin is so bulky :)