1. Hello. Immediately apologize for my English. I use a translator.
    Can you tell what could be the reason?
    Code:
    [Oxide] 12:04 [Error] Failed to call hook 'CommandConsoleAuth' on plugin 'FriendAuthorization v1.0.0' (NullReferenceException: Object reference not set to an instance of an object)
    [Oxide] 12:04 [Debug]   at Oxide.Plugins.FriendAuthorization.<AuthorizationCodeLocks>m__2 (.CodeLock codeLock, .BasePlayer friend) [0x00000] in <filename unknown>:0
      at Oxide.Plugins.FriendAuthorization.Authorization[CodeLock] (.BasePlayer player, System.Collections.Generic.List`1 entities, System.String completionLang, System.String noEntityLang, System.Action`2 execute) [0x00000] in <filename unknown>:0
      at Oxide.Plugins.FriendAuthorization.AuthorizationCodeLocks (.BasePlayer player) [0x00000] in <filename unknown>:0
      at Oxide.Plugins.FriendAuthorization.CommandConsoleAuth (.Arg arg) [0x00000] in <filename unknown>:0
      at Oxide.Plugins.FriendAuthorization.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
    Code:
    [ConsoleCommand("auth")]
            private void CommandConsoleAuth(ConsoleSystem.Arg arg)
            {
                if (arg.connection == null || arg.Player() == null || !arg.HasArgs()) return;            switch (arg.Args[0].ToLower())
                {
                    case "a.cupboard":
                        AuthorizationCupboard(arg.Player());
                        return;
                    case "a.autoturret":
                        AuthorizationAutoTurret(arg.Player());
                        return;
                    case "a.codelock":
                        AuthorizationCodeLocks(arg.Player());
                        return;
                    case "d.cupboard":
                        DeauthorizationCupboard(arg.Player());
                        return;
                    case "d.autoturret":
                        DeauthorizationAutoTurret(arg.Player());
                        return;
                    case "d.codelock":
                        DeauthorizationCodeLocks(arg.Player());
                        return;
                }
            }
     
    Last edited by a moderator: May 5, 2017
  2. Wulf

    Wulf Community Admin

    The error is likely in either the DeauthorizationAutoTurret or AuthorizationCupboard methods. Also, I'd suggest using arg.Player() once before the null checks like var player = arg.Player(); and then checking that for null once instead of converting to player each time.
     
  3. Thank you. And could you show me how to do it? Just not my plugin, and writing plugins, I am not strong.
     
  4. Wulf

    Wulf Community Admin

    Could you post the rest of those methods?
     
  5. --snipped--
     
    Last edited by a moderator: May 5, 2017
  6. Wulf

    Wulf Community Admin

    Since the error shows something with code locks, your issue likely lies with AuthorizationCodeLocks. Add some null checks and debug output.

    The likely cause though is the whitelistPlayers reflection you are using, as that is public now and will error when trying to reflect it.
     
    Last edited: May 5, 2017
  7. Thank you. If possible, delete the topic.