Plugin is throwing tons of errorsSolved
        object OnEntityTakeDamage(BaseCombatEntity entity, HitInfo info)
        {
            var attacker = info?.InitiatorPlayer;

            if (attacker == null) 
            {
                if (info.Initiator != null) return null;

                attacker = BasePlayer.FindByID(info.Initiator.OwnerID);
                if (attacker != null) return null;
            }

            var victim = entity?.ToPlayer();

            if (victim == null)
            {
                victim = BasePlayer.FindByID(entity.OwnerID);
                if (victim != null) return null;
            }

            // don't fuck with shooting range
            if (victim is NPCMurderer) return null;

            if (victim.Team == null || victim.Team.members.Contains(attacker.userID))
            {
                info.damageTypes = _EmptyDmgList;
                info.HitMaterial = 0;
                info.PointStart = Vector3.zero;
                info.HitEntity = null;
                return true;
            }

            return null;
        }​


Trying to make a plugin that only allows players and there team mates to destroy there structures. But I'm getting a ton of errors. Does anyo the know what I'm missing?
It would be helpful if you could provide the errors you are seeing. :)

I think error in lines:

if (info.Initiator != null) return null;
...
if (attacker != null) return null;
...
if (victim != null) return null;

because if they == null then method will not bee return and next condition will print NRE 

 
Ive managed to fix the errors, but it's still not working, it's making it so players can't damage anything, I want them to be able to only damage entities they placed
your main return should be "false" , and if owner = attacker or owner in attacker team then return "null"

Merged post

+ don't need modify info
Alright thanks I'll try that

Merged post

object OnEntityTakeDamage(BaseCombatEntity entity, HitInfo info)
{
info.damageTypes = new DamageTypeList();
var attacker = info.InitiatorPlayer;
var victim = entity.ToPlayer();

if (victim == attacker)
{
PrintToChat("test");
return null;
}

return false;
}

cant even seem to get the base if this plugin working, for some reason the attacker and the victim are not recognized as the same player, I can't break my own stuff
Yoshy10112
cant even seem to get the base if this plugin working, for some reason the attacker and the victim are not recognized as the same player, I can't break my own stuff

check by ownerId
if (attacker.userID == entity.OwnerID)

Thanks for the help everyone,  I was testing it on a players base who was null somehow so it was just returning. 
Locked automatically