Max Jobs Limit

Max jobs limits for darkrp, need help

Here my example code of sv_maxjobs.lua
local MAX_POLICE = 0
function CalculateMaxJobs()
local TotalPlayers = table.Count(player.GetAll())
if TotalPlayers >= 40 then
elseif TotalPlayers >= 30 then
elseif TotalPlayers >= 20 then
elseif TotalPlayers >= 10 then
elseif TotalPlayers < 10 then
hook.Add(“PlayerInitialSpawn”, “CalculateMaxJobsOnSpawn”, CalculateMaxJobs)
hook.Add(“PlayerDisconnect”, “CalculateMaxJobsOnDisconnect”, CalculateMaxJobs)
hook.Add(“InitPostEntity”, “CalculateMaxJobsOnStartUp”, CalculateMaxJobs)

My problem is when i paste MAX_POLICE to shared.lua it doesn’t work.
Help, how to make this work, because i can’t understand.

What is the point of this? You can do this in shared.lua…

Make jobs max limit depends on connected players

HE want when there are 10 players on the server there can be just 3 cops if there are more then 10 then 5 cops if more or equal to 20 then 6 cops and so on so on.

Yes you right

Ow sorry, didn’t read it clear.
Well, i like the idea but i can’t help… :confused:

Isn’t this feature already available in the form of a percentage?

lua_error try using this instead

The issue is that you made MAX_POLICE local, so unless it’s actually in your shared.lua file you will not be able to reference it.

Why aren’t you just setting RPExtraTeams[TEAM_POLICE][“max”]?

This looks like PERP code to me.

it’s not

[editline]17th February 2013[/editline]

And more on this- it’ll raise the limit serverside but clientside it’ll remain whatever the default was. You could always set a net message to current players (and ones that connect later) to set the variable though, if clientside sync is important to you. I don’t think DarkRP does anything with the limit off the top of my head, but it may use it for the F4 jobs menu, I can’t remember.

Yea this will work as global value “0” but it always will be “0”

I don’t undestand how to setting this

it’s a variable, set it the same as any other

Someone get Divinity over here, he’s got this on his server…he could give some pointers.