Grry‘s Mod and content download
Hello,
I‘m have a little issue. I still don‘t understand how to implement content downloading. So I would be glad if someone can clarify it to me
- When you just add +host_workshop_collection in your start.sh this means only the server has it installed then if nobody subscribes to the collection right?
- And with resource.addWorkshop the client downloads the specific workshop adding on join?
- resource.AddFile or resource.addSingleFile are just to tell the client to download a specific file which is in a addon for example and isn‘t a lua file? This can be used without a FastDL server?
- And AddCSLuaFile is basically the same as resource.AddFile but only for clientside lua files
- And what about shared files, what function do you use to tell the client to download this file?
- A question to resource.AddWorkshop: In the wiki it says gamemodes that are workshop enabled are automatically added to this list? Does this mean the gamesome already somewhere used resource.addWorkshop in itself and this should be also true to other addon right?
- And again something to resource.addWorkshop: it also says the server#s current map is automatically added if it‘s from a workshop addon? What does this exactly mean. I normallly extract the .gma file and use upload the .bsp to my dedicated server in garrysmods/maps. Is there something wrong with it
I‘m really thankfulll for any kind of help! These questions steal my sleep.
From my understanding (please correct me if I'm wrong):
- The collection (+host_workshop_collection) just makes the server download all the addons, so they are available to play.
- Using resource.addWorkshop, you can tell the client to also download a specific addon. You only need that for maps, models, textures, etc. otherwise clients will get errors (missing textures/models) since the server can't send them the maps and models (files too large)
- Lua scripts are automatically being send from server to client, therefore you don't need clients to download pure lua addons.
- Workshop enabled gamemodes just means that clients automatically subscribe to the gamemode itself on the workshop (so if you play darkrp on a server once, you can also play it in singleplayer since you automatically subscribed to it) [Not 100% sure tho]
- Files in Lua/Autorun [and /server + /client] are automatically downloaded by the clients [from the server]
- Using AddCSLuaFile() (and I think include() too) you can tell the client to download specific other scripts too (that aren't in lua/autorun)
Momox pretty much clarified all of the specific questions you had.
You essentially have three routes of delivering content to the players/clients, with a mix of a couple being possible.
Method 1: FastDL
- A "FastDL" is where the client is able to download, at much faster (HTTP) speeds than direct, from a webserver or a CDN.
- This method allows for compression to be used, meaning the download will be even faster. All files on the webserver should be compressed as .bz2 files. Do not include the .bz2 in the
resource.AddFile(). - This can be used in combination with workshop downloads.
- This cannot be used in combination with direct server downloads (it replaces direct server downloads with a faster and external webserver HTTP download method).
Setting this up:
- You must have a webserver or a CDN. A CDN (content-delivery-network) is the best option for this as it localizes to the user's location but it's not required and usually only larger server networks use these.
- Out of each of the addons that require content from your server (view your addons folder and any workshop addons you will need to extract), copy the content in their corresponding content folders.
- Content that requires downloading to players includes things under:
/maps/materials/models/particles/resource/sound- And any other content folder that can be in your garrysmod game directory.
- Lua files are automatically sent to the client you do not need to add these. Also ignore text files or info files in the root directories of addons.
- Compress each of them as .bz2 files. There are tools that can do this recursively for you. Upload this to the server.
- In your server.cfg file:
- set
sv_downloadurlto your webserver URL with that filestructure - Set
sv_allowdownloadto "0" - Create a new file under
/garrysmod/lua/autorun/server/sv_resources.lua - For each file in the FastDL, add a line that is
resource.AddFile("path/to/file.extension") - There are tools that can automatically generate this for you.
- This is relative to the addon directory, for example:
resource.AddFile("models/my_model/model.mdl") - Again, do not include the compressed .bz2 extension in this, only the actual file extension.
Method 2: Direct Download (Not really recommended)
- By default Garry's Mod can directly download from the server. This takes server bandwidth and is far slower than any other method. Generally this is not recommended.
- This can be used in combination with workshop downloads.
- This cannot be used in combination with a FastDL (it is a slower, more server-bandwidth-heavy method of downloading the content to the players).
Setting this up:
- In your server.cfg file:
- Set
sv_allowdownloadto "1" - Create a new file under
/garrysmod/lua/autorun/server/sv_resources.lua - For each content file, add a line that is
resource.AddFile("path/to/file.extension") - There are tools that can automatically generate this for you.
- This is relative to the addon directory, for example:
resource.AddFile("models/my_model/model.mdl")
Method 3: Workshop
- You can have users directly download and mount from the Garry's Mod Steam Workshop.
- This method is recommended if the majority of your server content is available on the workshop and/or you have an in-game downloader tool.
- This can be used in combination with either a FastDL or direct server downloads (one or the other).
Setting this up:
- Create a new file under
/garrysmod/lua/autorun/server/sv_resources.lua - For each workshop addon you use, add a line that is
resource.AddWorkshop("workshopID") - The workshop ID can be found at the end of the URL after clicking on that particular workshop addon:

- So in this example, the line to add would be:
resource.AddWorkshop("1953525147") - [If you are not also using direct downloads for other things] In your server.cfg file:
- Set
sv_allowdownloadto "0"
Examples of tools mentioned:
I haven't personally tested any of these.
- https://github.com/Braden1996/garrysmod-fastdl-generator
- Generates both the compressed files and a list of the
resource.AddFilelines by scanning your addons directory. - [Linux] https://github.com/Maxximou5/compressor
- Recursively compresses files to .bz2 files. Do not run this directly in your addons folder.
- https://github.com/maissani/gmad-auto-fastdl
- Generates both the compressed files and a list of the
resource.AddFilelines by scanning your addons directory. - There are many other automated tools and scripts out there that can help you in doing any of the tedious tasks of setting up content downloads.
Which method you use is up to you and the resources and time you have available. Setting up faster download methods have a better long term effect as players will be able to download faster and therefore connect faster. However, each has its downturns - with FastDL being region based unless it's a CDN and using bandwidth while requiring a webserver and storage. Often times a workshop download might be easiest to setup, unless a lot of your content is not on the workshop.
Also keep in mind in-game downloaders, such as https://www.gmodstore.com/market/view/leyworkshopdls-faster-joining-ingame-in-game-downloads, which will download and mount content while in-game. These are helpful for content that isn't immediately important or crucial to the player's experience.
Hopefully that clarifies some things for you and helps you get a basic understanding of dedicated server content delivery to players :-)
IIRC correctly, FastDL isn't really faster than Workshop DL, since it only sends one file at a time, while workshop DL sends multiple ones.
Not to forget that FastDL is really old (older than Gmod itself).
Read that on the gmod forums, can't find the thread tho. Sorry.
So it's probably good for sending few, bigger files (Maybe maps) but not that great for a lot of textures, models and scripts.
WSDL should also be good for maps because the client will download the current map if the server has it from workshop
You can just implement a simple check with game.getMap as well.
but why creating an extra lua file just for that if you can simply load your maps from workshop ^^ (i would give you a Agree and a Disagree at the same time so i give you an "Creative" rate ^^ )