Lua Table is Nil? Am I just being stupid here? Help!

So I am updating applejack, and what was working before has now broken itself just from me removing the password from the server? Weird I know, so here’s the error.

[ERROR] gamemodes/applejack/gamemode/sh_config.lua:73: table index is nil

  1. unknown - gamemodes/applejack/gamemode/sh_config.lua:73
  2. include - [C]:-1
    3. includecs - gamemodes/applejack/gamemode/sh_init.lua:7
    4. unknown - gamemodes/applejack/gamemode/sh_init.lua:11
    5. include - [C]:-1
    6. unknown - gamemodes/applejack/gamemode/init.lua:20

Its all branching from the “table index is nil” as you know so here is sh_config.lua!

Name: "sh_configuration.lua".
	~ Applejack ~
local config = {};

-- Player Defaults
config["Default Money"]				= 50000; -- The money that each player starts with.
config["Default Job"]				= "Citizen"; -- The job that each player starts with.
config["Default Clan"]				= "No clan "; -- The clan that each player belongs to by default.
config["Default rpname"]            = "John Doe"; -- Default rpname
config["Inventory Size"]			= 65; -- The default inventory size.
config["Default Access"]			= "beptp"; -- The access that each player begins with.

-- Command
config["Command Prefix"]			= "/"; -- The prefix that is used for chat commands.
config["Maximum Notes"]				= 10; -- The maximum amount of notes a player can write.
config["Advert Cost"]				= 150; -- The money that it costs to advertise.
config["Advert Timeout"]			= 60 -- How many seconds between adverts
config["OOC Timeout"]				= 8 -- How many seconds between OOC messages
config["Item Timer"]				= 2 -- How many seconds between item uses
config["Item Timer (S)"]			= 10 -- How many seconds between specific item uses
config["Note Fade Speed"]			= 30 -- How many minutes after being spawned notes should dissapear.

-- Door related things
config["Door Cost"]					= 150; -- The money that it costs to purchase a door.
config["Door Tax"]					= false; -- Whether door taxing is be enabled.
config["Door Tax Amount"]			= 50; -- The amount of money a player is charged in tax per door.
config["Maximum Doors"]				= 15; -- The maximum amount of doors a player can own.
config["Jam Time"]					= 60 -- How many seconds a door is jammed open for
config["Door Autoclose Time"]		= 15 -- How many seconds a door should autoshut after

-- Player Stuff
config["Walk Speed"]				= 150; -- The speed that players walk at.
config["Run Speed"]					= 275; -- The speed that players run at.
config["Incapacitated Speed"]		= 100; -- The speed arrested/tied/carrying players walk/run at.
config["Jump Power"]				= 160; -- Player's jump power. Don't mess with it unless you know what you're doing
config["Spawn Time"]				= 13; -- The time that a player has to wait before they can spawn again (seconds).
config["Bleed Time"]				= 5; -- The time that a player bleeds for when they get damaged.
config["Knock Out Time"]			= 30; -- The time that a player gets knocked out for (seconds).
config["Sleep Waiting Time"]		= 10; -- The time that a player has to stand still for before they can fall asleep (seconds).
config["Arrest Time"]				= 300; -- The time that a player is arrested for (seconds).
config["Earning Interval"]			= 300; -- The interval that players receive money from their contraband (seconds).
config["Search Warrant Expire Time"]= 300; -- The time that a player's search warrant expires (seconds)
config["Arrest Warrant Expire Time"]= 300; -- The time that a player's arrest warrant expires (seconds)

-- Unused entries
config["Death Penalty"]				= 2; -- The percentage of money players lose when they die.
config["Rope struggles"]			= 5 -- How many 'struggles' it takes for you to undo your rope
config["Tying Struggles"]			= 1 -- How many struggles it takes to get out of being tied up
config["Tying Struggles Timeout"]	= 30 -- How many seconds it takes for your struggle meter to fill

-- Voice
config["Local Voice"]				= true; -- Players can only hear a player's voice if they are near them.
config["Talk Radius"]				= 256; -- The radius of each player that other players have to be in to hear them talk (units).

-- Damage
config["Scale Ragdoll Damage"]		= 1; -- How much to scale ragdolled player damage by.
config["Scale Head Damage"]			= 5; -- How much to scale head damage by.
config["Scale Chest Damage"]		= 2; -- How much to scale chest damage by.
config["Scale Limb Damage"]			= 0.75; -- How much to scale limb damage by.
config["Anti propkill"]				= true -- Disables damage recieved from prop_physics', unless it's fall damage.

