1. Hello,

    I'm having a problem where i am storing data connected to IPlayer, but using a hook that uses BaseEntity or BasePlayer. How do i go about getting the player information under IPlayer from BasePlayer/Entiy?

    Code:
            private void OnPlayerAttack(BasePlayer player, HitInfo info)
            {
                var victim = info?.HitEntity as IPlayer;
                var attacker = info?.Initiator as BasePlayer;            Puts("Victim: " + victim);
                Puts("Player: " + attacker);
            }
    This results in:

    Code:
    [AngryJail] Victim:
    [AngryJail] Player: [AMob] Tori1157[13219/76561198025298808]
     
  2. victim.IPlayer
    attacker.IPlayer
     
  3. ...?? Really? It was that simple? Well, just goes to show overthinking is not the way to go. Thanks for the help Ryan!
     
  4. Wulf

    Wulf Community Admin

    The IPlayer is only available for BasePlayer, so make sure to cast and check that for null first.
     
  5. By that you mean this, correct?
    Code:
                if (attacker == null) return;
                if (victim == null) return;
                if (attacker == victim) return;
     
  6. Wulf

    Wulf Community Admin

    Yes, assuming those are BasePlayer.
     
  7. I'm pretty sure they are, else there would have been a lot of errors in console. Right?