1. I'm trying to allow admins with permission to do /report block user, and block a user from using a command in my plugin. I decided to do it by giving a user a permission if I don't want them to use the command. I know you can grant permissions to users via in-game command, but I wan't it to be any user who has the permission discordreport.use. Something like this:
    Code (Text):
    [Command("block")]
    if(player.HasPermission(permBlock)
    {
    //This is the line I'm unsure of how to do. I cannot find any documentation on this.
    targetUser.AddPermission(permIsBlocked);
    }
    obviously that's just psuedo but yea.

    I believe forcing the player to run the '/grant user permission' command would work. Does anyone know how to do that?

    Thanks
     
  2. Wulf

    Wulf Community Admin

    Why do you need them to run the command? Just use permission.GrantPermission if you want to give them a permission.
     
  3. Is that a console command?

    I have to get to work I'll explain after
     
  4. Wulf

    Wulf Community Admin

    It's a method.
     
  5. Not sure what you're asking, but I guess you're looking for:
    Code:
    player.SendConsoleCommand("Command_Here"); //Client Console
    From what I understand, you're trying to block the player's use of the command if they have the permission of your choosing. (Sorry, having difficulty understanding.)
    Code:
    namespace Oxide.Plugins
    {
        [Info("Test Plugin", "Kappasaurus", "0.1.")]
        class TestPlugin : RustPlugin
        {
            void Loaded() => permission.RegisterPermission("testplugin.blockuse", this);
            [ChatCommand("test")]
            void cmdTest(BasePlayer player, string cmd, string[] args)
            {
                if (!permission.UserHasPermission(player.userID.ToString(), "testplugin.blockuse"))
                {
                    //Command Code Here
                }
                else
                {
                    //Command Block Message
                    //SendReply(player, "...");
                }
            }
        }
    }
     
    Last edited by a moderator: Feb 15, 2017
  6. What you gave might work, but what wolf gave is much easier and more realistic to what I need.
     
  7. If you're revoking/granting permissions, of course it is. My code was based off "I decided to do it by giving a user a permission if I don't want them to use the command.", which is basically what that code is setup to do, you just would have to grant the permission manually, which I assumed is what you wanted.