-- Other
config["Website URL"]				= ""; -- The website URL drawn at the bottom of the screen.
config["Cleanup Decals"]			= true; -- Whether or not to automatically cleanup decals every minute.
config["Model Choices Timeout"]		= 30 -- Number of seconds to wait before reconnecting if model choices aren't sent.
config["Autokick time"]				= 15 * 60 -- Number of seconds a player has to do something in to avoid being kicked

-- SWEP related
config["Lockpick Break Chance"]		= 0.01; -- The probaility to add to the lockpick snapping on a hit for each lock successfully picked.
config["Maximum Lockpick Hits"]		= 30; -- The maximum amount of hits a lock takes to pick
config[TYPE_LARGE]					= 1 --Number of 'big' weapons that can be carried at once. Putting this above 1 will provide strange results, so don't.
config[TYPE_SMALL]					= 2 --Number of 'small' weapons that can be carried at once

-- Plugins
config["Officials Contraband"]		= true; -- Whether city officials, i.e. City Admin, CP get contraband payments.
config["Need Warrant"]				= false; -- Whether city officials need warrants to destroy contraband.
config["Police Kill Drop"]			= true -- Whether or not weapons should drop when a player is killed by the police.

config["Hunger Minutes"]			= 30 -- The number of minutes it takes before your hunger is full.
config["Hunger Damage"]				= 5 -- The amount of damage a second you are dealt while starving
config["Hunger Death"]				= true -- Whether or not you can starve to death

config["Stamina Drain"]				= 0.35 -- The amount of stamina lost every 0.1 seconds while running
config["Stamina Restore"]			= 0.15 -- The amount of stamina restored every 0.1 seconds while not running.

config["Car Doors"]					= true -- whether or not you must be looking at a car door to gain entry

-- Props
config["Prop Limit"]				= 30 -- The amount of props donators can spawn
config["Builder Prop Limit"]		= 30 -- The amount of props builders can spawn
config["Builder Prop Cost"]			= 0 -- The price of each prop a builder spawns

-- Job related
config["Master Race"]				= false -- All group changes must go through one base class
config["Minimum to demote"]			= 5 -- Minimum players in a gang before the leader can demote people from it
config["Minimum to mutiny"]			= 4 -- Minimum players in a gang before the leader can be mutinied against
config["Mutiny Percentage"]			= 0.75 -- Minimum percentage of positive mutinies

-- Tying System
config["Tying Timeout"]				= 5 -- How many seconds it takes to tie someone up
config["UnTying Timeout"]			= 5 -- How many seconds it takes to untie someone

-- Tables

