Can't get job to work

I’m am making jobs to only be able to work after a sertain time I used this code:


TEAM_MAYOR = DarkRP.createJob("Mayor", {
	color = Color(150, 20, 20, 255),
	model = "models/player/breen.mdl",
	description = [[]],
	weapons = {},
	command = "mayor",
	max = 1,
	salary = 125,
	admin = 0,
	vote = true,
	hasLicense = false,
	mayor = true,
	PlayerDeath = function(ply)
		if ply:Team() == TEAM_MAYOR then
			ply:changeTeam( TEAM_CITIZEN, true )
				for k,v in pairs( player.GetAll() ) do
					DarkRP.notify(v, 1, 4, "The mayor has been killed!")
				end
			end
		end,
	customCheck = function(ply)
		if ply:GetUTimeTotalTime() >= 36000 then
			return true
		elseif CLIENT or table.HasValue({ "vip", "trial-mod", "pay-admin", "head-of-staff", "developer", "head-developer", "co-owner", "admin", "superadmin", "owner", "moderator"}, ply:GetNWString("usergroup") or ply:IsSuperAdmin()) then
			if ply:GetUTimeTotalTime() >= 0 then
				return true
		elseif CLIENT or table.HasValue({ "donator"}) then
			if GetUTimeTotalTime() >= 18000 then
				return true
			else
				if CLIENT then
					return true
				else
					return false
				end
			end
		else
			return false
		end
	end
	customCheck = function(ply)
		if ply:GetUserGroup() == "donator" then
			CustomCheckFailMsg = "You need to have 5 hours to become this job."
		elseif
			if ply:GetUserGroup() == "user" then
			CustomCheckFailMsg = "You need to have 10 hours to become this job."
		end
})

And I get this error:

[ERROR] addons/darkrpmodification/lua/darkrp_customthings/jobs.lua:64: unexpected symbol near ‘if’

  1. unknown - addons/darkrpmodification/lua/darkrp_customthings/jobs.lua:0

Can someone please help I’m struggeling.

Thank you in advance

You didn’t end the customCheck function. You also didn’t end one of the if statements in that function.

Change this


customCheck = function(ply)
		if ply:GetUserGroup() == "donator" then
			CustomCheckFailMsg = "You need to have 5 hours to become this job."
		elseif
			if ply:GetUserGroup() == "user" then
			CustomCheckFailMsg = "You need to have 10 hours to become this job."
		end

To this


customCheck = function(ply)
		if ply:GetUserGroup() == "donator" then
			CustomCheckFailMsg = "You need to have 5 hours to become this job."
		elseif ply:GetUserGroup() == "user" then
			CustomCheckFailMsg = "You need to have 10 hours to become this job."
		end
end

Edit: Everytime i look back at the code i find more fucked up shit, you need a comma after the first customcheck function, also you’re just overwriting the first function with the second one.

Ok now I get this error:

[ERROR] addons/darkrpmodification/lua/darkrp_customthings/jobs.lua:67: unexpected symbol near ‘}’

  1. unknown - addons/darkrpmodification/lua/darkrp_customthings/jobs.lua:0

Its the closing of this job

Why do you have 2 customCheck functions?

Shouldnt it be

[lua]function customCheck(ply)[/lua]

Not

[lua]customCheck = function(ply)[/lua]

or does it go either way?

It’s setting variables in a table so that’s the format.

1 is the custom check for the utime part and the other is just so it notify’s the player that he needs more hours

But how do I make so that the player get notified but only have 1 custom check?

Put the shit from the second function into the first one.

Like this:



customCheck = function(ply)
	if ply:GetUserGroup() == "donator" then
		CustomCheckFailMsg = "You need to have 5 hours to become this job."
	elseif ply:GetUserGroup() == "user" then
		CustomCheckFailMsg = "You need to have 10 hours to become this job."
	end
	if ply:GetUTimeTotalTime() >= 36000 then
		return true
	elseif CLIENT or table.HasValue({ "vip", "trial-mod", "pay-admin", "head-of-staff", "developer", "head-developer", "co-owner", "admin", "superadmin", "owner", "moderator"}, ply:GetNWString("usergroup") or ply:IsSuperAdmin()) then
		if ply:GetUTimeTotalTime() >= 0 then
			return true
	elseif CLIENT or table.HasValue({ "donator"}) then
		if GetUTimeTotalTime() >= 18000 then
			return true
		else
			if CLIENT then
				return true
			else
				return false
			end
		end
	else
		return false
	end
end

Sure, but even if they have enough time it’ll still display the messages. Put them in the appropriate place in the code.

Well is still says this error:

