1. Hi, I did this and it works, but I have a problem. When the killer is helicoper or high externall wall (and more but I don't remember) I get an error. I know that that's because you can't SendReply to an helicopter ^^

    Code:
    void OnEntityDeath(BaseCombatEntity entity, HitInfo Info)
            {
                BasePlayer player = entity.ToPlayer();            if (player != null)
                {
                    BasePlayer Killer = null;
                    if (Info != null)
                    {
                        Killer = Info.Initiator.ToPlayer();
                        if (Info?.Initiator != null)
                        {
                            SendReply(Killer, "Something");
                        }
                    }
                }
            }
     
  2. Code:
       void OnEntityDeath(BaseCombatEntity entity, HitInfo hitInfo)
            {
                if (entity == null || hitInfo?.Initiator == null) return;
                if (entity is BasePlayer && hitInfo.Initiator is BasePlayer)
                {
                    var victim = entity.ToPlayer();
                    var attacker = hitInfo.Initiator.ToPlayer();
                    SendReply(victim, "you died");
                    SendReply(attacker, "you killed: " + victim.displayName);
                }        }
    
    This should work, you weren't checking if it was a player, you were only checking if the Initiator was not null, which means any entity could have killed it.

    EDIT: Maybe you were, I didn't notice the first if, not sure why that wasn't working before.

    EDIT 2: I'm apparently unable to read, you were checking if the person dying was a player, then wanting to send a message to the killer. They have to both be players.
     
    Last edited by a moderator: Jun 20, 2016
  3. Wulf

    Wulf Community Admin

    He's actually looking for the killer via HitInfo, what he has for the entity/player is fine, just an alternative way to how you did it.
     
  4. Yes, I realized this shortly after I posted it. I guess I'm trying to read too fast today. ;)
     
  5. Thank you! Solved!