1. Recently been modifying our servers plugins so they only work at a certain auth level. I wanted to change it so it works based on the permission system. I have registered the permissions under "InitializePermissions" and these are the permissions.
    Code:
                        if (!permission.PermissionExists(permissionmodkits.use)) permission.RegisterPermission(permissionmodkits.use, this);
                        if (!permission.PermissionExists(permissionadminkits.use)) permission.RegisterPermission(permissionadminkits.use, this);
                        if (!permission.PermissionExists(permissionall.use)) permission.RegisterPermission(permissionall.use, this);
    I get this error when compiling "The name `permissionadminkits' does not exist in the current context".

    The line it refers to is this.

    Code:
                if ((!hasPermission(player, permissionadminkits.use)) && (!hasPermission(player, permissionall.use)))
     
  2. Wulf

    Wulf Community Admin

    To start with, don't use the if check with permission.PermissionExists, that is pointless. Only a single plugin can register a permission, this will only break your plugin if another plugin already has it registered and it won't tell you that since you are telling it to ignore registration.

    You also aren't setting the permission right, it should be a string (assuming modkits.use is the perm you want:
    Code:
    permission.RegisterPermission("modkits.use", this);
    Keep in mind that your permissions should be prefixed with your plugin's name, so if you plugin is "MyMod", the permission should start with "mymod." with an end result of something like "mymod.kitsuse" or "mymod.use".
     
  3. It's more that I want to add the ability to give users permission to use particular functions within the kits plugin rather than having it run on authlevel. So an example would be that granting modkits.use lets the user use the /kits list command. Tha make sense?

    Really new to C# and Rust coding, but the syntax isn't too hard as I have done Java before ^_^
     
  4. Wulf

    Wulf Community Admin

    If you are trying to grant permissions that another plugin owns, then you'd need to handle it differently, your current method will not work. You can run the console commands that Oxide provides instead via your plugin.
     
  5. Should've mentioned that I am directly editing the "Kits" plugin by "Reneb". My bad! I just want to make his plugin use the permission system to grant access to different commands, but I think your previous response might have been more than helpful. So thanks!
     
  6. Wulf

    Wulf Community Admin

    You'd need to handle it the way I mentioned in the first reply then, not the 2nd.
     
  7. I have done. No errors in that department. I'm getting this now thought, which is a little odd.

    Code:
    (00:56:25) | [Oxide] 00:56 [Error] kits.cs(476,47): error CS0103: The name `NullValueHandling' does not exist in the current context
    I haven't really modified anything in that area or to do with that. I'm probably being retarded.
     
  8. Wulf

    Wulf Community Admin

    I'd need to see what you added/changed, I can't really guess based on that.
     
  9. Got it down to it now saying

    Code:
    (01:26:20) | [Oxide] 01:26 [Warning] Missing plugin name prefix 'kits.' for permission 'permissionmodkits.use' (by plugin 'Kits')
    (01:26:20) | [Oxide] 01:26 [Warning] Missing plugin name prefix 'kits.' for permission 'permissionadminkits.use' (by plugin 'Kits')
    (01:26:20) | [Oxide] 01:26 [Warning] Missing plugin name prefix 'kits.' for permission 'permissionall.use' (by plugin 'Kits')
    Edit: I'm retarded, sorry. I fixed it... What can I say, I'm tired.
     
    Last edited by a moderator: Apr 21, 2016
  10. Had everything working, now getting this error.

    The permissions are being registered here.

    Code:
            void InitializePermissions()
            {
                foreach (var kit in storedData.Kits.Values)
                {
                    if (!string.IsNullOrEmpty(kit.permission) && !permission.PermissionExists(kit.permission))
                        permission.RegisterPermission(kit.permission, this);
                              
                          
                }
              
            permission.RegisterPermission("kits.useadminskits", this);
            permission.RegisterPermission("kits.useallkits", this);            
            }
    This is the console error.

    Code:
    (15:08:17) | [RCON][109.154.8.216:64147] oxide.grant user Twisted kits.useadminkits
    (15:08:17) | [Oxide] 15:08 [Info] Permission 'kits.useadminkits' doesn't exist
    Edit: "kits.useallkits" works but the other doesn't"
     
    Last edited by a moderator: Apr 21, 2016
  11. Long story short. Re-coded the Kits plugin by Reneb for some extra functionality. I've made it use Oxide permissions rather than using authlevel.

    I created two new permissions, "kits.useadminkits" and "kits.useallkits". The permission for using all kits works, whilst trying to grant myself the admin kits produces this message.

    Code:
    (15:43:12) | [Oxide] 15:43 [Info] Permission 'kits.useadminkits' doesn't exist
    If anyone has any ideas what could cause one to work but not the other, that'd be great! Thanks.
     
  12. Wulf

    Wulf Community Admin

    You registered "kits.useadminskits", but you are trying to grant "kits.useadminkits", notice the difference?
     
  13. Let's pretend I didn't make such a rookie error. Is there a better environment for plugin development in C# for Rust? C# is fairly new to me. Thank you, also.
     
  14. Wulf

    Wulf Community Admin

    Visual Studio 2015 + a local Rust dev server works fine for me.
     
  15. Nice one. Thank you for that!
    [DOUBLEPOST=1461280321,1461262984][/DOUBLEPOST]What do you think would cause this to happen? If I assign myself the "kits.canuseadminkits" permission I should only be able to see/use "/kit list" and "/kit give" but I can use every command.

    This is the permission check.

    Code:
            bool hasPermission(BasePlayer player, string permissionName)
                {
                       
                if (player.net.connection.authLevel > 1) return true;
                return permission.UserHasPermission(player.userID.ToString(), permissionName);
                }
    This is an example of one of the permissions I shouldn't have access to.

    Code:
                        case "resetkits":
                            if ((!hasPermission(player, "kits.useadminkits")) & (!hasPermission(player, "kits.useallkits")))
                            {
                                SendReply(player, NoAccess);
                                return;
                            }
    Currently using auth level one on the account with the "kits.canuseadminkits" permission.
     
  16. Wulf

    Wulf Community Admin

    Try && instead of & for your permission checks.
     
  17. Tried that. It's not having any of it.
     
  18. Wulf

    Wulf Community Admin

    Your hasPermission is also allowing allowing any moderator or owner to use it, without even checking the permissions.
     
  19. Probably a really straight forward answer to this, but how do I get around that? That section of code is essentially the original Kits permission check. Thanks again for the help with this.
     
  20. Wulf

    Wulf Community Admin

    Either remove it and don't do any auth level check, don't test it using a player with owner/moderator, or tweak it to check for all, not just one.