[ERROR] addons/darkrpmodification/lua/darkrp_customthings/jobs.lua:65: unexpected symbol near ‘}’

  1. unknown - addons/darkrpmodification/lua/darkrp_customthings/jobs.lua:0

Paste the full code you have now.

Here is the full job again:



TEAM_MAYOR = DarkRP.createJob("Mayor", {
	color = Color(150, 20, 20, 255),
	model = "models/player/breen.mdl",
	description = [[]],
	weapons = {},
	command = "mayor",
	max = 1,
	salary = 125,
	admin = 0,
	vote = true,
	hasLicense = false,
	mayor = true,
	PlayerDeath = function(ply)
		if ply:Team() == TEAM_MAYOR then
			ply:changeTeam( TEAM_CITIZEN, true )
				for k,v in pairs( player.GetAll() ) do
					DarkRP.notify(v, 1, 4, "The mayor has been killed!")
				end
			end
		end,
	customCheck = function(ply)
		if ply:GetUTimeTotalTime() >= 36000 then
			return true
		elseif CLIENT or table.HasValue({ "vip", "trial-mod", "pay-admin", "head-of-staff", "developer", "head-developer", "co-owner", "admin", "superadmin", "owner", "moderator"}, ply:GetNWString("usergroup") or ply:IsSuperAdmin()) then
			if ply:GetUTimeTotalTime() >= 0 then
				return true
		elseif CLIENT or table.HasValue({ "donator"}) then
			if GetUTimeTotalTime() >= 18000 then
				return true
			else
				if CLIENT then
					return true
				else
					return false
				end
			end
		else
			return false
		end
		if ply:GetUserGroup() == "donator" then
			CustomCheckFailMsg = "You need to have 5 hours to become this job."
		elseif ply:GetUserGroup() == "user" then
			CustomCheckFailMsg = "You need to have 10 hours to become this job."
		end
	end
})

Your code looks terrible with a lot of redundancy. This is my attempt at cleaning up your code based on what you are trying to do.



customCheck = function(ply)
	if ply:GetUTimeTotalTime() >= 36000 or table.HasValue({ "vip", "trial-mod", "pay-admin", "head-of-staff", "developer", "head-developer", "co-owner", "admin", "superadmin", "owner", "moderator"}, ply:GetNWString("usergroup") or ply:IsSuperAdmin()) then
			return true
	elseif CLIENT or table.HasValue({ "donator"}) and GetUTimeTotalTime() >= 18000 then
			return true
	else
		if ply:GetUserGroup() == "donator" then
			CustomCheckFailMsg = "You need to have 5 hours to become this job."
			return false
		else
			CustomCheckFailMsg = "You need to have 10 hours to become this job."
			return false
		end
	end
end


I tried this and got this new error:

[ERROR] addons/darkrpmodification/lua/darkrp_customthings/jobs.lua:41: unexpected symbol near ‘or’

  1. unknown - addons/darkrpmodification/lua/darkrp_customthings/jobs.lua:0

Here is the job with new code:



TEAM_MAYOR = DarkRP.createJob("Mayor", {
	color = Color(150, 20, 20, 255),
	model = "models/player/breen.mdl",
	description = [[]],
	weapons = {},
	command = "mayor",
	max = 1,
	salary = 125,
	admin = 0,
	vote = true,
	hasLicense = false,
	mayor = true,
	PlayerDeath = function(ply)
		if ply:Team() == TEAM_MAYOR then
			ply:changeTeam( TEAM_CITIZEN, true )
				for k,v in pairs( player.GetAll() ) do
					DarkRP.notify(v, 1, 4, "The mayor has been killed!")
				end
			end
		end,
	customCheck = function(ply)
		if ply:GetUTimeTotalTime() >= 36000 then or table.HasValue({ "vip", "trial-mod", "pay-admin", "head-of-staff", "developer", "head-developer", "co-owner", "admin", "superadmin", "owner", "moderator"}, ply:GetNWString("usergroup") or ply:IsSuperAdmin()) then
			return true
		elseif CLIENT or table.HasValue({ "donator"}) and GetUTimeTotalTime() >= 18000 then
			return true
		else
			if ply:GetUserGroup() == "donator" then
				CustomCheckFailMsg = "You need to have 5 hours to become this job."
				return false
			else
				CustomCheckFailMsg = "You need to have 10 hours to become this job."
				return false
			end
		end
	end
})

Go up to my post and copy the code again and replace what you have. I had edited my post because I realized I left a “then” before the or in the first if statement.

Or just delete the then?

Ah shit, you’re right. I missed the table at the top there. My bad!
But yeah, honestly the code is a big fucking spaghetti mess.