I'm newbie. I try create console command but i always het the error:
My code:Code:[Oxide] 20:34 [Error] Failed to call hook 'RandomCommand' on plugin 'dezola v0.1.0' (NullReferenceException: Object reference not set to an instance of an object) [Oxide] 20:34 [Debug] at Oxide.Plugins.Dezola.RandomCommand (.Arg arg) [0x00000] in <filename unknown>:0 at Oxide.Plugins.Dezola.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
What am i doing wrong??Code:[ConsoleCommand("random")] private void RandomCommand(ConsoleSystem.Arg arg) { BasePlayer player = (BasePlayer)arg?.connection?.player ?? null; int Range = Core.Random.Range(0, Weapons.Length); var item = ItemManager.CreateByName(Weapons[Range]); player.GiveItem(item); // Puts("Yeah!"); }
Console Command. Error NullReferenceException
Discussion in 'Rust Development' started by Kuhulin, Jun 16, 2016.
