Garry's Mod Wiki

Serving Content

Serving content to players

For a player to be able to see custom content on a server they need to have the content downloaded. You can send your server content in various different ways to them, below are some different ways to achieve this.

.lua files are NOT considered content, they are downloaded through separate processes and require no additional setup.

Keep in mind that clients can change which types of files they download by going into the settings menu.

image.png

A simple oversight of the different methods, ordered by speed:

WorkshopDL FastDL ServerDL
Speed: As fast as the client can download, up to ~2gb (gma) at once As fast as the client can download, file by file Slow 64kb/s limit, file by file
Method: Steam workshop HTTP Source networking
Downside: You have to upload a content pack to Steam Workshop Can be slow for lots of smaller files as it downloads one by one for each file. Files aren't checked for their contents so updating files on the server wont make the client redownload updated files. Extremely slow, you need to enable sv_allowdownload
Requirements: Requires the content to be put on the workshop and added with resource.AddWorkshop Requires a FastDL webserver + resource.AddFile Requires sv_allowdownload 1 and resource.AddFile

More detailed explanations:

Content serving options

WorkshopDL

WorkshopDL effectively downloads straight from the steam workshop. So to use this you need to upload your content to Steam Workshop. Make sure when you upload that you mark your addons type as ServerContent to prevent unnecessary clutter on the workshop. Once you've done this you can now use the lua function resource.AddWorkshop.

Example:

You have the following addon in your collection and mounted to your server but clients see them as errors: https://steamcommunity.com/sharedfiles/filedetails/?id=150455514 To add it you can add a serverside only lua file that marks this workshop addon to be downloaded for clients. Example folder structure garrysmod/lua/autorun/server/workshop.lua or as legacy addon garrysmod/addons/workshop/lua/autorun/server/workshop.lua In this file you can put resource.AddWorkshop("150455514")

FastDL

For FastDL you need a separate webserver for players to download from and you need to set sv_downloadurl to the url of your website. Files can be marked for downloading with resource.AddFile and resource.AddSingleFile after that the client will automatically try to request the marked files from the webserver. Clients will first try to request a compressed version .bz2 version of the file and if that doesn't exist they will try the regular file, an example of this behavior can be seen below.

Example:

sv_downloadurl is set to https://mycoolwebsite.com and you've marked materials/hud/killicon.vmt for download. The client will first run a request to https://mycoolwebsite.com/materials/hud/killicon.vmt.bz2 and then https://mycoolwebsite.com/materials/hud/killicon.vmt.

Many server owners use workshop lua generator websites, these are NOT efficient as they will also mark addons with only lua to be downloaded thus increasing join times. Only mark addons that have files that aren't lua for download!

ServerDL

Using ServerDL is rather simple, you need to have sv_allowdownload enabled and you need to mark the files that you want to be downloadable with resource.AddFile and resource.AddSingleFile after that clients will automatically download the content when they join your server. However this is considered obsolete as its incredibly slow at 64kb/s and you should avoid using it.

Having sv_allowdownload enabled opens you up to exploits. Players with modified clients can spam request files to severely lag your server.

Alternatives

Some servers download content on the fly, this can be done through various methods but the most common are:

These methods wont work for everything, for example this will never work for a map. Some addons that precache or store Materials on autorun might also have issues with this.