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:

ServerDL FastDL WorkshopDL
Speed: Slow 64kb/s limit, file by file As fast as the client can download, file by file As fast as the client can download, up to ~2gb (gma) at once
Method: Source networking HTTP Steam workshop
Downside: Extremely slow, you need to enable sv_allowdownload 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. You have to put the content pack on the workshop
Requirements: Requires sv_allowdownload 1 and resource.AddFile Requires a FastDL webserver + resource.AddFile Requires the content to be put on the workshop and added with resource.AddWorkshop

More detailed explanations:

Content serving options

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.

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

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.

WorkshopDL

WorkshopDL effectively downloads straight from the steam workshop. So to use WorkshopDL you need to upload your content to the 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")

Many server owners use workshop lua generators, 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!

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.