DarkRP Creating Job error

Hello, recently I started a thread on how to receive files from data folder.
I was trying to add DarkRP jobs, and now everything works but, the creating job part!


AddCSLuaFile()
local locations = {}

function INITIALIZE()
	local files, directories = file.Find( "the-creator-logs/jobs/*", "DATA" )
	
		for k,v in pairs( directories ) do
			table.insert( locations, "the-creator-logs/jobs/"..v )
		end
		
		for k,v in pairs( locations ) do
			LocalPlayer():ChatPrint( "Salary for "..directories[k].." "..file.Read( v.."/salary.txt", "DATA" ) )
			LocalPlayer():ChatPrint( "Category for "..directories[k].." "..file.Read( v.."/category.txt", "DATA" ) )
			
			-- Jobs
			TEAM_..string.upper( directiories[k] ) = DarkRP.createJob(directories[k], {
				color = Color(255, 255, 255, 255),
				model = {
					"models/player/Group03/Female_01.mdl",
					"models/player/Group03/Female_02.mdl"
				},
				description = [[This text will serve as the description of this team.]],
				weapons = {"weapon_p2282"},
				command = "godley",
				max = 5, -- at most 70% of the players can have this job. Set to a whole number to set an absolute limit.
				salary = tostring(file.Read( v.."/salary.txt", "DATA" )),
				admin = 0,
				vote = false,
				hasLicense = false,
				ammo = {
					["pistol"] = 60,
				},
				category = tostring(file.Read( v.."/category.txt", "DATA" )), -- The name of the category it is in. Note: the category must be created!
			})
		end
end
hook.Add( "Initialize", "Initialize", INITIALIZE )

Now if I have this outside of hook.Add it loads BUT, it cant have the names I want it too have.
Example: TEAM_…string.upper( directiories[k] ) = DarkRP.createJob(directories[k]. Directories is from the local up top and [k] is the file number of the k,v. Anyway, I wan’t to create a job for every single file found. It works, without the darkrp add job. Anyway I can go around this? And I am trying to make a table called: TEAM_(directoryname) but it errors. Maybe thats my probleM?

Thats not how programming language works…
TEAM_ its not a string, its a var object, you cant concatenate variables as it, you got the idea but you took the worst way to implement it

I could be wrong here, but I think this solves that problem:
[lua]
G["TEAM" … string.upper( directiories[k] )]
[/lua]

A bit of a hacky solution, but really, it should be done with team.GetName or the job name.

Quick question, whats with G? because DarkRP TEAM(name) not GTEAM(Name)

G is the global table Lua stores everything in by default. TEAM enums are globals stored in _G. Again, you should look into using team.GetName or using the job name.

But whats the point of that, like why would do you define a variable that later you cant access with other hacky methods, what about if you just do a global table containing those jobs with the folder name as indexes so you can really access at them
This just will bring more problems than solutions

A bit unrelated but you should localize INITIALIZE() since you probably only made it for the hook.

And to explain this:

_G is the global table where the shizzle is stored as code_gs said, where the indexes are the variable names.

Some examples with their alternatives
[lua]
print( “test1” )
_G"print"

mymoney = 500
_G[“my” … “money”] = 500
[/lua]

Its pretty useful for using variables inside variable names, though you should probably go for code_gs’ solution.

Yes, but that will ruin the purpose. And aswell, I have tried that, thats why the solutions are hacky.

[editline]19th November 2016[/editline]

I will, but lol. Concatonating a string? Makes no sense man. “”…"" that will not work, it should be more: “my money”… xD

Nice try though.

What? Concentrating is connecting multiple strings, so saying that makes no sense is a bit silly. And I just gave the example because it was relevant to your problem, and to portrait the difference to defining a variable normally.

And there is no space because variable names can’t contain spaces