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.
I get this error when compiling "The name `permissionadminkits' does not exist in the current context".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);
The line it refers to is this.
Code:if ((!hasPermission(player, permissionadminkits.use)) && (!hasPermission(player, permissionall.use)))
Trouble modifying Kits plugin with permissions
Discussion in 'Rust Development' started by Twistedwheel, Apr 21, 2016.
-
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);
-
Really new to C# and Rust coding, but the syntax isn't too hard as I have done Java before ^_^ -
Wulf Community Admin
-
-
Wulf Community Admin
-
Code:(00:56:25) | [Oxide] 00:56 [Error] kits.cs(476,47): error CS0103: The name `NullValueHandling' does not exist in the current context
-
Wulf Community Admin
-
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')
Last edited by a moderator: Apr 21, 2016 -
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); }
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
Last edited by a moderator: Apr 21, 2016 -
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
-
Wulf Community Admin
You registered "kits.useadminskits", but you are trying to grant "kits.useadminkits", notice the difference?
-
-
Wulf Community Admin
-
[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); }
Code:case "resetkits": if ((!hasPermission(player, "kits.useadminkits")) & (!hasPermission(player, "kits.useallkits"))) { SendReply(player, NoAccess); return; }
-
Wulf Community Admin
-
-
Wulf Community Admin
-
-
Wulf Community Admin