Hello guys i have problem
I dont know, what me do, please help me.Code:[Error] Failed to call hook 'conscmd' on plugin 'DeployBlock v1.0.0' (NullReferenceException: Object reference not set to an instance of an object) (17:57:14) | [Oxide] 12:57 [Debug] at Oxide.Plugins.DeployBlock.conscmd (.Arg arg) [0x00000] in <filename unknown>:0 at Oxide.Plugins.DeployBlock.DirectCallHook (System.String name, System.Object& ret, System.Object[] args) [0x00000] in <filename unknown>:0 at Oxide.Plugins.CSharpPlugin.InvokeMethod (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 name, System.Object[] args) [0x00000] in <filename unknown>:0
Solved NullReferenceException in my plugin
Discussion in 'Rust Development' started by Joonyy, Oct 27, 2016.
-
Wulf Community Admin
I'd need to add some null checks to figure out what is null.
-
Code:
[ConsoleCommand("deployblock")] void conscmd(ConsoleSystem.Arg arg) { var player = arg.connection?.player as BasePlayer; if (!player.IsAdmin()) return; if (arg.Args==null) return; if (arg.Args.Length == 2 && arg.Args[0] == "start") { int min; if(!Int32.TryParse(arg.Args[1], out min)) return; data.minutes = min; data.blocked = true; timingFile.WriteObject(data); } if (arg.Args.Length ==1 && arg.Args[0] == "stop") { data.blocked = false; timingFile.WriteObject(data); -
Wulf Community Admin
I'd suggest adding a null check to player before you try checking if it is admin. -
It will be so?Code:
if (!player==null)return;
-
Wulf Community Admin
if (player == null) return; -
I dont see message of eror, but plugin dont work, how do it? Please help me.
-
Wulf Community Admin
Are you trying to use the command in the server console or RCON? A player will not exist in those cases, so you'd need to not use player checks. -
If i in game that it's work, if i use rcon console and i out of game it's dont work
[DOUBLEPOST=1477583215][/DOUBLEPOST]Thanks your Wolf for your Attention and help.
