Trying to make this job donator only and set armor to it but I am unsure how to combine the custom checks... I read this thread: [URL="http://facepunch.com/showthread.php?t=1237404"]http://facepunch.com/showthread.php?t=1237404[/URL]
[code]
customCheck = function(ply)
return ply:Team() == SWAT then ply:SetArmor(50))}
end
[/code]
So my question is how would I merge that code with the job code below? Again I am working on being able to understand how LUA functions so please place some comments telling me what does what!
[code]
TEAM_SWAT = DarkRP.createJob("SWAT", {
color = Color(20, 20, 255, 255),
VIPOnly = true,
model = "models/player/riot.mdl",
description = [[
Your role is to protect the town of Maelstrom and ensure the laws are in check.
Arrest law breakers with your arrest baton or take necessary measures to keep
the peace. Do not randomly weapon check or randomly issue warrants on players,
only with just reason. Give players warning prior to arresting them if possible.
Can they Mug: No
Can they Raid: No]],
weapons = {"darkrp_handcuffs", "unarrest_stick", "swb_357", "stunstick", "door_ram", "weaponchecker"},
command = "swat",
max = 2,
salary = 100,
admin = 0,
vote = false,
hasLicense = true,
ammo = {
["pistol"] = 60,
},
customCheck = function(ply) return client or function(ply) return donator[ply:GetUserGroup()] end
end
})
[/code]
[code]customCheck = function(ply) if ply:Team() == SWAT then ply:SetArmor(50) return true end[/code]
Should work. Also, don't include the CLIENT or... statement. All that does is make it so everyone can use the job.
[QUOTE=code_gs;45523562][code]customCheck = function(ply) if ply:Team() == SWAT then ply:SetArmor(50) return true end[/code]
Should work. Also, don't include the CLIENT or... statement. All that does is make it so everyone can use the job.[/QUOTE]
I have a LUA file to prevent that, the goal is make it so everyone can see the job. The other file actually prevents the use of the job.
[editline]28th July 2014[/editline]
[code]
TEAM_SWAT = DarkRP.createJob("SWAT", {
color = Color(20, 20, 255, 255),
VIPOnly = true,
model = "models/player/riot.mdl",
description = [[
Your role is to protect the town of Maelstrom and ensure the laws are in check.
Arrest law breakers with your arrest baton or take necessary measures to keep
the peace. Do not randomly weapon check or randomly issue warrants on players,
only with just reason. Give players warning prior to arresting them if possible.
Can they Mug: No
Can they Raid: No]],
weapons = {"darkrp_handcuffs", "unarrest_stick", "swb_357", "stunstick", "door_ram", "weaponchecker"},
command = "swat",
max = 2,
salary = 100,
admin = 0,
vote = false,
hasLicense = true,
ammo = {
["pistol"] = 30,
},
customCheck = function(ply) return client or function(ply) return donator[ply:GetUserGroup()] end
end,
customCheck = function(ply) if ply:Team() == SWAT then ply:SetArmor(50) return true end
})
[/code]
Got this error:
[ERROR] addons/darkrp mod/lua/darkrp_customthings/jobs.lua:594: unexpected symbol near '}'
1. unknown - addons/darkrp mod/lua/darkrp_customthings/jobs.lua:0
You can't have two custom checks. Use this:
[code] customCheck = function(ply) if ( CLIENT or donator[ ply:GetUserGroup() ] ) then ply:SetArmor(50) return true end[/code]
SetArmor was supposedly a nil value.
[ERROR] addons/darkrp mod/lua/darkrp_customthings/jobs.lua:591: attempt to call method 'SetArmor' (a nil value)
Remove the SetArmor from the custom check and try this:
[code]-- Run serverside
hook.Add( "PlayerSpawn", "ArmorJob", function( ply )
if ply:Team() == TEAM_SWAT then
ply:SetArmor( 50 )
end
end)[/code]
Use the PlayerSpawn field, ([URL]http://wiki.darkrp.com/index.php/DarkRP:CustomJobFields[/URL]), to give armor.
Yeah, do what ms333 said. also, you were using customCheck incorrectly, that's to see if you can be that job.
Sorry, you need to Log In to post a reply to this thread.