Hi, i'm trying to build a plugin and I would need to manage permission from across this plugin and others.
But I have an issue with the permission system when compiling :
"Error while compiling SDTR: An object reference is required for the non-static field, method, or property 'CSharpPlugin.permission' | Line: 185, Pos: 34".
Here is my code, line 185 being the one marked XXX :
class SDTR : RustPlugin
{
#region Fields
[PluginReference]
private Plugin Kits, ServerRewards, Backpacks, BlueprintManager, Economics, Skills;
//permissions
private const string ADMIN_PERMISSION = "sdtr.admin";
[etc...]
//dictionary to access all permissions
public static readonly Dictionary<string, string> PERM_DICT = new Dictionary<string, string>()
{
{ "isStarterKit", STARTER_PERMISSION },
{ "isBackpack", BACKPACKS_PERMISSION },
{ "isMagicBackpack", BACKPACKS_RETRIEVE }
};
//class managing all players datas
public class Users
{
[etc..]
//method of class Users to manage permission
public void SetUserPermission(string id, string perm, bool grant)
{
bool result = false;
XXX bool prev_perm = permission.UserHasPermission(id, PERM_DICT[perm]); XXX
if (prev_perm && grant is false)
{
permission.RevokeUserPermission(id, PERM_DICT[perm]);
result = true;
}
else if (!prev_perm && grant is true)
{
permission.GrantUserPermission(id, PERM_DICT[perm], base);
result = true;
}
else
result = false;
if (result)
{
[etc....]I think I might have to cast this line from a plugin object ? But the few things I tried didn't work so if anyone knows what I'm missing, thanks in advance for your help.