How many variables becomes too much for a gamemode?

As the title says, how many variables is “too much” for a gamemode to work properly?

Edit: To give you a context, I’m working on classes and every information about the class, how it reacts and what it should do is stored in an array. I don’t have any idea how many classes I’ll have yet but there’s A LOT of stuff in each classes.

You can’t really set a number on that. You should read into data structures, it’s really just about how much data is in memory.

Okay, well let’s say I have static information and I’d like to load it when used. Do I have to keep it in a .txt file and load on use or can I keep it in a seperate .lua file and include() it on use?

you should probably keep it on a .lua file, but the reason is so you don’t have to waste time parsing it.

Okay, but my question is; Can I include() on the fly or I have to do it on init?

no you cannot include a lua file as you go, I don’t even know why you would do that. an include implies that file must be loaded before the file you’re running your code on is loaded.

also you don’t do it IN init at all, you do it before everything else you’re doing, since includes are, well, what the name implies, things you must include in your code. essentially, its stuff you require.

Well that’s an exemple of what I’m trying to achieve with classes, they all have their own files.

  • This one is half completed

[lua]/* ------------------------------------------------- This is a class folder, it describes actions
for this class.
------------------------------------------------- */

– Variables of use in your spells
– abilityLevel[abilityID] : This is the current level of the ability.

– Normal stuff
marksman = {}

marksman[“name”] = “Marksman” – The name of our class.
marksman[“description”] = “An adept shooter.” – The description of our class.
marksman[“price”] = 500 – How much credits to unlock this class?

– Abilities
– They can range from a variety of uses. But we’ll try to keep it simple.

marksman[“abl”] = {}

marksman[“abl”][1] = {}
marksman[“abl”][1][“name”] = “Powershot”
marksman[“abl”][1][“description”] = “Increase the damage of your next attack.”
marksman[“abl”][1][“dmg”] = 5
marksman[“abl”][1][“cooldown”] = 5

marksman[“abl”][2] = {}
marksman[“abl”][2][“name”] = “Camouflage”
marksman[“abl”][2][“description”] = “Stealth yourself when crouched.”
marksman[“abl”][2][“dmg”] = 5
marksman[“abl”][2][“cooldown”] = 5

for k,v in pairs(marksman[“abl”]) do print(k) end

/* -------------------------------------------------
This is the function section. What to do
with the spell informations.

OnNextAttack = Called when shooting before
                the bullet is fired.
OnNextAttackHit = When the next attack hits
                    a target.
OnNextAttackLand = When the next attack lands

------------------------------------------------- */

– Now the functions that do the actual thingies.

marksman[“OnNextAttackHitEnemy”] = function( ply, target, dmginfo )

if ply.abilities[1]["curCooldown"] <= 0 then 
    ply.abilities[1]["curCooldown"] = marksman["abl"][1]["cooldown"]


marksman[“OnThink”] = function( ply )


If I have, let’s say, 20 of those I just hope it is going to be fine.

Try to do GM.Classes = {} and then GM.Classes[“marksman”] = {}

Better to store all this information in one gamemode table then 20 global tables.

This is how I store them when included. This makes it so I can add/remove classes only using include.

[lua]/* ------------------------------------------------- The class system for our gamemode.
It’s all server side.
We have to inlude the files in our class folder.
------------------------------------------------- */

include( “lmnt_classes/class_marksman.lua” );

gamemode.classTable = {}
gamemode.classTable[0] = {}

gamemode.classTable[0][“name”] = “No Class”
gamemode.classTable[0][“description”] = “You don’t have any class selected yet.”

– The marksman
gamemode.classTable[1] = marksman[/lua]

Edit: Wait I’m dumb… I’ll just put the gamemode prefix in the class file itself…

why not do
[lua]gamemode.classTable = {

	name = "No Class";
	description = "You don't have any class selected yet.";



The syntax is correct and does the same as what you want it to do.

GAMEMODE.CLASSES[“marksman”] = {}
GAMEMODE.CLASSES[“marksman”][“dec”] = “blah”
GAMEMODE.CLASSES[“marksman”]["abl] = {}


To answer the main question though, you’re never going to run into an issue with variables like that. You can store more information in variables than you can probably think of to type.

That’s a lot guys, this helps a great deal!

@Hentie, I’ll definatly use this syntax as it removes lots of useless code.

@Spencer, Alright perfect then, I can go all out.