1. I'm trying to get the attacker, not the victim's, Steam ID with the OnEntityDeath hook.

    The following doesn't work: data.steamid = Convert.ToInt32(((BasePlayer)entity).userID);

    Update: I'm using C#
     
    Last edited by a moderator: Oct 11, 2015
  2. Wulf

    Wulf Community Admin

    For C#, info.Initiator?.ToPlayer().userID should work.
     
  3. Thank you. Would it be possible for you to provide an example usage of it, too?

    data.steamid = Convert.ToInt32(hitInfo.Initiator.ToPlayer().userID);
    [DOUBLEPOST=1444534714][/DOUBLEPOST]BasePlayer attacker = hitInfo.Initiator.ToPlayer()
    data.steamid = Convert.ToInt32(attacker.userID);

    This doesn't work either.
     
  4. Wulf

    Wulf Community Admin

    It depends what you are passing in, you'd need to match the first variable. The below should work granted you are passing in hitInfo.

    hitInfo.Initiator.ToPlayer().userID.ToString()
     
  5. Wulf, that worked. Thank you, sir.
    [DOUBLEPOST=1444700127,1444536616][/DOUBLEPOST]Now that it's been discussed on how to retrieve the attacker's Steam ID, how would I retrieve the victim's Steam ID in OnEntityDeath?
     
  6. Wulf

    Wulf Community Admin

    entity.ToPlayer().userID.ToString()
     
  7. Thank you, Wulf, for that fast response.
     
  8. Code:
            void OnEntityDeath(BaseCombatEntity entity, HitInfo hitInfo)
            {
                BasePlayer player = entity as BasePlayer;
                if(player == null) return;
                BasePlayer killer = hitInfo.Initiator as BasePlayer;
                if(killer == null) return;
                ulong steamID = killer.userID;
                // code