Learn how to code GLua.

ALright so this will be rated dumb, I can tell but I really would like to learn Glua to start coding things e.g. gamemodes, HUD’s and sweps. The only thing I have made so far is a very basic darkrp HUD but I am not happy with it so I want to know where I could learn how to code more advanced things :slight_smile: so the actual question if you still have no cue what it is yet is where do I go to learn some Glua :slight_smile:

Well what is it you are trying to make? The wiki has anything you would need.

Make a cheat

Make a Millitary/Life gamemode but in depth more serious than most DarkRP servers. e.g. Whitelist system, kinda like a job application menu and things like that but I have very basic knowledge of Glua so I don’t even know if what I want to do is possible and what commands to look for.

I think the problem I see most people do in this matter is: “I want to learn lua” -> “I want to create this”. It doesn’t really work that way, just as you can’t say “I want to learn english” -> “I want to say banana”.

If you actually want to learn, it’s a long process of learning various things related to coding in general. Although while a gamemode covers I guess many parts of this aspect(what I wrote above was more for people saying like “I want to create an inventory”) - it’s still a long way to go.

Here you can get a good start:

However, all the basics you learn in lua basically applies to any other language - loops, variables, functions etc - although in gmod lua you also generally will need to understand realms(server/client/[shared]), and how to safely communicate between them - but it’s nothing you need to start on right away, however, the basics of it is not difficult to pick up.

But imagine creating a gamemode - obviously:
alot of various serverside functions
alot of clientside code, as well as derma menus etc
alot of communication between server and client

you don’t go to school and learn “math” to be able to “math”, there’s alot of different areas in every subject and you will have to pick up most of them before you can say you’ve learned it.

you can’t get away from having to do it from the bottom up, if you want to learn lua. If you just want a gamemode you should pay someone to do it, because it will take you a good time before you have a gamemode of the kind you want.

Something that is a little bit difficult to put in words, but it feels like people in general who wants to learn how to code has no clue what it involves. I mean you are not writing thousands of lines containing cryptic characters, it’s generally english words(for, do, while, function), rarely there’s any need for advanced math, do some + - here and there. It all comes into something big, you don’t magically learn how to create a gamemode, it’s just different combinations of these pre defined words(and your own functions and variables ofc).

final add:
if you learned how to code, you won’t just be “hi I’m a coder of militaryRP gamemodes”, that’s what I’m trying to say. Just learn to code and you can create an inventory, an npc, a melon, a gamemode, a derma menu, a scoreboard - that’s why you need to learn it from the bottom, don’t follow gamemode tutorials etc just learn how to code and you can use your knowledge in most other languages too.

basically you just work your way up
huds are a good start for beginners, next you should look into coding some sweps and entities. After that have a mess around with hooks and serverside logic and make something basic like idunno, maybe a confirmation menu for when you try to suicide (do you really want to die?) etc
get a workshop decompiler and pull other peoples stuff apart to see how it ticks, there’s plenty of good stuff out there that will teach you heaps about how glua works
learning to code is a long process but if you stick to your guns and don’t give up you’ll get there in the end

@Busan al right thanks :slight_smile: I am looking into those tutorials right now. I understand what you are talking about this thread was more about where to begin? I just stated my end goal if it helped.

@legendotrobbo I sure will make my own swep after I learn more :slight_smile:

I started with money printers and making drug addons!

Read simple gamemodes/addons. Figure out how they do everything they do and what all their code means.

I started out by making a cheat and copy pasting code from other cheats on like mpgh or something, and slowly understood how the code I copy pasted worked. I gradually rewrote it all into my own code until I got bored with it. I learned a lot from it

I started with some client-side scripts (i.e. HUDs) and I’m slowly advancing after every script I make. I started with a HUD, then a scoreboard, then an F4 menu, and soon will be getting into work with entities and 3d2d things. Asking for a little bit of help from friends or forums can get you far too.

Make a tool of some sort. They are very easy to follow and are simply structured.

You can always just stick with HUD stuff :v: I’ve barely touched gLua beyond derma and I’ve still managed to have fun learning stuff - for example, how to perform sphere intersections based on normal vector coordinates generated based on mouse positions (just because I wanted a red dot to appear on a model depending where the user clicked -_-)

To be honest, when I first started lua i found client-side stuff much harder then server-side, but that might be because I already had a much larger knowledge of how servers work then clients, and I think I was thinking about it the wrong way.

My first few scripts where:

  • Permanent Weapons - start by hooking into PlayerSpawn and read a file to see if their name;weapon appears, if it does give the weapon. Add console command to add entries to the file.
  • VIP Event add on - give VIP on login - store all players who where not already VIP in a file and once you run the console command to stop it, send them all back to default rank. (ULX).

I think working with files ( reading/writing ) is quite a good place to start as it gives you a insight into much large data management such as SQL.

As for how to do this, I was lucky enough to have Neth, who to this day probably regrets offering me help, however there are lots of guides on how to get started, and a few videos. Plus, obviously you have Facepunch! :slight_smile:

The main advice I can give you, is start small. Even now when I work on projects I need to try not to think too big when starting out, or it can become overwhelming. Start with the basics. Especially when doing a game: What do you want to happen when the game-mode loads, what happens when a player is authed, what happens when they spawn. Do they die? If so, what happens then. Just build it up and up until you have something that feels like a game-mode, :P.