[code] 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, [/code]
The full job
[code]
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!",
})
[/code]
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:
[CODE]
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,
[/CODE]
[QUOTE=mib999;49866082]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.[/QUOTE]
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
[QUOTE=Borris_Squad;49866109]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[/QUOTE]
That model is only for one job?
[QUOTE=P4sca1;49866086]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:
[CODE]
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,
[/CODE][/QUOTE]
But thats not checking for their model. I want it so that if their model is the bulldozer, they have a higher armor.
[QUOTE=Borris_Squad;49866138]But thats not checking for their model. I want it so that if their model is the bulldozer, they have a higher armor.[/QUOTE]
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,
[QUOTE=DanielHershey;49866133]That model is only for one job?[/QUOTE]
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.
[code] 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, [/code] Do i need to anything else to make this work, have not tested it yet.
[editline]4th March 2016[/editline]
[QUOTE=Light_Magic;49866671]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.[/QUOTE]
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
[QUOTE=Borris_Squad;49866740]I thought i had to separate them, i just did not know if it were if statements and or and etc[/QUOTE]
Please, for the love of god, go over basic Lua syntax, its not hard.
[code] 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, [/code]
[code] [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 -------
[/code] :/
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.
[QUOTE=P4sca1;49866864]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.[/QUOTE]
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]
[code] 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,
[/code]
The only issue left is with ply:SetHealth()...
[code] 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, [/code]
[editline]4th March 2016[/editline]
Thanks, you helped a lot and thought me something :)
Hrmmm, given that stuff works. Any one can become that job
You need to have the customCheck that checks for desired ranks too.
You make fun of people who can't setup MySQL but you can't figure out simple lua syntax or darkrp configuration.
:what:
[QUOTE=Mikey Howell;49869657]You make fun of people who can't setup MySQL but you can't figure out simple lua syntax or darkrp configuration.
:what:[/QUOTE]
I dont make fun of people who cant Setup SQL? I struggle my self....
Sorry, you need to Log In to post a reply to this thread.