Skip to content

Conversation

@BackSH00TER
Copy link
Contributor

This pull request includes changes to enhance the permission check system for accessing the MDT by including a minimum grade requirement.

  • server/utils.lua: Updated the PermCheck function to include a check for the minimum grade required for accessing the MDT. The function now verifies if the user's job and grade meet the required criteria.

  • shared/config.lua Updated the Config.PoliceJobs, Config.AmbulanceJobs, and Config.DojJobs to include a minGradeRequired field, allowing for more granular control over access permissions based on job grade.

  • A value of 0 gives access to all grade levels for that job.

Example:

['lawyer'] = true,  =>  ['lawyer'] = { minGradeRequired = 2 },
['judge'] = true,  => ['judge'] = {  minGradeRequired = 0 },

Why is this needed?
Currently the MDT checks the players job to see whether they can access the MDT. This is just checking that their job name matches. Some servers want to be able to limit access to the MDT by job name + grade level. For example, a server might want to configure the 'lawyer' job to only have access to the MDT if they are grade level 2 or higher.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR enhances the MDT permission system by adding minimum grade level requirements to job-based access control. Previously, access was granted solely based on job name matching; now, administrators can specify a minimum grade requirement for each job, with 0 allowing access to all grade levels.

Changes:

  • Modified job configuration structure from boolean values to tables containing minGradeRequired field
  • Updated PermCheck function to validate both job name and grade level before granting MDT access
  • All existing jobs configured with minGradeRequired = 0 to maintain backward compatibility

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
shared/config.lua Restructured Config.PoliceJobs, Config.AmbulanceJobs, and Config.DojJobs from boolean values to table objects with minGradeRequired field, with all jobs defaulting to 0 (allow all grades)
server/utils.lua Enhanced PermCheck function to validate player's grade level against job's minimum grade requirement in addition to job name verification

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

['doctor'] = { minGradeRequired = 0 }
}

-- Add ranks
Copy link

Copilot AI Jan 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment "Add ranks" is unclear and inconsistent with the comments for PoliceJobs and AmbulanceJobs above. Consider changing this to match the format used for the other job tables (e.g., "Set the min grade level required to access the MDT" or remove it entirely to avoid confusion).

Suggested change
-- Add ranks
-- Set the min grade level required to access the MDT
-- Set to 0 to allow all grades

Copilot uses AI. Check for mistakes.
Comment on lines +24 to +31
local allowedJob = Config.AllowedJobs[PlayerData.job.name]

if not allowedJob or (allowedJob.minGradeRequired and PlayerData.job.grade.level < allowedJob.minGradeRequired) then
print(("UserId: %s(%d) tried to access the MDT without authorization (server direct)"):format(GetPlayerName(src), src))
return false
end
return true
Copy link

Copilot AI Jan 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inconsistent indentation detected. The codebase uses tabs for indentation (visible in lines 27-28 and throughout the rest of the file), but lines 24, 26, 29, and 31 use spaces. Please use tabs to maintain consistency with the rest of the codebase.

Suggested change
local allowedJob = Config.AllowedJobs[PlayerData.job.name]
if not allowedJob or (allowedJob.minGradeRequired and PlayerData.job.grade.level < allowedJob.minGradeRequired) then
print(("UserId: %s(%d) tried to access the MDT without authorization (server direct)"):format(GetPlayerName(src), src))
return false
end
return true
local allowedJob = Config.AllowedJobs[PlayerData.job.name]
if not allowedJob or (allowedJob.minGradeRequired and PlayerData.job.grade.level < allowedJob.minGradeRequired) then
print(("UserId: %s(%d) tried to access the MDT without authorization (server direct)"):format(GetPlayerName(src), src))
return false
end
return true

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant