Heyo!
One man that use my plugin has run into the NRE, wich I thought impossible. So - the problem is, that in this cycle SendConsoleCommand crashes with NRE.
Here is the cycle itself:
This function called SendChat, and here is the error:Code:foreach (var player in BasePlayer.activePlayerList) { player?.SendConsoleCommand("chat.add", userId, string.IsNullOrEmpty(name) ? $"{msg}" : $"{name}: {msg}"); }
I didn't think that it's possible, but.... Can it be that while iterating activePlayerList some of the players went offline? Cos overwise, I'm out of ideas....Code:11:50 [Error] Failed to call hook 'OnUserChat' on plugin 'ChatPlus v1.3.4' (NullReferenceException: Object reference not set to an instance of an object) 11:50 [Stacktrace] at BasePlayer.SendConsoleCommand (System.String command, System.Object[] obj) [0x00000] in <filename unknown>:0 at Oxide.Plugins.ChatPlus.SendChat (System.String name, System.String message, System.String censorMessage, System.String userId) [0x00000] in <filename unknown>:0 at Oxide.Plugins.ChatPlus.OnUserChat (IPlayer sender, System.String message) [0x00000] in <filename unknown>:0 at Oxide.Plugins.ChatPlus.DirectCallHook (System.String name, System.Object& ret, System.Object[] args) [0x00000] in <filename unknown>:0 at Oxide.Plugins.CSharpPlugin.InvokeMethod (Oxide.Core.Plugins.HookMethod method, System.Object[] args) [0x00000] in <filename unknown>:0 at Oxide.Core.Plugins.CSPlugin.OnCallHook (System.String name, System.Object[] args) [0x00000] in <filename unknown>:0 at Oxide.Core.Plugins.Plugin.CallHook (System.String hook, System.Object[] args) [0x00000] in <filename unknown>:0
NRE in SendConsoleCommand
Discussion in 'Rust Development' started by Vlad-00003, Oct 29, 2017.