Jobs.lua - Need help, please!

Hey guys, sorry about this, I have read so many threads with this error but with a different error in the code…
I believe it’s a tiny tiny Syntax error some where in the code - I only know Python, need to learn LUA!
Therefore I can’t spot what’s wrong:
First of all here’s the error -
[ERROR] addons/darkrpmodification/lua/darkrp_customthings/jobs.lua:15: unexpected symbol near ‘=’

  1. unknown - addons/darkrpmodification/lua/darkrp_customthings/jobs.lua:0
    And I’ll pastebin the code (It’s not actually my code, someone wanted these jobs in the server so threw them at me)
    http://pastebin.com/0aifpH0m
    Thank you so much to who can help! Again, I am sorry for this, I am sure you’re all bored of the noob coders by now :stuck_out_tongue:

You’re switching between the long and short formats. Convert all jobs to this format: http://wiki.darkrp.com/index.php/DarkRP:Jobs

Ahh okay, makes sense, thanks - will give it a go!

[editline]31st August 2014[/editline]

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

  1. unknown - addons/darkrpmodification/lua/darkrp_customthings/jobs.lua:0
    Okay so I was wondering whether that ‘15’ in Bold is the line that the mistake is on… because that is what I thought it meant from the start.
    If so, I have corrected the first code in which line 15 is included in, and and I still get the error
    http://pastebin.com/wC7udTjb
    There is the first code fixed, everything after that is still the same as I don’t think it will run due to the first error, or am I incorrect in saying that?? xD
    Anyway thanks in advance to you code_gs or anyone else that can help :3

OOPS! I forgot to add ‘model = -model-’ as a new line however I corrected that and the missing comma but still the same error, just letting you know!


local UserGroups = {
	["donator"] = true,
	["operator"] = true,
}
       

