Help a lua noob make a Class-Based Team Deathmatch Gamemode!

I don’t know so much about scripting, and The Gmod Wiki has great information, but I’m sure the members of Facepunch have more experience and learned how to do things that aren’t on the wiki, or can manage to explain things better.

Basically, this is what I’m trying to accomplish;
-Different classes, each with different stats/abilities.
-Multiple types of weapons with “class-support”, which changes the stats of the gun depending on the player’s class. Ex. A sniper has 15% more accuracy while aiming. Instead of creating multiple versions of the same weapon just to change the accuracy variable, the player’s class would change the stats of the gun.
-Playermodels are different for each team, meaning a class on 1 team would have a different playermodel than the same class on a different team.

Also, I didn’t make this a request because if somebody gave me the entire code, I wouldn’t have done anything, meaning I deserve no credit. I’m not saying “Oh, can someone make this entire code for me so I can take the credit?”, what I am saying is that feedback, constructive criticism and community help would make this a learning experience rather than a copy-paste waste of time for everyone.

Thanks to all those who decide to help me attempt to do this, I’m trying my best to become a skilled lua coder instead of the noob I am right now.

You don’t start a thread basically asking people to give you everything what you do is make the gamemode then if you come across errors debug, not come on here and ask us to tell you everything ahead of time.

what you wanna do is in the SWEPs is do a check for the players class. If it is a sniper class then change the accuracy variable 15% higher than the default.

We aren’t going to feed you code if you don’t make an attempt at it yourself. There are plenty if ways to make these things work, just think of one and try it, if it doesn’t work bring it to FP and tell us what you tried to do.


make table that has each class with each data you need for that class: example

classes = { }
classes[“Assault”] = { printName = “Assault”, model = “ModelPath”, spawnpoints = { Vector(0,0,0), Vector(0,0,0) }, loadout = {“M4a1”, “M9”} }

Then, you have a function to select the class and call the data from the table, applying it to the player.

function classes:Get( class )
if(!class or ! self[ tostring(class)])then return end
return self[ tostring(class)]

function classes:SetClassModel( pl, class )
if ( !pl or !class ) then return end
local info = self:Get( tostring(class) )
pl:SetModel( info[“ModelPath”] )

just an idea., sorry for sloppyness, wrote in facepunch