Permissions Configuration

This guide explains how to configure permissions for the admin menu in your RedM server. Permissions control what actions different roles (e.g., Helper, Moderator, Admin) can perform in the admin panel. The configuration is defined in Config.Permissions in the config/main.lua file. Each role has a label, color scheme, permission list, and level, which determine its capabilities and visual appearance.

Understanding the Permissions System

  • Roles: Each role (e.g., Helper, Admin) is defined with a unique set of permissions, a display label, and a level (lvl) to indicate hierarchy.

  • Permissions: Specific actions a role can perform, such as banning players, viewing logs, or teleporting. Permissions are listed explicitly or use "*" to grant all permissions.

  • Role Colors: Tailwind CSS classes are used to style the role’s appearance in the admin menu (e.g., background, text, and border colors).

  • Level (lvl): A numerical value indicating the role’s rank (higher is more senior). For example, Owner (lvl 5) has more authority than Helper (lvl 1).

Configuration Example

Below is the provided Config.Permissions configuration, with explanations of each role and its permissions:

Config.Permissions = {
    ["helper"] = {
        label = "Helper",
        roleColors = {
            color = "bg-yellow-500", -- Main color (yellow) for the role
            bg = "bg-yellow-50", -- Light yellow background
            text = "text-yellow-600", -- Medium yellow text
            border = "border-yellow-200" -- Light yellow border
        },
        permissions = {
            "livemap.action", -- Perform actions on the live map
            "view.livemap", -- View the live map
            "access_admin_panel", -- Access the admin panel
            "show_banned_players", -- View banned players
            "ban_history", -- View ban history
            "unban_player", -- Unban players
            "edit_ban", -- Edit existing bans
            "get_player_warnings", -- View player warnings
            "close_server_for_players", -- Close server to new players
            "ignore_while_kicking_allplayers", -- Exempt from mass kicks
            "refresh_resouces", -- Refresh server resources
            "schedule_restart", -- Schedule server restarts
            "send_announcement", -- Send server-wide announcements
            "access_logs", -- View server logs
            "players_page", -- Access the players page
            "player.revive", -- Revive players
            "player.kick", -- Kick players
            "player.ban.permanent", -- Issue permanent bans
            "player.ban.temporary", -- Issue temporary bans
            "player.heal", -- Heal players
            "player.respawn", -- Respawn players
            "player.kill", -- Kill players
            "player.teleport.to_player", -- Teleport to a player
            "player.teleport.bring", -- Bring a player to you
            "player.freeze", -- Freeze a player
            "player.inventory.remove_items", -- Remove items from player inventory
            "player.inventory.clear", -- Clear a player’s inventory
            "player.warn", -- Warn a player
            "player.removewarn", -- Remove a player’s warning
            "player.removeweapon", -- Remove a player’s weapon
            "player.spectate", -- Spectate a player
            "remove.item.from_player", -- Remove specific items from a player
            "add.item.to_player", -- Add items to a player
            "add.xp", -- Add XP to a player
            "remove.xp", -- Remove XP from a player
            "set.nickname", -- Set a player’s nickname
            "set.chardescription", -- Set a player’s character description
            "set.age", -- Set a player’s age
            "set.lastname", -- Set a player’s last name
            "set.firstname", -- Set a player’s first name
            "set.jobgrade", -- Set a player’s job grade
            "set.joblabel", -- Set a player’s job label
            "set.jobwithgrade", -- Set a player’s job with a specific grade
            "currency.addorremove", -- Add or remove currency
            "resource.action", -- Perform resource-related actions
            "admin.kickall", -- Kick all players
            "admin.reports.view", -- View reports
            "admin.reports.claim", -- Claim a report
            "admin.reports.resolve", -- Resolve a report
            "admin.reports.reopen", -- Reopen a report
            "admin.reports.message", -- Send messages in reports
            "player.teleport.locations", -- Teleport to specific locations
            "player.teleport.anywhere", -- Teleport anywhere
            "player.teleport.manage", -- Manage teleport locations
            "admin.action", -- Perform admin actions
            "change.admin.role", -- Change a player’s admin role
            "refresh_resources", -- Refresh server resources
            "whitelist.add", -- Add players to whitelist
            "whitelist.remove", -- Remove players from whitelist
            "whitelist.suspend", -- Suspend players from whitelist
            "whitelist.edit" -- Edit whitelist entries
        },
        lvl = 1, -- Lowest rank
    },
    ["moderator"] = {
        label = "Moderator",
        roleColors = {
            color = "bg-green-500", -- Main color (green)
            bg = "bg-green-50", -- Light green background
            text = "text-green-600", -- Medium green text
            border = "border-green-200" -- Light green border
        },
        permissions = {"*"}, -- Grants all permissions
        lvl = 2, -- Higher than Helper
    },
    ["admin"] = {
        label = "Admin",
        roleColors = {
            color = "bg-blue-500", -- Main color (blue)
            bg = "bg-blue-50", -- Light blue background
            text = "text-blue-600", -- Medium blue text
            border = "border-blue-200" -- Light blue border
        },
        permissions = {"*"}, -- Grants all permissions
        lvl = 3, -- Higher than Moderator
    },
    ["headadmin"] = {
        label = "Head Admin",
        roleColors = {
            color = "bg-purple-500", -- Main color (purple)
            bg = "bg-purple-50", -- Light purple background
            text = "text-purple-600", -- Medium purple text
            border = "border-purple-200" -- Light purple border
        },
        permissions = {"*"}, -- Grants all permissions
        lvl = 4, -- Higher than Admin
    },
    ["owner"] = {
        label = "Owner",
        roleColors = {
            color = "bg-red-500", -- Main color (red)
            bg = "bg-red-50", -- Light red background
            text = "text-red-600", -- Medium red text
            border = "border-red-200" -- Light red border
        },
        permissions = {"*"}, -- Grants all permissions
        lvl = 5, -- Highest rank
    }
}