TEAM_TLEADER = DarkRP.CreateJob("Terrorist Leader", {
        color = Color(255, 51, 0, 255), 
        model = "models/player/guerilla.mdl",
        description = [[You\'re a Terrorist Leader Lead your terrorist and bomb up shit with them]],
        weapons = {"m9k_rpg7","m9k_vikhr"},
        command = "tleader",
        max = 1,
        salary = 35,
        admin = 0,
        vote = false,
        hasLicense = false,
        customCheck = function(ply) return ply:IsAdmin() or UserGroups[string.lower(ply:GetNWString("usergroup"))] end,
        CustomCheckFailMsg = "This job is VIP only!"
})

Wow, thank you so much! For now I’ll be having to use that local code for each individual block of jobs that require the UserGroups, so is there an alternative like 'Global to make it more efficient?? If not that’s fine, but I am just so grateful that you fixed it xD

I just have one question - Why did ‘GetNWString’ work?? I am using UXL but apparently GetNWString is for Fadmin? Atleast that’s what it said on the wiki O.o

  1. That local table will work for the WHOLE file. Global tables work for every file. In other words, that table will work for every job that uses it; do not make it global or remake it.
  2. GetNWString is a GMod function, not FAdmin. GetUserGroup is a ULX function that just calls GetNWString, so it’s really pointless to even use it.

Yeah I understand :slight_smile: Well thank you so much for your help!

I’ve just got another problem though, it seems… Have you ever come across these errors after adding jobs?:

[ERROR] gamemodes/darkrp/gamemode/modules/base/sh_createitems.lua:460: bad argument #1 to ‘PrecacheModel’ (string expected, got nil)

  1. PrecacheModel - [C]:-1
  2. createJob - gamemodes/darkrp/gamemode/modules/base/sh_createitems.lua:460
  3. unknown - addons/darkrpmodification/lua/darkrp_customthings/jobs.lua:14
  4. include - [C]:-1
  5. loadCustomDarkRPItems - gamemodes/darkrp/gamemode/libraries/modificationloader.lua:111
  6. fn - gamemodes/darkrp/gamemode/libraries/modificationloader.lua:119
  7. Call - addons/ulib/lua/ulib/shared/hook.lua:183
  8. unknown - lua/includes/modules/gamemode.lua:40
  9. DeriveGamemode - [C]:-1
  10. unknown - gamemodes/darkrp/gamemode/init.lua:6

Corrupt team “S.W.A.T”: element model is incorrect.

[ERROR] gamemodes/darkrp/gamemode/modules/base/sh_createitems.lua:460: bad argument #1 to ‘PrecacheModel’ (string expected, got nil)

  1. PrecacheModel - [C]:-1
  2. createJob - gamemodes/darkrp/gamemode/modules/base/sh_createitems.lua:460
  3. unknown - addons/darkrpmodification/lua/darkrp_customthings/jobs.lua:14
  4. include - [C]:-1
  5. loadCustomDarkRPItems - gamemodes/darkrp/gamemode/libraries/modificationloader.lua:111
  6. fn - gamemodes/darkrp/gamemode/libraries/modificationloader.lua:119
  7. Call - addons/ulib/lua/ulib/shared/hook.lua:183
  8. unknown - lua/includes/modules/gamemode.lua:35

I have no idea what has caused this!! xD It’s caused the F4 Menu to break and I don’t know where to start!
If you have an idea on how to fix this, I’ll actually worship you! If not, it’s back to the drawing board for me! xD
At first I thought it was the SWAT Model so I changed it to the default citizen model :stuck_out_tongue: Still the same error, no worries if you can’t help though :wink:

Post your SWAT job in


 tags.

TEAM_SWAT = DarkRP.createJob("S.W.A.T", {
color = Color(0, 0, 255),
models = "models/player/group01/male_01.mdl",
description = [[You\'re S.W.A.T, Take orders from your Leader and Help Cops Defend the City!]],
weapons = {"m9k_m92beretta","m9k_g36","door_ram","weaponchecker"},
command = "swat",
max = 3,
salary = 75,
admin = 0,
vote = true,
hasLicense = true,
})

See no issue with that. Have you restarted the server since you changed the model?

I see an issue. DUN DUN DUN

Anyways, he wrote models instead of model

facepalm sigh :suicide:
Right! Thanks for noticing that xD For some reason I failed to see that xD Let’s see how the code runs from here :3

[editline]31st August 2014[/editline]

Okay so for some odd reason, whenever I add a second job, it seems to break the F4 menu, the menu is just a blank grey screen…

This is the error that I get:


[ERROR] gamemodes/darkrp/gamemode/modules/base/sh_createitems.lua:460: bad argument #1 to 'PrecacheModel' (string expected, got nil)
1. PrecacheModel - [C]:-1
2. createJob - gamemodes/darkrp/gamemode/modules/base/sh_createitems.lua:460
3. unknown - addons/darkrpmodification-master/lua/darkrp_customthings/jobs.lua:14
4. include - [C]:-1
5. loadCustomDarkRPItems - gamemodes/darkrp/gamemode/libraries/modificationloader.lua:111
6. fn - gamemodes/darkrp/gamemode/libraries/modificationloader.lua:119
7. unknown - addons/ulib/lua/ulib/shared/hook.lua:183

Prior to this, with the code that should have been fixed, I believe this is the error I got.

So I decided to make my own jobs in, 1 by 1, instead of the other persons code, this time in short format.

The first job worked without error…

I added the second job and then I got that error above!


TEAM_SWAT = AddExtraTeam("S.W.A.T", Color(0, 204, 204, 255), "models/player/swat.mdl", [[You\'re here to back-up the Po Po!
Stay in the Police Department until called!]], {"m9k_scar"}, "swat", 3, 80, 0, true, true, false)

TEAM_HITMAN = AddExtraTeam("Hitman", Color(0, 204, 204, 255), "models/player/swat.mdl", [[You kill for money, the bigger the target the
higher the price. (There has to be a legitimate
reason for the hit.)]], {"m9k_svu","m9k_ragingbull","m9k_acr","weapon_mad_xm1014"}, "hitman", 1, 75, 0, false, true, false)

GAMEMODE.DefaultTeam = TEAM_CITIZEN

GAMEMODE.CivilProtection = {
	[TEAM_POLICE] = true,
	[TEAM_CHIEF] = true,
	[TEAM_MAYOR] = true,
}

DarkRP.addHitmanTeam(TEAM_HITMAN)

That’s the code now; SWAT worked perfectly fine until I added a second job ‘Hitman’ which seemed then to break the F4 menu in the gamemode folder, which doesn’t make sense to me… I have re-installed the game mode twice yet still the same problem

It’s really frustrating me now xD

AddExtraTeam and the long format is deprecated.