DarkRP Several Jobs 1 Limit

Alright so this is a weird one. I am using the DarkRP gamemode as a base for my RP server. I have many Police jobs setup but just with different ranks that require different amount of playtime. Rather then have a limit to each rank I’d rather have a limit to the cops overall. So I can have 5 cadets or 5 officers or 2 cadets 3 officers. I don’t really have an idea on how to do this. Could anyone possibly give me a little help with this?

So Again I want a overall limit. So if I set the limit to 10. I could have 1 Police Cadet 5 Officers and 4 Police Sergeant, or 10 officers, etc… Please if you can give me an answer that would be great!

I’m not exactly sure how DarkRP works but I’m pretty sure you can run a custom check when they go to become the job. You could use this with a piece of code that checks the amount of players in each of the police jobs. This may be achievable with team.GetPlayers and a table of the police jobs.

-- A table of all the police jobs (NOTE: I have no idea how DarkRP stores these)
local police ={

local TotalPolice = 0
for k, v in pairs( police )do -- Loop through all the police jobs.
    TotalPolice = TotalPolice + #team.GetPlayers( v ) -- Add the amount of players in the police jobs to the 'TotalPolice' variable.

if( TotalPolice >= 10 )then -- Check if the total amount of police is greater than or equal to 10.
    -- Stop the player from becoming this job?

Or you could check for a keyword to find the teams that are police with a combination of team.GetAllTeams and string.match:

local keyword = "police" -- Set the keyword to search for.
local PoliceJobs = {}

for k, v in pairs( tams.GetAllTeams() )do -- Loop through all of the teams.
    if( string.match( team.GetName( v ), keyword ) )then -- Check if the team name has the keyword in it.
        table.insert( PoliceJobs, v ) -- Add the current job to the list of police jobs.

-- Then run a check for the amount of players in the team. (as shown in previous example)

NOTE: I honestly don’t know if this will work - I haven’t tested any of it and I don’t know the way DarkRP stores it but you could always do this sort of research yourself.