For anyone using Automatic Authorization

This is pretty specific, but if you're using that plugin as well, teammates who are added to cupboards automatically through AA won't be recognized in RaidProtection until RP is reloaded.

You can add a hook call in AA in the AuthToCupboard method to force it though, eg:

Before:

foreach (var friend in authList)
{
     buildingPrivlidge.authorizedPlayers.Add(friend);
}
buildingPrivlidge.SendNetworkUpdate();

After:

foreach (var friend in authList)
{
    buildingPrivlidge.authorizedPlayers.Add(friend);
 
    var bPlayer=BasePlayer.FindByID(friend.userid);
    RaidProtection.Call("OnCupboardAuthorize", buildingPrivlidge, bPlayer);
}
buildingPrivlidge.SendNetworkUpdate();

 

Getting this error

Error while compiling: AutomaticAuthorization.cs(333,5): error CS0103: The name `RaidProtection' does not exist in the current context

masshole

Getting this error

Error while compiling: AutomaticAuthorization.cs(333,5): error CS0103: The name `RaidProtection' does not exist in the current context

Ah you need to add RaidProtection as a reference up the top:

[PluginReference] private readonly Plugin Clans, Friends, EntityOwner, RaidProtection;

Also I updated this slightly to:
 
 
               foreach (var friend in authList)
                {
                    buildingPrivlidge.authorizedPlayers.Add(friend);

                    var bPlayer = BasePlayer.FindAwakeOrSleeping(Convert.ToString(friend.userid));
                    if (bPlayer != null && RaidProtecton != null)
                        RaidProtection.Call("OnCupboardAuthorize", buildingPrivlidge, bPlayer);
                }
                buildingPrivlidge.SendNetworkUpdate();