config["Back Weapons"] = {
	[TYPE_LARGE] = true
} -- Which weapons go on your back when not deployed.
config["Weapon Timers"] = {
	["deploytime"] = {
		[TYPE_LARGE] = 2,
		[TYPE_SMALL] = 1
	["redeploytime"] = {
		[TYPE_LARGE] = 2,
		[TYPE_SMALL] = 1
	["reholstertime"] = {
		[TYPE_LARGE] = 4,
		[TYPE_SMALL] = 2
	["deploymessage"] = { -- 1 gun type, 2 gender
		[TYPE_LARGE] = "pulls a %s off %s back",
		[TYPE_SMALL] = "pulls a %s out of %s pocket"
	["equiptime"] = {
		[TYPE_LARGE] = 2,
		[TYPE_SMALL] = 1
	["Equip Message"] = {
		["Start"] = "starts rummaging through %s backpack",
		["Final"] = "pulls out a %s gun and puts %s backpack back on",
		["Abort"] = "gives up and pulls %s backpack back on",
		["Plugh"] = "slides the %s gun back into %s backpack and puts it back on"
		 -- 1 gun type, 2 gender
		[TYPE_LARGE] = "Pulls out a %s and puts %s backpack back on",
		[TYPE_SMALL] = "Pulls out a %s and puts %s backpack back on"]]
	["holstermessage"] = {	 -- 1 gun type, 2 gender
		[TYPE_LARGE] = "puts the %s back on %s back",
		[TYPE_SMALL] = "puts the %s back in %s pocket"
} --

config["sv_tags"] = {
	"applejack", -- Please always leave this in
	"cider" -- Never forget your origins
} -- tags you want added to the sv_tags convar
config["Usable Commands"] = {
}; -- Commands that players may use at any time
config["Default Inventory"] = {
	health_vial = 5,
	chinese_takeout = 5
}; -- The inventory that each player starts with.
config["Contraband"] = {
	cider_drug_lab = {maximum = 5, money = 50, name = "Drug Lab", health = 100, energy = 5},
	cider_money_printer = {maximum = 2, money = 150, name = "Money Printer", health = 100, energy = 5}
}; -- The different types of contraband.
config["Male Citizen Models"] = {
}; -- The male citizen models.
config["Female Citizen Models"] = {
}; -- The male citizen models.
config["Banned Props"] = {

}; -- Props that are not allowed to be spawned.
config["Rules"] = [[
1. Do not break NLR. NLR is a new life rule. You forgot everything of your past life.
2. Don't spam.
3. Do not RDM - RDM stands for Random Death Match. Do not just randomly kill people which will fllow to a ban.
4. Follow FearRP - If someone has a gun on your head you are to do what they say.
5. Do no failRP - If your a gun dealer you don't randomly steal peoples cars. You roleplay to what your job is. Custom jobs are to follow the same thing.
6. Do not Random Arrest(RDA) - You have to have a reasoning behind it.
7. Do not randomly steal cars(RGTA) - If your say some kind of rebel or mafia you must have a reasoning behind stealing the car.
8. No Random Raiding(RR) - You must have a reason behind it. A RP Reason. Laws are a reason to raid or dictaorship.
9. If you are to have anything like [M] which is what the admins use you will be asked to remove it, if you don't you will be banned perminantly as this is impersonating a member of Staff. Use [M:RP] to support us!
10. The president can not random warrant people for search or arrest. There must be a reasoning behind it like contraban/money printers. (or not complying to the laws after warning by a Police Officer.)
11. Prop Spamming/Surfing/Pushing/Blocking/Throwing and Flipping is all against the rules. If you break this rule you will be instantly ban by a staff member for 1 day and if this continues it will lead to a week then a month.
12. There no arguing or sexual talk to be had in OOC.
13. No one may throw props. Do not let us catch you doing this. We will remove your Prop permissions.
14. If anyone is to enter the cave at the lake. You will be permenatly ban as this crashes the server!
15. Do not metagame. When you approuch someone you do not know there name. You do not ask people where they are in OOC. You use /pm. Also if someone you know like your friend or someone is a Police officer, President or any job you can't randomly kill them. This is metagaming. You don't know them in RP and you can't RDM them over a real life situation. This will result on a day ban and so on and so forth.
16. Do not backseat adminstrate. If someone is say CDMing you do not shoot them or handle it with death or CDMing them back. You call a admin to the situation or screenshot them breaking the rules. Then you would tell me intill I have set up our website with a ban request section of the fourms.
17. Do not random tase. This goes for all the jobs. This goes toward FailRP and FearRP. If your being arrested and they have a taser on you. You comply to what they tell you to do.
18. Do not minge. Minging is purposly trying to ruin roleplay and other peoples memorys on the server. These examples are hitting people with axes, random tasing and the rules above.
19. No mic spamming or spamming the chats in general.
20. You have 1 warning, after this you will be banned for a day. Read the rules or be banned.
21. Our staff team is to be chosen by the High up Staff members. Asking for staff is not a option. You will be denied your chance.
22. Rasism and Harassment is not accepted here. If you want to do this stuff go do it some where else. I and my staff do not tolerate this. Perminant ban.
23. The pointshop suits and dresses will be based on how good your rp's are. You can share your rp experiences and builds on the fourms. If people relpy with good feedback and comments on the fourms/post, and how we see the roleplay as amazing, fun, well built you will be given a point for the pointshop. The models will cost more then 1 point. It's not going to be easy. Roleplay well and you will be rewarded.
24. Do not public build without a staff member giving you the ok to build this.
25. If you ask to be a staff member you will be automatically denied and you will have to start from the beggining of gaining our trust.
26. you get <b>one</b> warning after reading this rule. After you break this one warning you will be ban the next time. All suggestions are to be given to any higher up staff.
27. Enjoy and Roleplay. Remember the rules as these come in handy :). Please share and tell your friends to join and have fun with this new community.
]]; -- The rules for the server.
config["Laws"] = [[
[Permanent Laws0]
Contraband is illegal. Anyone found with it will be arrested. Any police found with it will be demoted on the spot.
Murder is illegal.
Assault is illegal.
Breaking into other people's property is illegal.
Stealing cars is illegal.
Explosives are illegal.
Tying people up without their explicit consent is illegal.
You must drive on the right hand side of the road.
You may not walk in the road - Always walk on the pavement or on the zebera crossings.
If you hit something while driving, you are liable for all damages.
Observe the speedlimit. The use of turbo devices is illegal.
You must obey all traffic signals.
Civilians may not enter the inner Government HQ (behind the desk) at any time, unless being escorted by two officers. They must report this to the Mayor immediately.
Civilians may not enter the main Government HQ in times of crisis.
Civilians may not unholster weapons in the Government HQ at any time.
Civilians may not build in a public area without permission.
Civilians may not block any offical thoroughfare without written consent from the mayor.
Civilians may not use silenced weapons
Any civilian seen with an illegal or police weapon will be arrested on the spot.
[Temporary Laws1]

GM.Config = config;

As you can see, at the top the table should be defined but IDK why. (I’m sorta new to lua but not that much. I’m learning.)

Thanks in advance guys! :slight_smile:

TYPE_LARGE or TYPE_SMALL are probably undefined.

What is line 73?

[ERROR] gamemodes/applejack/gamemode/sh_config.lua:73: table index is nil

Just so nobody else goes through the trouble line 73 is

config[TYPE_LARGE]					= 1 --Number of 'big' weapons that can be carried at once. Putting this above 1 will provide strange results, so don't.

Then yes, here’s the exact issue:

Hmmm… I wonder where it’s being defined?

Use notepad++ and search *.lua files for those const/enums. If they don’t exist, declare them, ensure they’re declared in a file that runs BEFORE you run the file in the OP

The problem is that it is not being defined at all.

Wait… type_large is supposed to be defined by the config file right?

I’d define it inside an ENUMeration file, or a definitions file. Typically, all uppercase vars are “constants” meaning never-changing; used for enumeration. So, set it once somewhere before everything loads in. Definitions are one of the highest priority in terms of load-order.

Alright, so I got the gamemode running but still there is the table index is nil. I have looked through the whole gamemode and it isnt being defined. The config file should define it but it’s not?

you’re going to have to reverse engineer the structure of the table if TYPE_LARGE is a table, if it’s not a table you’re going to have to figure out what data type it is suppose to be and what you need to set it to. your best option is looking at an untouched version of applejack and see what it once was, it probably got removed accidentally.

Unless it is being declared somewhere and you can’t find it, and for some reason at some point during runtime it is terminated. Or it could be something that is set during runtime, but you would have found it in the script somewhere.

My guess is that it is being defined somewhere, and as a result of something broken or a faulty repair you made, it is terminating itself due to an error. ( although it doesn’t make sense to change something that is suppose to be constant usually )

Well there is this…

~ AK47 ~
~ Applejack ~

ITEM.Name = “AK47”;
ITEM.Size = 2;
ITEM.Cost = 22000;
ITEM.Model = “models/weapons/w_rif_ak47.mdl”;
ITEM.Batch = 10;
ITEM.Store = true;
ITEM.Plural = “AK47s”;
ITEM.Description = “A very powerful rifle which is great at long range.”;
ITEM.Ammo = “smg1”
ITEM.Base = “weapon”

All of the larger weapons have that

It’s either a table containing data for a category of weapon sizes. You can try printing TYPE_LARGE right above ITEM.WeaponType and see if it exists when the items are being loaded. A lot of times item systems set up temporary variables that are terminated at the end of the item loading process( much like ITEM itself ), my inventory systems do something very similar. Or it’s an integer, and it’s basically a for-convenience enumeration.

In either case i gaurantee you it’s solvable by taking an older untouched version of applejack and searching it for TYPE_LARGE and see what it was being defined as, then update your script with the definition.

Hope that helps. btw i messaged Lexi( applejack author) about this thread, he does not support applejack at all but maybe he will know the problem off hand and post a quick reply if you’re lucky :slight_smile:

It’s probably the same concept as this:
[lua]local i = 0;
WEAPON_SLOT1 = i; i = i + 1;
WEAPON_SLOT2 = i; i = i + 1;
WEAPON_SLOT3 = i; i = i + 1;
WEAPON_SLOT4 = i; i = i + 1;
WEAPON_SLOT5 = i; i = i + 1;
WEAPON_SLOT6 = i; i = i + 1;
WEAPON_SLOT7 = i; i = i + 1;
WEAPON_SLOT8 = i; i = i + 1;
WEAPON_SLOT9 = i; i = i + 1;
WEAPON_SLOT10 = i; i = i + 1;[/lua]

where each type is set to it’s own number.

Hi. TYPE_LARGE is, iirc, the string “large”. (Bonus points if you can guess what TYPE_SMALL is!) I’ve no idea where it was defined, other than before sh_config.lua was called. Try shared.lua.