Sign in to follow this  
Followers 0
Kavawuvi

Admin Groups

This script can be used as a supplement to SAPP's minimal admin system, by introducing groups that are allowed to execute different commands, essentially whitelisting the commands they can use. It allows for much more customization of admins than just using admin levels.
 
Here are some examples of groups. They're only some examples:

  • a group that is in charge of every admin functionality, but has no access to the "naughty" commands or cheat commands
  • a group that has access to certain naughty and cheat commands, but not all of them
  • a group that has access to every command, but still give other admins access to certain level 4 commands

What makes this script even more helpful is that it's not limited to a level system like SAPP. You can choose to have two different groups have access to different commands that the other group doesn't have. You can also reload the groups without reloading SAPP using the reload_groups command. Know that scrim_mode will disable this script - If you don't want admins using cheat commands, don't let them use cheat commands.
 
Setting up the script takes a little bit more effort than most other scripts:
 
First, you're going to want to install the separate JSON parser that I'm using, as permissions are stored in JSON format. You can get it here, but I'll also mirror it on this page as well. Place this file in your SAPP folder.
 
Next, load the script and edit the groups.json file that's in the SAPP folder. This is what it will generate if there is no groups.json file.
 

{
  "group_default": "default",
  "groups": {
    "admin": {
      "commands": [ "sv_map", "map", "sv_maplist", "sv_gamelist", "sv_map_reset", "st", "kill" ],
      "inherit": "moderator"
    },
    "default": {
      "commands": [ "afk", "pl" ]
    },
    "moderator": {
      "commands": [ "ipbans", "inf", "ipunban", "ub" ],
      "inherit": "submoderator"
    },
    "submoderator": {
      "commands": [ "k", "sv_kick", "bans", "mute", "textban", "textbans", "mutes", "unmute", "textunban", "sv_ban", "b" ],
      "inherit": "default"
    },
    "superadmin": {
      "all_commands": true,
      "commands": [],
      "inherit": "admin"
    }
  },
  "hashes": {
    "examplehash12345678": "default"
  },
  "ignore_commands": [ "stfu", "unstfu", "info", "stats", "sv_stats", "about", "whatsnext", "login", "lead", "clead", "list" ],
  "ignore_rcon": false
}

Edit this file. "hashes" are the player hashes followed by their group. You can get hashes using the inf command if the player is online. For more information, see this post.

 

You can then execute the command reload_groups to reload the permissions.
 
With this setup (generated by default), if a player has the group moderator, moderator inherits from submoderator which inherits from default. This means that they have access to all moderator, submoderator, and default commands. Because ignore_rcon is set to false, rcon commands are also checked. Players that are not listed are assigned to group_default's group, which is the "default" group. Players in the superadmin group have "all_commands" enabled, giving them unrestricted access to every command.
 
Note that SAPP's admin system has the final say, and will deny players commands if their admin levels are not high enough. You can circumvent this by setting players' level to a level that would execute the commands you want them to be allowed to execute.
 
JSON.lua (place in sapp folder): JSON.lua
groups.lua (SAPP plugin): groups.lua

HAN-105 and Takka like this

Share this post


Link to post
Share on other sites

Tiddy-bits:

How To Use it ? How can i add another admin player ?

Edited by HAN-105

Share this post


Link to post
Share on other sites

How To Use it ? How can i add another admin player ?

Edit the groups.json file that appears in your SAPP folder after running the script. Obviously it's in JSON format, so you'll need to understand how the JSON format works. There's a site that's all about it at http://www.json.org.

The default file will look like this:

 

{
  "group_default": "default",
  "groups": {
    "admin": {
      "commands": [ "sv_map", "map", "sv_maplist", "sv_gamelist", "sv_map_reset", "st", "kill" ],
      "inherit": "moderator"
    },
    "default": {
      "commands": [ "afk", "pl" ]
    },
    "moderator": {
      "commands": [ "ipbans", "inf", "ipunban", "ub" ],
      "inherit": "submoderator"
    },
    "submoderator": {
      "commands": [ "k", "sv_kick", "bans", "mute", "textban", "textbans", "mutes", "unmute", "textunban", "sv_ban", "b" ],
      "inherit": "default"
    },
    "superadmin": {
      "all_commands": true,
      "commands": [],
      "inherit": "admin"
    }
  },
  "hashes": {
    "examplehash12345678": "default"
  },
  "ignore_commands": [ "stfu", "unstfu", "info", "stats", "sv_stats", "about", "whatsnext", "login", "lead", "clead", "list" ],
  "ignore_rcon": false
}
I'll break it down:

 

{
  "group_default": "default",
  "groups": {
    "admin": {
      "commands": [ "sv_map", "map", "sv_maplist", "sv_gamelist", "sv_map_reset", "st", "kill" ],
      "inherit": "moderator"
    },
    "default": {
      "commands": [ "afk", "pl" ]
    },
    "moderator": {
      "commands": [ "ipbans", "inf", "ipunban", "ub" ],
      "inherit": "submoderator"
    },
    "submoderator": {
      "commands": [ "k", "sv_kick", "bans", "mute", "textban", "textbans", "mutes", "unmute", "textunban", "sv_ban", "b" ],
      "inherit": "default"
    },
    "superadmin": {
      "all_commands": true,
      "commands": [],
      "inherit": "admin"
    }
  },
The second line is "group_default". This determines what the default group is (the group that everyone is in if they're not in a group).

The following groups are the various default groups. You can delete all of them, but you want to make sure that there's at least a default group. You can name the default group anything you want, as long as "group_default" is set to the name of the default group. If you don't have a default group, then players that aren't in a group cannot execute any commands.

Each group looks like this:

 

    "admin": {
      "commands": [ "sv_map", "map", "sv_maplist", "sv_gamelist", "sv_map_reset", "st", "kill" ],
      "inherit": "moderator"
    },
"commands" are a list of commands that the group can get. "inherit" is the name of the group that this group inherits from. Groups can only inherit from one group, and it is recursive, so it gets every command from the group it inherits from, and any groups that that group inherits from, and so on. In this case, "admin" gets "moderator", which gets "submoderator", which gets "default".

Next, we have the hashes.

 

    "hashes": {
      "examplehash12345678": "default"
    },
A player that has the hash examplehash12345678 will be in the "default" group. You can get hashes using the inf command, which then you just add your own hash. This is what multiple hashes would look like:

 

    "hashes": {
      "hash12345678_1": "admin",
      "hash12345678_2": "superadmin",
      "hash12345678_3": "moderator"
    },
The first hash, hash12345678_1, is in the admin group. hash12345678_2 is in the superadmin group. hash12345678_3 is in the moderator group.

Lastly, some extra settings.

 

  "ignore_commands": [ "stfu", "unstfu", "info", "stats", "sv_stats", "about", "whatsnext", "login", "lead", "clead", "list" ],
  "ignore_rcon": false
ignore_commands, by default, contains the commands that SAPP normally allows all players to use. These commands are automatically allowed regardless of what group the user is in.

ignore_rcon is set to false, but if you set it to true, then rcon commands will bypass the Admin Groups script, and will not be checked.

NeX likes this

Share this post


Link to post
Share on other sites
Sign in to follow this  
Followers 0
  • Recently Browsing   0 members

    No registered users viewing this page.