Players getting kicked when they fire a weapon

Hi, I'm getting this error spamming my console whenever scientist NPCs shoot, and players are getting kicked from the server with it:

NullReferenceException: Object reference not set to an instance of an object
at BaseEntity.SignalBroadcast_Patch1(...)
at BaseProjectile.ServerUse(...)
at NPCPlayer.TriggerDown()
at NPCPlayer.ShotTest(...)
at ScientistNPC.ShotTest(...)

Server: Oxide, no Carbon, no HarmonyMods. Vanish is the only plugin patching SignalBroadcast (confirmed in the console on load).

I think the cause is in BaseNetworkable_GetConnectionsWithin_Patch.Postfix:

Line 1111: __result.Add(vanishPlayer.Connection);

This can add a null Connection to the list when a vanished player is offline or reconnecting. The null check on line 1090 only checks vanishPlayer, not vanishPlayer.Connection. SignalBroadcast then goes through that list and crashes on the null, and that seems to be what kicks the players.

Suggested fix:
Line 1090: if (vanishPlayer == null || vanishPlayer.Connection == null) continue;
Line 1102: if (__result[i] != null && __result[i].userid == vanishPlayer.userID)

I've applied this fix locally. Could you include it in the next update?

Thanks!

Same here, in my server it begin happening when i (owner using vanish) disconnected.

Failed to call hook 'OnPlayerDisconnected' on plugin 'Vanish v2.1.6' (ArgumentException: An item with the same key has already been added. Key: Notz[xxxxxxxxxxxxxxxxxxxxxx])
  at System.Collections.Generic.Dictionary`2[TKey,TValue].TryInsert (TKey key, TValue value, System.Collections.Generic.InsertionBehavior behavior) [0x0015a] in <239c1f78a64c42c29c04241c777f1859>:0 
  at System.Collections.Generic.Dictionary`2[TKey,TValue].Add (TKey key, TValue value) [0x00000] in <239c1f78a64c42c29c04241c777f1859>:0 
  at ListHashSet`1[T].Add (T val) [0x0000c] in <b2729a1311c54a30aaa963a6d47d4dc5>:0 
  at Oxide.Plugins.Vanish.Disappear (BasePlayer player) [0x00109] in <c0643a06d8624ec5bdb37f5836ef904b>:0 
  at Oxide.Plugins.Vanish.OnPlayerDisconnected (BasePlayer player, System.String reason) [0x00020] in <c0643a06d8624ec5bdb37f5836ef904b>:0 
  at Oxide.Plugins.Vanish.DirectCallHook (System.String name, System.Object& ret, System.Object[] args) [0x0061c] in <c0643a06d8624ec5bdb37f5836ef904b>:0 
  at Oxide.Plugins.CSharpPlugin.InvokeMethod (Oxide.Core.Plugins.HookMethod method, System.Object[] args) [0x00079] in <42f9bedc659b4f4786eb778d3cd58968>:0 
  at Oxide.Core.Plugins.CSPlugin.OnCallHook (System.String name, System.Object[] args) [0x000de] in <db058accaef24d86af67c0d18d641acb>:0 
  at Oxide.Core.Plugins.Plugin.CallHook (System.String hook, System.Object[] args) [0x00060] in <db058accaef24d86af67c0d18d641acb>:0 

NullReferenceException: Object reference not set to an instance of an object
  at (wrapper dynamic-method) MonoMod.Utils.DynamicMethodDefinition.BaseEntity.SignalBroadcast_Patch1(BaseEntity,BaseEntity/Signal,string,Network.Connection,string,single)
  at BaseProjectile.ProcessCLProject (BaseEntity+RPCMessage msg, System.Boolean verified, BaseMountable mount) [0x001e3] in <b76989ccf18f41a281254aab1dd59a34>:0 
  at BaseProjectile.CLProject (BaseEntity+RPCMessage msg) [0x0000e] in <b76989ccf18f41a281254aab1dd59a34>:0 
  at BaseProjectile.OnRpcMessage (BasePlayer player, System.UInt32 rpc, Network.Message msg) [0x000ff] in <b76989ccf18f41a281254aab1dd59a34>:0 
UnityEngine.DebugLogHandler:Internal_LogException_Injected(Exception, IntPtr)
UnityEngine.DebugLogHandler:Internal_LogException(Exception, Object)
UnityEngine.DebugLogHandler:LogException(Exception, Object)
UnityEngine.Logger:LogException(Exception, Object)
UnityEngine.Debug:LogException(Exception)
BaseProjectile:OnRpcMessage(BasePlayer, UInt32, Message)
BaseEntity:SV_RPCMessage(UInt32, Message)
ServerMgr:OnRPCMessage(Message)
ServerMgr:OnNetworkMessage(Message)
Facepunch.Network.Raknet.Server:ProcessRead(NetRead)
MonoMod.Utils.DynamicMethodDefinition:Network.BaseNetwork.Cycle_Patch0(BaseNetwork)
MonoMod.Utils.DynamicMethodDefinition:ServerMgr.Update_Patch0(ServerMgr)​
Failed to run a 3.00 timer in 'Vanish v2.1.6' (ArgumentException: An item with the same key has already been added. Key: BAGIRA ❤)
  at System.Collections.Generic.Dictionary`2[TKey,TValue].TryInsert (TKey key, TValue value, System.Collections.Generic.InsertionBehavior behavior) [0x0015a] in <b2ed3aa968d84284a17b07ec9195055c>:0
