Hi everyone. this thread will probably be pretty massive, as I intend to gather information about all vital parts of gamemode creation. Sure, the tutorials on the gmod wiki are pretty good, but they do not really explain why it works like it does. It’s mostly “place this code here, and that code there”. I will probably ask questions that have already been answered. I have searched, but to be honest I really suck at searching since I never get the search words right. My ambition is that all info needed to create a gmod gamemode can be gathered in one place, so it will be easier for everyone to learn.
The first thing that should be asked is:
What do you consider to be needed to learn in order to develop a gamemode?
Since I’m a beginner, my guess is:
- 1. How do I know if I should place a code inside Shared.lua, cl_init.lua or init.lua?
After reading tutorials, it’s pretty obvious what their difference are (server, client, or shared), but it’s not very clear how to know when to put wihch piece of code where. Are there any general, good guidelines to follow?
- 2. How do I create stats & variables for players to use?
We maybe want to give the player a “money” varaible
- 3. How do I send data between the clients & the server?
What I know so far is that you can use datastream and/or usermessages.
- 4. How do I make the server save the player’s stats until the next time he joins?
Example: We want to remember the player’s “money” variable the next time he joins.
- 5. What exactly is a hook and how should it be used?
I tried the example code found here. I placed it in cl_init.lua, but I didn’t get it to work (only tried single player, and by dying from worldspawn/entities/npcs). it didn’t give me an error, it simply didn’t show anything in the console upon death. my guess is that it should not be placed in cl_init.lua (but how can I know where it should be placed?)
I don’t know (exactly) what the arguments mean, but i think that’s easy to learn from the wiki
Here are some of the questions I’m wondering about, even after reading on the wiki. the lua language is simple enough, but how to use it is a whole other story. Questions can be answered with links if the link provides good info and explains in which context to use it. like i said before, some of the questions are maybe answered before… my search skill failed me though… Also, if you know anything apart from those questions that you should know when creating a gamemode, please do share.
Hope I made everything clear enough…