Hello I am Chad I just popped an adderall most I assume most of you know who I am. If you don't this picture should be enough. I played this game for a decade now and because of it I became extremely anti-sematic. Six years ago I started to code for this game which was one of the best decisions unironically in my life as it started my ventures in coding. I am currently a comp sci major in my second year because of the decision. Why I enjoy coding because it is a artform and you can basically create anything if you're creative enough. An example is a Geroge Floyde emote that says I can't breath AGAIN when you use it. Which has already made me 80$ hahahhaa. So first we need the basics for coding. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - TOOLS First Editing the code https://code.visualstudio.com/?wt.mc_id=DX_841432 After installing it on a side bar there is a addon section type Gmod Lua and install it. Second https://steamworkshopdownloader.io/ Is how you will download and edit most code - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - HOW FILES WORK IN GMOD I will talk about how the code works now Garry's Mod files are three types all in .lua There is client files These are client only files usually VGUI When you join a Gmod server these are downloaded to your client at the end of workshop Second is shared files These are files shared between the Server and the Client This can be things things such as anti-cheats The client portion checks the client for cheats Server code then tells staff if they have cheats When you join a Gmod server these are also downloaded to your client at the end of workshop Server side files This is things that only the server has access to It can be damage variables for weapons It can be double jumping These files are not downloaded to the client - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - START CODING How to start coding for this game After you read the past sections. Gmod is mostly open source and everything can be downloaded off in the workshop to be configured to your needs I will explain how I started using TFA BASE All code usually is run off a API and TFA BASE is a weapon foundation It calculates bullet falloff, damage, what happens when you use mouse1 to shoot. These API are extremely complicated and I am not at the skill-set to create my own yet. This is how I started coding on Gmod. First download TFA BASE -- Don't worry about this foundation [TFA][AT] INS2 Shared Parts -- Don't worry about this foundation [TFA][AT] Sterling -- This is what you will be editing Use https://steamworkshopdownloader.io/ to get the code for these Paste the steam workshop links into it you will then get a zip file Extract the files into \steamapps\common\GarrysMod\garrysmod\addons Now going to single player all these addons should be active. Spawn yourself a sterling weapon in q Menu weapons. You can edit weapon files while Gmod is active usually. go to TFAAT-Sterling\lua\weapons\tfa_ins2_sterling.lua Open it. You can edit most values of weapons here from damage to fire rate to muzzle flash etc After you are done editing it you can save it CTRL + S and the edited configuration should work. Restart the single player session the config doesn't work right away I suggest just fucking around with it. I will go more in depth later. You can browse workshop and download addons to see how they're coded and this is how I got experienced coding .lua - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - HOOKS Hooks are usually called (When the code is activated) during certain conditions I will talk about TTT here. https://www.troubleinterroristtown.com/development/hooks/ all TTT hooks. TTTBeginRound That hook is called when a TTT round begins. Uses for this can be anything. You can set players HP to 500, kill all of them etc Role counter code here. When round begins rolls are printed to chat local ROLE_SPECTATOR = 3 -- local means local to this .lua files other .lua files cannot access it local roles = -- This is table to hold values { [ROLE_INNOCENT] = {string = " Innocent", color = Color(98, 255, 0, 255)}, -- string = Innocent the color is 98, 255, 0, 255 [ROLE_DETECTIVE] = {string = " Detective", color = Color(82, 119, 255, 255)}, -- string is Detective the color is 82, 119, 255, 255 [ROLE_TRAITOR] = {string = " Traitor", color = Color(255, 0, 0, 255)}, -- string is Traitor the color is 255, 0, 0, 255 [ROLE_SPECTATOR] = {color = Color(255, 255, 0, 255)} } net.Receive("TTT_RoleCount_Start", function() -- Net recieve is when local rounds_left = math.max(0, GetGlobalInt("ttt_rounds_left", 6) - 1) -- This code makes this .lua code end if it is the last round of match I configured this for personal reasons if rounds_left <= 0 then return end -- If rounds left is 0 then return end ending this code it will not go further local innocents = net.ReadUInt(6) -- Asks server how many innocents there are stores value in innocents local detectives = net.ReadUInt(6) -- Asks server how many detectives there are stores value in detectives local traitors = net.ReadUInt(6) -- Asks server how many traitors there are stores value in traitors local spectators = net.ReadUInt(6) -- Asks server how many spectators there are stores value in spectators chat.AddText -- Sends chatbot message ( color_white, "[ ", Color(149, 179, 255), "REDACTED", color_white, " ] ", -- Color white is just 255,255,255 - Color(xx,xx,xx) is just what color text will be color_white, "There are ", roles[ROLE_INNOCENT].color, innocents .. roles[ROLE_INNOCENT].string .. "s", color_white," - ", -- roles is a table and it has things stored in it -- roles[ROLES_INNOCENT].color calls the table which value is color = Color(98, 255, 0, 255)}, -- innocents is value that was called by server asking how many innocents there was -- roles[ROLE_INNOCENT].string .. "s", is asking for that tables string which is Innocent -- roles[ROLE_INNOCENT].string .. "s", = Innocent + s = Innocents -- [ REDUCTED ] There are 1 Innocents - -- Is the value what will be printed after this code is ran roles[ROLE_DETECTIVE].color, detectives .. roles[ROLE_DETECTIVE].string .. "s", color_white, " - ", -- Same as above roles[ROLE_TRAITOR].color, traitors .. roles[ROLE_TRAITOR].string .. "s", color_white, " this round." -- Same as above -- After code reaches this point it will print [ REDUCTED ] There are 1 Innocents - 0 Detectives - 1 Traitors this round ) end) -- Where the code is ended - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - I will go further in depth here whenever I binge adderall This game is dying, it's old but the community has kept it alive for the past decade I think it's a great way to get started in coding because of the autistic things you can create Also wiki for most functions like Color(xx,xx,xx) chat.addtext can be found https://wiki.facepunch.com/gmod/
This guy makes great guides on youtube https://www.youtube.com/c/CodeBlue But really all you have to do is read the documentation to be successful. glua isn't exactly hard lol