at System.Collections.Generic.Dictionary`2[TKey,TValue].Add (TKey key, TValue value) [0x00000] in <b2ed3aa968d84284a17b07ec9195055c>:0
at ListHashSet`1[T].Add (T val) [0x0000c] in <04cc789e4c0f4bad99f13891e52eae76>:0
at Oxide.Plugins.Vanish.Disappear (BasePlayer player) [0x00109] in <a836dbf1502643329b8fac380fe417da>:0
at Oxide.Plugins.Vanish.OnPlayerConnected (BasePlayer player) [0x00199] in <a836dbf1502643329b8fac380fe417da>:0
at Oxide.Plugins.Vanish+<>c__DisplayClass36_0.<OnPlayerConnected>b__0 () [0x00000] in <a836dbf1502643329b8fac380fe417da>:0
at Oxide.Core.Libraries.Timer+TimerInstance.FireCallback () [0x00018] in <db058accaef24d86af67c0d18d641acb>:0

i did feed into Claude, and it fixed for me this issue above pointed out.

 

worth to delete the config file, and the plugin, and start from scratch, to setup.

 

might help - just a thougt.

Same here:

 

11/20 16:19:56 | NullReferenceException: Object reference not set to an instance of an object
11/20 16:19:56 | NullReferenceException: Object reference not set to an instance of an object
11/20 16:19:57 | System.NullReferenceException: Object reference not set to an instance of an object
at Oxide.Plugins.Vanish+BaseNetworkable_GetConnectionsWithin_Patch.Postfix (System.Collections.Generic.List`1[Network.Connection]& __result, UnityEngine.Vector3 position, System.Single distance, System.Boolean includeInvisPlayers) [0x0006f] in <a958c92a096a4001b62c2c8efc1223a7>:0
at (wrapper dynamic-method) MonoMod.Utils.DynamicMethodDefinition.BaseNetworkable.GetConnectionsWithin_Patch2(UnityEngine.Vector3,single,bool)
at (wrapper dynamic-method) MonoMod.Utils.DynamicMethodDefinition.BaseEntity.SignalBroadcast_Patch2(BaseEntity,BaseEntity/Signal,string,Network.Connection,string,single)
at BaseProjectile.ServerUse (HeldEntityServerUseParams parameters) [0x0016e] in <b76989ccf18f41a281254aab1dd59a34>:0
at NPCPlayer.TriggerDown () [0x00031] in <b76989ccf18f41a281254aab1dd59a34>:0
at NPCPlayer.ShotTest (System.Single targetDist) [0x00110] in <b76989ccf18f41a281254aab1dd59a34>:0
at ScientistNPC.ShotTest (System.Single targetDist) [0x00000] in <b76989ccf18f41a281254aab1dd59a34>:0
at HumanNPC.TickAttack (System.Single delta, BaseCombatEntity target, System.Boolean targetIsLOS) [0x00106] in <b76989ccf18f41a281254aab1dd59a34>:0
at HumanNPC.AttackTick (System.Single delta, BaseEntity target, System.Boolean targetIsLOS) [0x00007] in <b76989ccf18f41a281254aab1dd59a34>:0
at AttackTickAIEvent.Execute (AIMemory memory, AIBrainSenses senses, StateStatus stateStatus) [0x00042] in <b76989ccf18f41a281254aab1dd59a34>:0
at AIEvents.Tick (System.Single deltaTime, StateStatus stateStatus) [0x000c3] in <b76989ccf18f41a281254aab1dd59a34>:0
at BaseAIBrain.Think (System.Single delta) [0x00085] in <b76989ccf18f41a281254aab1dd59a34>:0
at BaseAIBrain.DoThink () [0x0000d] in <b76989ccf18f41a281254aab1dd59a34>:0
at HumanNPC.ServerThink (System.Single delta) [0x0001a] in <b76989ccf18f41a281254aab1dd59a34>:0
at NPCPlayer.ServerThink_Internal () [0x00016] in <b76989ccf18f41a281254aab1dd59a34>:0
at HumanNPC.TryThink () [0x00000] in <b76989ccf18f41a281254aab1dd59a34>:0
at AIThinkManager.DoProcessing (ListHashSet`1[T] process, System.Single budgetSeconds, System.Int32& last) [0x00014] in <b76989ccf18f41a281254aab1dd59a34>:0
11/20 16:19:57 | NullReferenceException: Object reference not set to an instance of an object
11/20 16:19:57 | NullReferenceException: Object reference not set to an instance of an object