1. Please anyone help me

    How to block a command in console.
    The command 'craft.add' have a bug to craft 999999 C4

    Please help me, i have used the args.cmd.namefull and not work ;-;
     
    Last edited by a moderator: Mar 18, 2018
  2. Code:
            private object OnServerCommand(ConsoleSystem.Arg arg)
            {
                if (arg.Player() == null) return null;
                if (arg.cmd?.Name == null) return null;
                if (arg.cmd.Name == "craft.add")
                {
                    return false;
                }
                return null;
            }
                   
    
     
  3. Not work ;-;
     
  4. Wulf

    Wulf Community Admin

    You can use the CommandBlock plugin for this, otherwise the code provided above should work fine.
     
  5. The commandblock of the 2016 not work to block craft.add ;--; and this command too
    [DOUBLEPOST=1521355762][/DOUBLEPOST]I wanted to edit in assembly-csharp.dll but every time I will compile this same error occurs:
    https://i.imgur.com/biKWOZN.png
     
    Last edited by a moderator: Mar 18, 2018
  6. craft.add is nor useable by anyone. It may be if you are an admin, otherwise this command has no use.
     
  7. Try this:
    Code:
            private List<string> blackCmd = new List<string>() { "craft.add" };        private object OnServerCommand(ConsoleSystem.Arg arg)
            {
                if (arg.Connection == null) return null;            foreach (var cmd in blackCmd)
                    return arg.Player().IsAdmin ? (object)null : arg.cmd?.Name != cmd;            return null;
            }
    
     
  8. That's a terrible implementation. You're only checking the first element in that list, which is not at all scalable. Secondly, your return value is non-null if the player isn't an admin and the connection isn't null, always, which will prohibit the user from executing the command regardless of it's value. A proper solution would return a non-null value if the list contains the command.
    Code:
    return /* this name needs some work */ blackCmd.Contains(arg.cmd?.Name) ? false : (object)null;