Explanation of the Configuration

  • Helper Role:

    • Label: Displayed as "Helper" in the admin menu.

    • Colors: Uses yellow-themed Tailwind CSS classes for visual distinction (e.g., bg-yellow-500 for a bold yellow background).

    • Permissions: A detailed list of specific permissions, allowing Helpers to perform tasks like banning, teleporting, managing inventory, and viewing reports, but not all actions (e.g., no access to some advanced admin features).

    • Level: lvl = 1, the lowest rank, suitable for entry-level staff.

  • Moderator, Admin, Head Admin, and Owner Roles:

    • Label: Each has a unique label (e.g., "Moderator", "Admin") for display.

    • Colors: Each role uses a distinct color scheme (e.g., green for Moderator, blue for Admin, purple for Head Admin, red for Owner) to differentiate them visually.

    • Permissions: Use "*" to grant access to all permissions, giving these roles full control over the admin menu’s features.

    • Level: Higher levels (2 for Moderator, 3 for Admin, 4 for Head Admin, 5 for Owner) indicate increasing authority.

How to Customize Permissions

  1. Add a New Role:

    • Copy an existing role block (e.g., helper) and modify its label, roleColors, permissions, and lvl.

    • Example: To add a "Support" role with limited permissions:

      ["support"] = {
          label = "Support",
          roleColors = {
              color = "bg-teal-500",
              bg = "bg-teal-50",
              text = "text-teal-600",
              border = "border-teal-200"
          },
          permissions = {
              "access_admin_panel",
              "admin.reports.view",
              "admin.reports.message"
          },
          lvl = 0
      }
  2. Modify Permissions:

    • For roles like helper, add or remove permissions from the permissions table to control access. For example, remove "player.ban.permanent" to prevent Helpers from issuing permanent bans.

    • For roles with "*", no changes are needed unless you want to restrict specific actions (replace "*" with a specific list).

  3. Change Colors:

    • Update roleColors using Tailwind CSS classes. For example, change bg-yellow-500 to bg-orange-500 for a different color scheme. Refer to the Tailwind CSS documentation for available colors.

  4. Adjust Levels:

    • Modify the lvl value to change the role’s hierarchy. Ensure levels are unique to avoid conflicts.

Assigning Roles

  • To assign a role to a player, update the admin_data table in your database:

    • Set the group field to match the role key (e.g., helper, admin, owner).

    • Example: To make a player a Helper, set group = "helper".

  • Ensure the player’s identifier, username, and discord_id are also filled in.

Tips

  • Test Changes: After modifying permissions, test the admin menu to ensure roles have the correct access.

  • Use Specific Permissions: For lower roles like Helper, list specific permissions to limit their power.

  • Check Colors: Use Tailwind’s color palette to ensure role colors are visually distinct and consistent.

  • Backup Config: Save a copy of config/main.lua before making changes to avoid losing settings.

This configuration allows you to fine-tune access and appearance for each role in the admin menu, ensuring a secure and organized staff hierarchy.

Last updated