diff --git a/server/utils.lua b/server/utils.lua index 00cb4804..064a40b3 100644 --- a/server/utils.lua +++ b/server/utils.lua @@ -18,15 +18,17 @@ function UnpackJob(data) return job, grade end +-- Ensure the user has permission to access the MDT +-- Checks if the user is in the allowed jobs list and if they have the required grade (if applicable) function PermCheck(src, PlayerData) - local result = true - - if not Config.AllowedJobs[PlayerData.job.name] then - print(("UserId: %s(%d) tried to access the mdt even though they are not authorised (server direct)"):format(GetPlayerName(src), src)) - result = false - end - - return result + 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 end function ProfPic(gender, profilepic) diff --git a/shared/config.lua b/shared/config.lua index 2d99a865..53cc56cc 100644 --- a/shared/config.lua +++ b/shared/config.lua @@ -64,26 +64,29 @@ Config.RosterLink = { ['sapr'] = '', } +-- Set the min grade level required to access the MDT +-- Set to 0 to allow all grades Config.PoliceJobs = { - ['police'] = true, - ['lspd'] = true, - ['bcso'] = true, - ['sast'] = true, - ['sasp'] = true, - ['doc'] = true, - ['lssd'] = true, - ['sapr'] = true, - ['pa'] = true + ['police'] = { minGradeRequired = 0 }, + ['lspd'] = { minGradeRequired = 0 }, + ['bcso'] = { minGradeRequired = 0 }, + ['sast'] = { minGradeRequired = 0 }, + ['sasp'] = { minGradeRequired = 0 }, + ['doc'] = { minGradeRequired = 0 }, + ['lssd'] = { minGradeRequired = 0 }, + ['sapr'] = { minGradeRequired = 0 }, + ['pa'] = { minGradeRequired = 0 } } Config.AmbulanceJobs = { - ['ambulance'] = true, - ['doctor'] = true + ['ambulance'] = { minGradeRequired = 0 }, + ['doctor'] = { minGradeRequired = 0 } } +-- Add ranks Config.DojJobs = { - ['lawyer'] = true, - ['judge'] = true + ['lawyer'] = { minGradeRequired = 0 }, + ['judge'] = { minGradeRequired = 0 } } -- This is a workaround solution because the qb-menu present in qb-policejob fills in an impound location and sends it to the event.