Whats wrong with this custom check?


    customCheck = function(ply) return ply:GetNWString("usergroup") == "donator" or ply:IsAdmin() or ply:GetNWString("usergroup") == "policed" if ply:GetModel() == "models/mark2580/payday2/pd2_bulldozer_player.mdl" then ply:SetArmor(500) end end end, 

The full job


 

TEAM_SWAT = DarkRP.createJob("NYPD Swat Police", {
   color = Color(114, 48, 0, 255),
   model = {"models/player/pmc_4/pmc__06.mdl", "models/player/pmc_4/pmc__08.mdl", "models/player/pmc_4/pmc__07.mdl", "models/mark2580/payday2/pd2_bulldozer_player.mdl"},
   description = [[You are to stay on call for any raids which the NYPD officers may need assistance with. You do not patrol the streets.]],
   weapons = {"fas2_p226","fas2_m4a1", "arrest_stick", "unarrest_stick", "policebadge"},
   command = "swat",
   max = 5,
   salary = 350,
   admin = 0,
   vote = false,
   hasLicense = true,
   candemote = false,
   -- CustomCheck
   medic = false,
   chief = false,
   mayor = false,
   hobo = false,
   cook = false,
   category = "Public Services",
   PlayerLoadout = function(ply) ply:SetArmor(100) end,
   customCheck = function(ply) return ply:GetNWString("usergroup") == "donator" or ply:IsAdmin() or ply:GetNWString("usergroup") == "policed" if ply:GetModel() == "models/mark2580/payday2/pd2_bulldozer_player.mdl" then ply:SetArmor(500) end end end,
   CustomCheckFailMsg = "This job is donator only!",
})



I would get you the console error how ever their is an animation error and it spams the console. All i can see from the error when i get a glimpse of it, it says about it expected an ‘end’ or something like that on the customCheck Line.

Thanks!

You can’t return something like that. The function is returning a boolean but you have an if statement there.

Also, this is before you become the job, not after - it’s checking whether you’re allowed to be a job so you’re picking the wrong time to set armor.

I think the problem is that there’s one ‘end’ too much.
Also the if statement won’t be executed because you are returning something before I guess?

I think this should work:



customcheck = function(ply) if ply:GetNWString("usergroup", "") == "donator" or ply:GetNWString("usergroup", "") == "policed" or ply:IsAdmin()  then return true else return false end end,
PlayerSpawn = function(ply) ply:SetArmor(500) end,


Ok, so should i just make a new lua file in the addons that does the custom check instead, people can buy that model on the server and it would be nice if it gave them the armor

That model is only for one job?

But thats not checking for their model. I want it so that if their model is the bulldozer, they have a higher armor.

Replace PlayerSpawn = function(ply) ply:SetArmor(500) end, with

PlayerSpawn = function(ply) if ply:GetModel() == “models/mark2580/payday2/pd2_bulldozer_player.mdl” then ply:SetArmor(500) end end,

No

Aren’t you trying to learn lua? This is very basic try wiki.garrysmod.com it should have anything / everything you need. Instead of having people doing it for you. You won’t learn that way, obviously ask for help if needed but hints not the script.


 PlayerSpawn = function(ply) if ply:GetModel() == "models/mark2580/payday2/pd2_bulldozer_player.mdl" then ply:SetArmor(500),  ply:SetWalkSpeed(ply:GetWalkSpeed() / 2), ply:SetRunSpeed(ply:GetRunSpeed() / 2) end end,  

Do i need to anything else to make this work, have not tested it yet.

[editline]4th March 2016[/editline]

Eh, i use the wiki…

Why are you using a , after ply:SetArmor() and ply:SetWalkSpeed()?

I thought i had to separate them, i just did not know if it were if statements and or and etc

Please, for the love of god, go over basic Lua syntax, its not hard.


    PlayerSpawn = function(ply) if ply:GetModel() == "models/mark2580/payday2/pd2_bulldozer_player.mdl" then ply:SetArmor(500) ply:SetWalkSpeed(ply:GetWalkSpeed() / 2) ply:SetRunSpeed(ply:GetRunSpeed() ply:SetHealth(500) / 2) ply:Give( "fas2_m60e3" ) end end, 


 [ERROR] Lua is unable to understand file "darkrp_customthings/jobs.lua" because its author made a mistake around line number 136.
The best help I can give you is this:

Right before the 'ply', Lua expected to read a ')', but it didn't.

Hints:
	- Did you forget a keyword?
	- Did you forget a comma?

------- End of Simplerr error -------


:confused:

I won’t give you the solution this time, because you can easily check this yourself.
Have a look at every ‘(’ and see where it gets closed.

They all get closed after the value of whats in them, thats why i cant see the issue… All the brackets get closed?

[editline]4th March 2016[/editline]


   PlayerSpawn = function(ply) if ply:GetModel() == "models/mark2580/payday2/pd2_bulldozer_player.mdl" then ply:SetArmor(500) ply:SetWalkSpeed(ply:GetWalkSpeed() / 2) ply:SetRunSpeed(ply:GetRunSpeed()) ply:SetHealth(500) / 2) ply:Give( "fas2_m60e3" ) end end,


The only issue left is with ply:SetHealth()…


  PlayerSpawn = function(ply) if ply:GetModel() == "models/mark2580/payday2/pd2_bulldozer_player.mdl" then ply:SetArmor(500) ply:SetWalkSpeed(ply:GetWalkSpeed() / 2) ply:SetRunSpeed(ply:GetRunSpeed() / 2) ply:SetHealth(500) ply:Give( "fas2_m60e3" ) end end,  

[editline]4th March 2016[/editline]

Thanks, you helped a lot and thought me something :slight_smile:

Hrmmm, given that stuff works. Any one can become that job

You need to have the customCheck that checks for desired ranks too.