S&box should give a standard way to check if a player has X permission, outside of gamemodes

Now before you get all hyped up and start typing "it already has Sandbox.Player.HasPermission(string)", let me finish:

That’s good, for gamemodes. Not for addons, as they can’t override the gamemode’s player to override that method.

That should be moved to an external event that can be overridden, so that addons like administrative ones can implement their own permission check on top of the standard one, regardless of the current gamemode.

Perhaps something of the sort?

// Global Permissions class to check if a player has a permission.
Permissions.HasPermission(Player, "some.permission.string")

public enum PermissionValue
{
    None = 0,
    Granted = 1,
    Denied = 2,
}

// Implement your own permission checks using an interface, maybe `IPermissionHandler`?
public interface IPermissionHandler
{
    PermissionValue HasPermission(Player ply, string permission);
}

Have the IPermissionHandler interface use that instead of a boolean. Return None if you don’t want to handle said permission. If no implementation returns Granted, default to Denied.

Permissions.HasPermission() can still return a boolean since at the end, the user doesn’t care about None.

That way, developers can implement many ways to check if a player has a permission outside of the gamemode, using a standard so they can “co-operate”.

8 Likes

We can always create our own permission system. But for it to work, all addons and servers should use the same administrative addon like gmod and ULX

1 Like

just because gmod has ULX and its widely used it doesnt mean that we should only have 1 admin system

it should be easy to just make your own as you sometimes dont wanna have a bloated admin system just to manage permissions and groups

3 Likes

Yes u’re right. That was just an idea but if s&box could integrate a such thing it would be much better

2 Likes

If s&box has a good standard one, everything will be able to use it and work hand to hand. So instead of something third party like CAMI, it’ll be included in the game directly.

2 Likes