Skip to content

CodeSteel/HowToGMODServer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 

Repository files navigation

How to Manage a Garry's Mod Server

Welcome to "How to Manage a Garry's Mod Server", here I will try to explain the process of managing a Garry's Mod server properly with the aim of productivity and scale over time. I am sick of seeing populated servers with horrible development practices and even more so, tired of working for them, so read this guide and fix your shit.

Disclaimer, all of the information in this README was gathered from my own personal experience. I built and managed a successful Garry's Mod server in the past and continue to do commissions for other servers in the community.

The Explanation

1. Github

You need Github. Plain and simple. You will want to use Github for two main reasons, although there are many many more reasons why Github should be used.

  1. Github allows you to store a backup for every single update and every single line of code you change. This means, if you fuck shit up, you can easily revert back.
  2. Git's source conrol allows working with future developers, or any development you and your team contributes, much easier to manage and deploy as you can have mulitple people working on the same project at a time.

If you plan to hire a developer for any commission work, a Github repository is a MUST. DO NOT hire anyone for commission work without this step.

2. Local Dedicated Server

You will want to set up a local dedicated server, this will be your dev server. Any future work YOU do should be done through this server. DO NOT use FTP to update your code, that is very bad practice.

Hosting the server yourself is free and allows you to develop much faster.

It is also what we will be using to store your local github repository branch so you can make updates to your live server without ever touching or modifying any of the files, only your local files.

3. DeployHQ

DeployHQ makes it easy to deploy your github repository to the live server. What this means is any updates you or your team makes can be pushed to the live server with a click of a button. This allows us to take the changes you've made in your local server and send them to the live server to be updated. DeployHQ is free, but limited to 5 deploys a day. As long as you have a decent update routine, this won't be an issue.

The Setup

1. Github

  1. Start by creating a Github account if you don't have one already.
  2. Create a new Github Organization with your ServerName/CompanyName.
  3. Create a new Private Reposiory for the Gamemode you are developing under that organization. Make sure it is set to Private.

It should look something like this github.com/MoonNetwork/DarkRP image

Next we need to set up the local server before going any further with Github.

2. Local Dedicated Server

  1. First you need to install SteamCMD. SteamCMD is used to download/update the Garry's Mod game. You can go here, scroll down to Download, and following the instructions for your OS.
  2. Create a new directory for your server located in a safe location and name it whatever you want. I.e. "MoonNetworkDarkRP". Save the location of this directory as you will need it for the next step.
  3. Go to where you installed SteamCMD and open it. The first time you open the program, it will download all of the required files for it to run. Once it has finished, type in these commands in order:
force_install_dir <path_to_your_server_directory>
login anonymous
app_update 4020 validate

This will install the Garry's Mod Dedicated Server in that directory, now we need to configure it.

  1. Create a new file in the root directory of the installed garry's mod server, name it start.bat.
  2. Open it and paste these contents, but make sure to replace the with your own.
start "SRCDS" /B srcds.exe -game garrysmod -conlog -port 27015 -console -conclearlog -condebug -tvdisable -maxplayers 16 +gamemode <GAMEMODE_HERE> +r_hunkalloclightmaps 0 +map <MAP_HERE> -tickrate 26 +fps_max 26 +host_workshop_collection "<WORKSHOP_ID_HERE>" +sv_lan 0

Now if you run start.bat, a terminal should open and the server should start. If it doesn't run, then congratulations you failed.

Now that we have the server installed, we must set up our github repository with the addons folder.

If you already have a live server with addons installed, now is the time to copy everything from the live server to your local server, only the addons folder.

  1. Open a terminal in your local server's addons directory. You can do this by right cicking in the directory and clicking "Open in Terminal".
  2. Type in these commands to initialize the github repository with the repository you made.
git init
git remote add origin <THE_URL_TO_YOUR_REPOSITORY>
git fetch
git checkout main
git add .
git commit -m "init"
git push origin main

This will initialize a new repository, set it up with the repository you made, fetch any files the repo may have, add the files we already had, and push it to git.

Congratulations, you created a repository and are now backing up your server files. Let's move on and set up DeployHQ.

3. DeployHQ

  1. Go to https://deployhq.com/ and create a new account.
  2. Sign into your deploy panel and you should be greeted with a "Create a Project" screen. image
  3. Fill out the server information and select Github, click Create Project. image
  4. You should be able to link your Github account to your DeployHQ account, allowing you to select the Server's Repository. image
  5. Now we must link the repository to the live serve so updates can be pushed. Fill out the New Server form with your server's connection info. For Physgun servers, use SSH/SFTP. image
  6. On the bottom of the page, you should see Deployment Path as an option. This will be the directory the repository is updating the files to. For Physgun servers, this should be /garrysmod/addons, though it could differ depending on the server's host. Now you can click Create Server. image

If you didn't get any errors then great, it worked. Otherwise, you're going to have to debug the problem.

Now whenever we want, we can go to the deploy's overview page and click New Deployment. This will allow you to update the server with the latest commit, which should be "init". Go ahead and run the first deployment so DeployHQ is synced with what files we have on the server.

Check FTP and make sure all the files are in the correct place. Great, this is probably the last time you'll need to use FTP.

4. IDE (Visual Studio Code)

You will most likely want an IDE, in this case Visual Studio Code, to manage/update your files. Visual Studio Codes makes things easier by having a built-in Source Control window which shows every change you've made on that commit. It's helpful for those times you forget what you've changed and want to look back and verify everything is good. It can also be helpful for mass-finding a function or string that is messing up. Just click Ctrl + Shift + F to search through every file.

  1. Download and install Visual Studio Code here
  2. Now you can open your addons directory in VSCode and boom, you have the power of FTP all in one editor! 😎

The Conclusion

Now that we have the Github Repository storing the server files, the DeployHQ account ready to push our changes to the live server, and the dedicated server to make the changes on, we just need to put it all together.

Development Flow

  1. Open your server's addons directory in VSCode. You can either open a terminal in the addon's directory and type code . or you can right click in the directory and click 'Open with Code'.
  2. Make a change, or changes.
  3. Push changes to Github:
git add .
git commit -m "feat: my changes"
git push origin main
  1. Go to your DeployHQ overview and click New Deployment. Click Deploy to deploy your latest commit to the sever.

And that's it, you just updated the live server with your local server's files!

Bonus!

When commiting to github, you have to type 3 commands that are hard to remember every time. Make this process easier by installing my Github CLI, Boom.

This cuts down the pushing process from this:

git add .
git commit -m "feat: my changes"
git push origin main

To only this:

boom push "feat: my changes"
  1. Start by installing NodeJS, here You may have to restart your computer after, I am not sure.
  2. Now install the Boom package with this command:
npm install -g @steelio/boom-cli
  1. Now close the terminal and open it back up and type boom.

If it works then great, you successfully installed Boom. Now everytime you want to push an update, type boom push "the update message"!

Thanks for reading this guide! I hope you found something useful in it. If you want to contribute, just make a PR ❤️

http://codesteel.io/

About

How to manage a Garry's Mod Server, properly.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published