Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions server/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
29 changes: 16 additions & 13 deletions shared/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down