Solved Difference between NPC's and Players

Snake

Moderator
Moderator
Jul 13, 2014
288
174
28
Hi !

I was wondering if there's another way to difference between a NPC and a Player in a DeathEvent or HurtEvent.

The usual way is to check if the name is any animal, but that can be "tricked" if a player's name is equal to an animal.

Any ideas ? Thanks !
 

DreTaX

Probably knows the answer...
Administrator
Jun 29, 2014
4,095
4,815
113
At your house.
github.com
  • Like
Reactions: Snake

Snake

Moderator
Moderator
Jul 13, 2014
288
174
28
Solved !

To anyone with this problem :

Reference the Assembly-CSharp and use the DamageEvent information !
 

Snake

Moderator
Moderator
Jul 13, 2014
288
174
28
To those who have same problem :

What I used was :
C#:
DamageEvent damageEvent = (DamageEvent) de.DamageEvent;
Fougerite.Player att = Fougerite.Player.FindByPlayerClient(damageEvent.attacker.client);
Fougerite.Player vic = (Fougerite.Player) de.Victim;
if (att != null)
{
//Your code here
}
 
Last edited:

DreTaX

Probably knows the answer...
Administrator
Jun 29, 2014
4,095
4,815
113
At your house.
github.com
What I used was :
C#:
DamageEvent damageEvent = (DamageEvent) de.DamageEvent;
Fougerite.Player att = Fougerite.Player.FindByPlayerClient(damageEvent.attacker.client);
Fougerite.Player vic = (Fougerite.Player) de.Victim;
if (att != null)
{
//Your code here
}
Just like on TS3 xdd
 
  • Like
Reactions: Snake

mikec

Master Of All That I Survey
Retired Staff
Trusted Member
Jul 12, 2014
296
152
28
Los Angeles, California, USA
That was easy.

C#:
    public class HurtEvent
    {
        ...
        private readonly bool _playerattacker;
        private readonly bool _playervictim;

       ...
        public bool VictimIsPlayer
        {
            get
            {
                return this._playervictim;
            }      
        }

        public bool AttackerIsPlayer
        {
            get
            {
                return this._playerattacker;
            }
        }
    }
 
  • Like
Reactions: Snake

Snake

Moderator
Moderator
Jul 13, 2014
288
174
28
That was easy.

C#:
    public class HurtEvent
    {
        ...
        private readonly bool _playerattacker;
        private readonly bool _playervictim;

       ...
        public bool VictimIsPlayer
        {
            get
            {
                return this._playervictim;
            }     
        }

        public bool AttackerIsPlayer
        {
            get
            {
                return this._playerattacker;
            }
        }
    }
Thanks !