So I have this simple plugin to make autoturret shoot npc. It's working but server console keeps showing red line errors after turret killed npcs. Is there something wrong with my code? Thanks for reply.
object OnTurretTarget(AutoTurret turret, BaseCombatEntity entity)
{
if (entity.ShortPrefabName == "scarecrow")
{
return null;
}
if (entity.ShortPrefabName == "murderer")
{
return null;
}
if (entity.ShortPrefabName.Contains("scientist"))
{
return null;
}
if (entity is BasePlayer)
{
return false;
}
return null;
}Error is here:
Failed to call hook 'OnTurretTarget' on plugin 'mcTurret v1.0.0' (NullReferenceException: Object reference not set to an instance of an object)
at Oxide.Plugins.mcTurret.OnTurretTarget (AutoTurret turret, BaseCombatEntity entity) [0x00000] in <9fd93d84f51c4a53b599b579a8a90ddf>:0
at Oxide.Plugins.mcTurret.DirectCallHook (System.String name, System.Object& ret, System.Object[] args) [0x0005e] in <9fd93d84f51c4a53b599b579a8a90ddf>:0
at Oxide.Plugins.CSharpPlugin.InvokeMethod (Oxide.Core.Plugins.HookMethod method, System.Object[] args) [0x00079] in <d09a1f46ca2f4432811bcfe45ad13c7b>:0
at Oxide.Core.Plugins.CSPlugin.OnCallHook (System.String name, System.Object[] args) [0x000d8] in <cf88a28c7fb44d36890d85a78331cc9d>:0
at Oxide.Core.Plugins.Plugin.CallHook (System.String hook, System.Object[] args) [0x00060] in <cf88a28c7fb44d36890d85a78331cc9d>:0
(Filename: C:\buildslave\unity\build\Runtime/Export/Debug/Debug.bindings.h Line: 35)