Valid question. simply tought of a quick fix and its not liek this runs each tick or somthing, wont be that bad
, will it ? Changed it now, thanks for th hint
It runs for every entity what spawns so it still runs alot.
Merged postName File RemoveWaterWellNpc.cs
namespace Oxide.Plugins
{
[Info("RemoveWaterWellNpc", "Razor", "1.0.0")]
[Description("Remove unwanted WaterWell npc's")]
public class RemoveWaterWellNpc : RustPlugin
{
private const string prefab = "assets/prefabs/npc/waterwell/waterwell_shopkeeper.prefab";
private void OnServerInitialized()
{
foreach (var npc in BaseNetworkable.serverEntities)
{
if (npc != null && npc is NPCShopKeeper)
RemoveShopKeeper(npc.GetComponent<NPCShopKeeper>());
}
}
private void OnEntitySpawned(NPCShopKeeper keeper) => RemoveShopKeeper(keeper);
private void RemoveShopKeeper(NPCShopKeeper keeper)
{
if (keeper != null && keeper.name != null && keeper.name == prefab && keeper.skinID == 0UL)
{
if (keeper.invisibleVendingMachineRef.Get(true) != null && keeper.invisibleVendingMachineRef.Get(true) is InvisibleVendingMachine invisibleVendingMachine)
{
PrintWarning("Killing WaterWell Npc Vendingmachine");
if (invisibleVendingMachine != null && !invisibleVendingMachine.IsDestroyed)
invisibleVendingMachine.Kill();
}
PrintWarning("Killing WaterWell Npc.");
if (keeper != null && !keeper.IsDestroyed)
keeper.Kill();
}
}
}
}