Setting up sv_downloadurl
From GMod Wiki
| Go to:|
What exactly is Fast Download or sv_downloadurl?
Fast Download (also know as sv_downloadurl) is a practice used to get content from the server to the client faster. By default the download limit is capped in Garrysmod at 20kb/s. So to get content to clients faster, we use Fast Download which allows the client to download at standard http speeds.
Fast Download has some basic requirements. If you have a dedicated game server, you will most likely have the resources to make a fast download server.
Webspace is required for a place to store the files so the client can download them. It is suggested that you have at least 1GB of space on the server, and at least 20GB of Bandwidth for a small server.
To find a webhost use www.google.com or a similar search engine.
Setup and Configuration
Setting up the initial configuration for Fastdownload is easy enough. In your garrysmod/cfg folder, you'll have a file called server.cfg. In that, add the following lines below:
- sv_downloadurl "http://www.mysvdownloadurl.com/garrysmod/"
- sv_allowupload "0"
- sv_allowdownload "0"
And there you have it. The first part of Fast Download has been set up. It's now on to configuring the Webspace and preparing it to be used.
So how does Fast Download work exactly?
Fast Download works by mirroring your "garrysmod/" folder. However, it can only mirror certain folders for it to function. These are:
- cache This is the most important one, explanation below
Note: the names of both the files and folders are case sensitive
Content that is automatically downloaded
There is some content which source will automatically attempt to send to the client. These are:
- The Cache (Clientside Lua Files)
Content that must be manually added
Often there is content that a server owner will want clients to have however source does not automatically force these to be downloaded. Using resource.AddFile this can be forced and the files sent. The following content will not automatically be sent:
- Resources (e.g. fonts etc)
What exactly is needed for a server to function with sv_downloadurl?
Found under garrysmod/cache/ the cache file contains 'all clientside data that the client has to know. This file(s) is autogenerated by your server each time it starts.
It is important that the cache file is on the Fast Download server for without it the client will not see the gamemode correctly and will be given a warning about the server cache being misconfigured.
Maps will automatically be downloaded from the server if the file is placed on the Web Server. The advantage of this is that instead of downloading the map at 20kb/s, the client will download it at their average internet speed. There are even tricks to help them download faster, however that will be discussed further on.
If you are using sv_downloadurl, you must upload the maps to the server otherwise clients will be unable to play on the server unless they already own the map.
For some, this can be slightly complex to understand. The Addons folder is "emulated" if you like in game to be the garrysmod folder, which is how the content is used and sent. So to use the models / materials / sounds, you must extract them from the /addons folder, and into the correct folders on the webserver. You can keep the addon normally on the game server, but on the webserver the extraction must occur.
Look below for an example.
- addons/myaddon/materials/mymaterial.vtf => materials/mymaterial.vtf on the webserver
- addons/myaddon/models/mymodel.mdl => models/mymodel.mdl on the webserver
- addons/myaddon/sound/policesounds/police1.wav => sound/policesounds/police1.wav
Hopefully from the above examples you get the idea.
You do not actually need to upload any gamemode files whatsoever to Fast Download. However, if you wish to use custom content in your Gamemode, you can under your gamemodes directory add a content folder, and then replicate materials / models under that. For example:
Content works similar to that of the addon format. If you can understand one, you can understand the other.
And you're done!
That is the general usage of Fast Download covered. However, below is some help, along with some tricks you can use to help your server and your players in the long run.
SourceRSC can update your fast download server automatically. If custom content is missing from the fast download server it will bzip the files, create the appropriate folder structure, and properly 'virtualize' the addons and gamemodes folders on the fast download server. Supports accessing the game and fastdownload server locally or with FTP. Works on Windows and Linux.
Bzip2 File Compression
Bzip2 is a program which can be used to significantly reduce the size of the files on the Fast Download server. Source natively supports Bzip2, so it's known that this will work. Bzip2 can reduce a file's size by up to 75%. This means a 50mb file can be 15mb or less, allowing players to download it faster. This also means if you have bandwidth limits, you'll save bandwidth with smaller files. Every single file that can be used by Fast Download can be Bzipped. However, the files on the Game Server must be the original files. Only the Web Server needs the bzipped files The normal files do not need to be on the web server if you use Bzip2.
Once the files have been uploaded to the Fast Download server (and put in the appropriate places), that's your work done. Source automates the rest, when the client downloads the file, they'll be automatically unzipped and cached etc.
You can either get Bzip2 and use the command line, or use 7Zip which has support for zipping into Bzip2 format.
Note: As of Gmod update 81, the cache is now one file ranging between 100 - 275kb. This means zipping the cache could be useless and actually increase the size of the file.
I see red error models / purple and black textures!
This means you haven't placed or added the files correctly on the Fast Download Server
People have to download files every time they join!
This means you forgot something on the FastDL folder. It's trying to download it every time they join. It also tells you what you have to move there. If you have the files already, you will not need to re-download them.
There could also be an issue regarding the files name. Case sensitivity matters with sv_downloadurl, so ensure that the filepath and filename are exactly the same on both the webserver and gameserver.
Fast Download is certainly worth the time and money to set up. Your players get their models and whatnot faster and you get a slight peace of mind knowing that your server is that bit more secure and safer.