Garry's Mod Wiki

Revision Difference

Downloading_a_Dedicated_Server#551006

<cat>Play.Hosting</cat> <title>Downloading and Hosting a Dedicated Server</title> # Windows ## SteamCMD Dedicated servers are now downloaded using SteamCMD. This is a command line version of Steam. You can download it [from this page](https://developer.valvesoftware.com/wiki/SteamCMD). The first time you run it it will update and you will be left at a STEAM> console. You will want to log in. You can log into an anonymous account by typing: ``` login anonymous ``` ## Installing & Updating Garry's Mod Dedicated Server If you want to specify a download folder then before you update enter this command: <note>This is known to cause problems when updating your server to a newer version. If your server fails to update, try not using the `force_install_dir` feature, or try reinstalling your server into another folder. You can also try entering `force_install_dir ` **before** logging into Steam via `login` command.</note> ``` force_install_dir c:\my_garrysmod_server\ ``` You can then install or update the Garry's Mod Dedicated Server by using the command: ``` app_update 4020 ``` It will slowly download or update. If you wish to verify your server, enter this instead of the above: ``` app_update 4020 validate ``` Once it's done you can type quit at the console to exit or just close the SteamCMD window. ## Automated You probably don't want to do that every time you want to install/update a server. Don't worry - it supports command lines too. ``` steamcmd.exe +login anonymous +force_install_dir c:\my_garrysmod_server\ +app_update 4020 validate +quit ``` ## Running the server After downloading and installing the server files you can now run the dedicated sever. You can either just run `srcds.exe` directly or use its command line interface like so: ``` srcds.exe +maxplayers 20 -console +gamemode sandbox +map gm_construct +sv_setsteamaccount <your token> ``` # After initial installation After installing your server you should set up your GSL Token and the server's location. ### GSLT Please see <page>Steam Game Server Accounts</page> (GSLT) for help with `sv_setsteamaccount`. **This is mandatory.** Your server's ranking will be penalized if you do not do this. ### Server operator rules Please make sure your server conforms to <page>Server Operator Rules</page>. ### Location flag Next you should set your server's location. This is done via the `sv_location` console variable. The convar should directly correspond to a flag icon stored in the `materials/flags16/` folder, without the `.png` extension. The maximum length is currently set to 5 characters. The flag icon filenames follow the `ISO 3166-1 alpha-2` country codes. (http://www.famfamfam.com/lab/icons/flags/) For example `sv_location gb` will display the Great Britain flag, `sv_location us` will display the USA flag, etc. European Union has a special case: `sv_location eu` ### Steam Workshop Optionally you can add `+host_workshop_collection <collectionID>` to your command line to automatically install workshop addons onto your dedicated server. Please see <page>Workshop for Dedicated Servers</page> for help with workshop for dedicated servers. ⤶ ### Setting startup gamemode⤶ ⤶ The active gamemode is set via the `gamemode` <page>ConVar</page>. As a command line parameter it can be applied as such: `+gamemode sandbox`, where `sandbox` is the name of the gamemode folder as it appears in `garrysmod/gamemodes/` or in the `gamemodes/` folder of any addon, including workshop addons. If you do know know the folder name of a workshop addon, it is very likely this information is provided in the addons' description. If not, you can ask the addon author.⤶ ⤶ The active gamemode can be changed at any time with the `gamemode` convar and then changing the map (see below).⤶ ⤶ ### Setting the startup map.⤶ ⤶ Setting startup maps works identically to setting startup gamemode, but using the `map` concommand. As a command line parameter it would look like so: `+map gm_construct`, where `gm_construct` is name of the map file without the `.bsp` extension, inside the `garrysmod/maps/` folder, or inside the `maps/` folder of any addon. Same rule applies to workshop addons - check the addons workshop page description for map file name.⤶ ⤶ To gracefully change the active map to a different map (or to simply reload the map), you can use the `changelevel` command, like so: `changelevel gm_flatgrass`.⤶ ### Peer to Peer Dedicated server can function in peer-to-peer mode. It can be turned on via the `-p2p` command line parameter. On startup the server will tell you how players can connect to such a server manually. # Linux Main article: <page>Linux Dedicated Server Hosting</page> ## Installation Install SteamCMD as per the recommendations from the [Valve Developer Wiki](https://developer.valvesoftware.com/wiki/SteamCMD#Linux). Then install the GMod dedicated server in a similar manner to Windows: ``` steamcmd +login anonymous +force_install_dir ../gmodds +app_update 4020 validate +quit ``` The server is now available in ~/gmodds/. ``` cd ~/gmodds/ ./srcds_run -game garrysmod +maxplayers 32 +map gm_construct ``` ## Troubleshooting If you get the error message ``` ./steamcmd.sh: line 29: /home/$USER/Steam/linux32/steamcmd: No such file or directory ``` You are most likely running 64 a bit system and missing 32 bit libraries. If the output of this command is x86_64, you are running a 64 bit system and need 32 bit libraries. ``` uname -m ``` See this article on the valve wiki. [32-bit libraries on 64-bit Linux systems](https://developer.valvesoftware.com/wiki/SteamCMD#32-bit_libraries_on_64-bit_Linux_systems) # macOS macOS dedicated servers are no longer shipped. # The Experimental Branches To update your server to the development branch, you'll have to launch your SteamCMD and enter these commands **manually**: ``` login anonymous app_update 4020 -beta dev validate quit ``` For the pre-release branch: ``` login anonymous app_update 4020 -beta prerelease validate quit ``` For the x64 branch: ``` login anonymous app_update 4020 -beta x86-64 validate quit ``` To revert back to stable branch: ``` login anonymous app_update 4020 -beta NONE validate quit ``` The development branch is updated regularly.