Is this possible, even if the player is not online/alive anymore?
(I'm beginner with C#)
(I'm beginner with C#)
var entities = BaseNetworkable.serverEntities.Where(e => e?.name != null && e.name.Contains("skull_fire_pit")).Cast<BaseEntity>().ToList();
...
foreach (var entity in entities)
{
if (!entity.GetBuildingPrivilege())
{
entity.Kill(BaseNetworkable.DestroyMode.Gib);
continue;
}
...
BasePlayer owner = BasePlayer.FindByID(entity.OwnerID);
if (BasePlayer.FindByID(entity.OwnerID))
owner = BasePlayer.FindByID(entity.OwnerID);
else if (BasePlayer.FindSleeping(entity.OwnerID))
owner = BasePlayer.FindSleeping(entity.OwnerID);
if (owner == null)
{
entity.Kill(BaseNetworkable.DestroyMode.Gib);
continue;
}
In indisght covalence.Players is more suitable, but it would require a lot of change to other parts of the plugin