Lua Donator Job "CRASH"

I’m wondering why my server crash when i use.


TEAM_SWAT = AddExtraTeam("SWAT", {
	color = Color(0,0,153,255),
	model = "models/player/riot.mdl",
	description = [[A swat team member makes people follow the law, they are called if things get out of hand]],
	weapons = {"weapon_m42", "arrest_stick", "unarrest_stick", "weapon_deagle2", "stunstick", "door_ram", "weapon_real_cs_flash" },
	command = "swat",
	max = 4,
	salary = 65,
	admin = 0,
	vote = true,
	hasLicense = true,
	NeedToChangeFrom = TEAM_SWAT
	function(ply) return ply:GetUserGroup() == "donator" or ply:IsAdmin() end)
})

i underlined the donator group “function(ply) return ply:GetUserGroup() == “donator” or ply:IsAdmin() end)”
and when i put it into the server it makes it crash,even through
i have a ULX group called donator.

you need to add a comma after TEAM_SWAT

no you dont have to do it, all my other classes dont have a comma after it.

That guy is only partly correct, it should be:



TEAM_SWAT = AddExtraTeam("SWAT", {
	color = Color(0,0,153,255),
	model = "models/player/riot.mdl",
	description = [[A swat team member makes people follow the law, they are called if things get out of hand]],
	weapons = {"weapon_m42", "arrest_stick", "unarrest_stick", "weapon_deagle2", "stunstick", "door_ram", "weapon_real_cs_flash" },
	command = "swat",
	max = 4,
	salary = 65,
	admin = 0,
	vote = true,
	hasLicense = true,
	NeedToChangeFrom = TEAM_SWAT,
	checkCustom = ply:IsUserGroup("donator") or ply:IsUserGroup("admin")
})


If you want to also limit with a steam id you can you



checkCustom = ply:SteamID == "STEAM ID"


[editline]21st December 2012[/editline]

Ah, that is incorrect as well. The commas indicate to the server that there is a new “function” coming up. So, you don’t need a comma in all the others at the TEAM_SWAT as it is the end of the job. To add a custom check, you need a comma to indicate a new function.

also there is just a random space before the } in weapons

Finished code:



TEAM_SWAT = AddExtraTeam("SWAT", {
	color = Color(0,0,153,255),
	model = "models/player/riot.mdl",
	description = [[A swat team member makes people follow the law, they are called if things get out of hand]],
	weapons = {"weapon_m42", "arrest_stick", "unarrest_stick", "weapon_deagle2", "stunstick", "door_ram", "weapon_real_cs_flash"},
	command = "swat",
	max = 4,
	salary = 65,
	admin = 0,
	vote = true,
	hasLicense = true,
	NeedToChangeFrom = TEAM_SWAT,
	checkCustom = ply:IsUserGroup("donator") or ply:IsUserGroup("admin")
})


Thank you, alot.

No Worries,

^

i just tryed the checkcustom thing it i get a server crash with lua errors and this is what it says

[ERROR] gamemodes/darkrp/gamemode/shared.lua:242: ‘}’ expected (to close ‘{’ at line 230) near ‘checkCustom’

  1. unknown - gamemodes/darkrp/gamemode/

230 TEAM_SWAT = AddExtraTeam(“SWAT”, {
231 color = Color(0,0,153,255),
232 model = “models/player/riot.mdl”,
233 description = [[A swat team member makes people follow the law, they are called if things get out of hand]],
234 weapons = {“weapon_m42”, “arrest_stick”, “unarrest_stick”, “weapon_deagle2”, “stunstick”, “door_ram”, “weapon_real_cs_flash”},
235 command = “swat”,
236 max = 4,
237 salary = 65,
238 admin = 0,
239 vote = true,
240 hasLicense = true,
241 NeedToChangeFrom = TEAM_SWAT
242 checkCustom = ply:IsUserGroup(“donator”) or ply:IsUserGroup(“admin”)
243 })

I think you might use the if and then like:



If checkCustom = ply:IsUserGroup("donator") or ply:IsUserGroup("admin") then
TEAM_SWAT = AddExtraTeam("SWAT", {
	color = Color(0,0,153,255),
	model = "models/player/riot.mdl",
	description = [[A swat team member makes people follow the law, they are called if things get out of hand]],
	weapons = {"weapon_m42", "arrest_stick", "unarrest_stick", "weapon_deagle2", "stunstick", "door_ram", "weapon_real_cs_flash"},
	command = "swat",
	max = 4,
	salary = 65,
	admin = 0,
	vote = true,
	hasLicense = true,
	NeedToChangeFrom = TEAM_SWAT 
})
end


now i get this [ERROR] gamemodes/darkrp/gamemode/shared.lua:230: ‘=’ expected near ‘checkCustom’

  1. unknown - gamemodes/darkrp/gamemode/shared.lua:0

[editline]21st December 2012[/editline]

do i have to have a line of code somewhere else in a different file because that’s not working even through we got a ulx donator group.

Nvm the problem is that i cant fit it no where, you maybe need to make a infinite timer to check if the player is a donator and mayor to “kick” him off mayor

Great linguistic skills. Oh, I see my error, I forgot to end customCheck. Here, try this.



TEAM_SWAT = AddExtraTeam("SWAT", {
	color = Color(0,0,153,255),
	model = "models/player/riot.mdl",
	description = [[A swat team member makes people follow the law, they are called if things get out of hand]],
	weapons = {"weapon_m42", "arrest_stick", "unarrest_stick", "weapon_deagle2", "stunstick", "door_ram", "weapon_real_cs_flash"},
	command = "swat",
	max = 4,
	salary = 65,
	admin = 0,
	vote = true,
	hasLicense = true,
	NeedToChangeFrom = TEAM_SWAT,
	customCheck = function(ply) return ply:IsUserGroup("donator") or ply:IsUserGroup("admin")
        end
})


EDIT: Sorry for the long reply, I was coding some custom things for my DarkRP server.

thanks

now dose that make it so anyone can see it but only donators and admins can use it. if that how it is how do you make it so everyone can see it and only donators/admins can use it.

I have a very clear idea, but the idea is worth money, and I am not willing to divulge it on facepunch yet.

what about over steam

This thread is full of people with very, very, poor grasps of lua, and very, very poor grasps of the English language. funnygame, what is your question exactly? Why don’t you try phrasing it in English so I can understand what exactly you’re asking?

Squished, your idea isn’t worth money and the fact that you’d even say that is really stupid.

Nice, I see you cant read. His first line says.

Great way to sound smart is to actually read the OP first. Dumbass.