Getting owners of build zone of shotgun trap?

Hi, I'm pretty new to creating plugins.
I've done some of the basics but now for my next idea I need something specific.

What I'm looking for is the following:

When a shotgun trap fires, I want to know if it's inside a building zone.
If it is I want to know who has build priv. for it.

What would be the best way for me to access this information?


There doesn't seem to be a hook for the shotgun trap, right?
So I saw how another plugin 'created' suck a hook by using the OnEntityTakeDamage.

I'd figure I should start there, but how should I go further to get the required info, and is this the best way to do this?

Thx

private void OnEntityTakeDamage(BaseCombatEntity entity, HitInfo info)
        {
            var initiator = info?.Initiator?.GetComponent();
            if (initiator == null)
            {
                return;
            }

            if (initiator.GetBuildingPrivilege() != null)
            {
                // In building privilege
            }
            else
            {
                // Out of building privilege
            }
        }

 

5ba216a6d7f65.png Orange
private void OnEntityTakeDamage(BaseCombatEntity entity, HitInfo info)
        {
            var initiator = info?.Initiator?.GetComponent();
            if (initiator == null)
            {
                return;
            }

            if (initiator.GetBuildingPrivilege() != null)
            {
                // In building privilege
            }
            else
            {
                // Out of building privilege
            }
        }

 

Thank you for your reply!

I'm guessing the returned object of initiator.GetBuildingPrivilege() will hold information about who has privilege?

I'll will try this weekend.

Thx again!

SEGVeenstra

Thank you for your reply!

I'm guessing the returned object of initiator.GetBuildingPrivilege() will hold information about who has privilege?

I'll will try this weekend.

Thx again!

initiator.GetBuildingPrivilege()

is actual cupboard, you can check player's authorized like (can be wrong syntax)

initiator.GetBuildingPrivilege().authorizedPlayers
Oke, I couldn't wait any longer and I tried it. It's working fantastic, it was exactly what I needed thank you!