An overall look at how permissions work and how you can use them.
Permission registration
A good place to start using permissions in your plugins, here's how you register your permissions within your plugin. Usually done at the very beginning of your plugin, which can be Init() or OnServerInitialized().
To use your newly registered permissions, you may use the following format:
privatevoidOnPlayerConnected(BasePlayer player){if(permission.UserHasPermission(player.UserIDString,"myplugin.admin")) { // Do admin stuff. }}
Groups registration
To get all the groups available on a server, you may use this:
var groups =permission.GetGroups();
To create a new group, you can do this:
var rank =0;if(permission.CreateGroup("mygroup","Group Display Name", rank)){Puts("Group has been created successfully!");}else{Puts("Couldn't create group. Probably because it already exists.");}
To delete a group:
if(permission.RemoveGroup("mygroup")){Puts("Group has been successfully deleted.");}else{Puts("Couldn't delete group. Probably because it doesn't exist.");}
var permissions =permission.GetGroupPermissions("mygroup",false);// 'false' is the value for the "parents" parameter. When true, it will return all permissions, including the parent permissions "mygroup" group is a part of. When false, it will only return "mygroup" permissions.
Get the rank value of a group:
var rank =permission.GetGroupRank("mygroup");
Get the display title of a group:
var displayName =permission.GetGroupTitle("mygroup");