DarkRP Jobs limited to Levels (With Levelling system).

Currently have a Levelling system and am wondering how to check if you are a certain level before you pick a job. I have this so far:

These are only snippets.

player.lua
[lua]
if TEAM.Level and self.profData.Level < TEAM.Level then
Notify(self, 1, 4, “You must be level " …TEAM.Level… " to choose this team!”, “”)
return false
end
[/lua]

Makethings.lua
[lua]
function AddExtraTeam( Name, color, model, Description, Weapons, command, maximum_amount_of_this_class, Salary, admin, Vote, Haslicense, NeedToChangeFrom, CustomCheck, level)
if not Name or not color or not model or not Description or not Weapons or not command or not maximum_amount_of_this_class or not Salary or not admin or Vote == nil then
local text = "One of the custom teams is wrongly made! Attempting to give name of the wrongly made team!(if it’s nil then I failed):
" … tostring(Name)
print(text)
hook.Add(“PlayerSpawn”, “TeamError”, function(ply)
if ply:IsAdmin() then ply:ChatPrint("WARNING: "…text) end
end)
end
local CustomTeam = {name = Name, model = model, Des = Description, Weapons = Weapons, command = command, max = maximum_amount_of_this_class, salary = Salary, admin = admin or 0, Vote = tobool(Vote), NeedToChangeFrom = NeedToChangeFrom, Haslicense = Haslicense, customCheck = CustomCheck, Level = level}
table.insert(RPExtraTeams, CustomTeam)
team.SetUp(#RPExtraTeams, Name, color)
local Team = #RPExtraTeams

timer.Simple(0, function(CustomTeam, maximum_amount_of_this_class) AddTeamCommands(CustomTeam, maximum_amount_of_this_class) end, CustomTeam, maximum_amount_of_this_class)

// Precache model here. Not right before the job change is done
if type(model) == "table" then
	for k,v in pairs(model) do util.PrecacheModel(v) end
else 
	util.PrecacheModel(model)
end
return Team

end
[/lua]

shared.lua
[lua]
TEAM_DUDE = AddExtraTeam(“Dude”, Color(80, 45, 0, 255), “models/player/corpse1.mdl”, [[The lowest member of society. All people see you laugh.
You have no home.
Beg for your food and money
Sing for everyone who passes to get money
Make your own wooden home somewhere in a corner or
outside someone else’s door]], {“weapon_bugbait”}, “dude”, 5, 0, 0, false, 10)
[/lua]

I can still become a Dude even tho I’m level 1.

I haven’t coded for darkrp myself, but I think this is your problem:

Simply compare the function statements:
[lua]–Function:
AddExtraTeam( Name, color, model, Description, Weapons, command, maximum_amount_of_this_class, Salary, admin, Vote, Haslicense, NeedToChangeFrom, CustomCheck, level)

–Called as:
TEAM_DUDE = AddExtraTeam(“Dude”, [“Color”], [“Model-corpse”], [“Description”], [“Weapons-bugbait”], [“Command-dude”], [“max-5”], [“salary-0”], [“admin-0”], [“vote-no”], [“HasLicense-10”])

–Possible intention:
TEAM_DUDE = AddExtraTeam(“Dude”, Color(80, 45, 0, 255), “models/player/corpse1.mdl”, [[The lowest member of society. All people see you laugh.
You have no home.
Beg for your food and money
Sing for everyone who passes to get money
Make your own wooden home somewhere in a corner or
outside someone else’s door]], {“weapon_bugbait”}, “dude”, 5, 0, 0, false, nil, nil, nil, 10)[/lua]

And I’ll say it again just to make sure, I’m not guaranteeing this will work, that’s just a change I’d make after a glance at your code

Thanks for the reply, I did think of this as more parts are called however it doesn’t seem to make a difference :frowning:

I’m not entirely sure what is wrong, or where I have gone wrong. The function I did in player.lua is being called, however it looks like its just skipping over it.

[editline]1st February 2012[/editline]

Edit: If I do this

[lua]
if TEAM.level and PointsData.Level < TEAM.level then
Notify(self, 1, 4, “You must be level " …TEAM.level… " to choose this team!”, “”)
return false
else
Notify(self, 1, 4, “False”)
end
[/lua]

Any team I change too (Even the dude) says false. Something must be wrong in the team setup.

Does returning false actually stop the changing process?
It seems like it works but returning false won’t stop the team change from occuring still.

Its fixed now, TEAM.Level had to be a capital L.