GMod : Can't make clients download custom files

Hello everybody.

First of all, as I’m a french student, my Engilsh can be a bit broken. Apologizes if so.

So, I think my problem is already explained in the title of the topic : I’ve tried many ways to make people donwload custom files from the server (like new materials or models from addons I installed), but there’s no way it works.
Here are some infos : I started to config my brand new server this morning, so I installed everything from a clean thing. My sv_downloadurl is well configured as I can download maps, but not the other files. (I also have an other known problem with Lua cache if I remember well).
The last thing I made was to put directly the files from the addons to the folders of the game, and try to force download with resource.AddFile() commands in garrysmod/lua/autorun/server. It seems to download files, as I get a list of about 500 files to download while connecting to the server, but I get ingame when there are about 375 files left to download. Weird…

Here is my forceddownloads.lua :

function AddDir(dir) // Recursively adds everything in a directory to be downloaded by client
	local list = file.FindDir("../"..dir.."/*")
	for _, fdir in pairs(list) do
		if fdir != ".svn" then // Don't spam people with useless .svn folders
	for k,v in pairs(file.Find(dir.."/*", true)) do

function AddDirLua(dir) // Recursively adds everything in a directory to be downloaded by client
	local list = file.FindDir("../"..dir.."/*")
	for _, fdir in pairs(list) do
		if fdir != ".svn" then // Don't spam people with useless .svn folders
	for k,v in pairs(file.Find(dir.."/*", true)) do


So, if you have some solutions to fix this trouble, it would be great :slight_smile:


Bump, hopin’ it’s not against the rules…

I’ve tried things all night long, but I can’t fix this problem ><

(No ad intented) If you want to see what happens while connecting to the serveur, the IP is

Gyoo, you’re doing this all wrong. You are only suppose to make clients download CUSTOM files instead of the whole freaking models folders. And the way you do it doesn’t work.

If you have any custom files, and you want to add them using AddDir, you have to find every folder.

Lua isn’t that easy that it detects everything that is custom in a folder.

This is how you do it:
You are only suppose to add custom files, so if you have any custom files, you have to make clients download them.
So, lets say, you have a custom model installed on your server, and the folder structure is made like this:

Take time reviewing the structure.
As you can see, there is a folder in the "root/materials/custommodel folder.
You may think it is just to add this to the AddDir function: AddDir (“materials/custommodel”) but what you really have to do is to add this:

AddDir ("materials/custommodel/")
AddDir ("materials/custommodel/materials")

AddDir DOES NOT add file in a folder which are in the folder you specified. So if you only write


to the AddDir function it will only take the FILES in that folder and not the files in the folder which is in the folder you specified.

Also, if you add for example this:

AddDir ("models/player")

and you have custom models in there, all files in there will be downloaded which clients do not need. And there’s a whole bunch of DEFAULT models which is in there. So, if you have any CUSTOM models in there, you have to write:

resource.AddFile ("models/player/yourfile.mdl")

Note: You only have to write the .mdl path, since GMod automatically detects the .dx80, dx90, etc.
Although, for materials (.vmt & .vtf) you have to write this:


the vtf file is automatically detected by GMod. Do the above code for EACH .vmt file you find which are CUSTOM and put in there by you.

There’s ALOT of other folders in models/ and materials/ which contains default models and materials.

So, as long as you custom models and materials are in the same folder as defaul models, you HAVE to use resource.AddFile

Thank you for your answer.

I’ll try to make it the way you describe it, and I hope I won’t have to restart from scratch because I fear to have a big mess in the folders with all the files I added ^^’

Therefore, I found some topics on other websites, with people trying to make the client download directly from the addons folder (with AddDir(“addons/etc…”). It sounded weird to me, so I didn’t try this method, but should it work ?

EDIT : I wanted to try something like this :

(not sure for LUA files)
Is it correct ?

New edit : I tried to download two simple files that I put in materials/vgui/entities
Here is the command to force the download :

Still, it doesn’t download anything (I deleted the other forceddownloads.lua with the AddDir function to start with a clean one), even with only two small files… I checked everything : on the server and on the fast download server, the files are well placed.

Lua files should not be downloaded to clients unless it is a REALLY rare moment of Lua code or whatever to call it. So remove all that and never create it again.

Here’s what you should do when creating a script, you HAVE to put it in /lua/autorun/ folder:
Name of Lua File: forcedownloads.lua

resource.AddFile ("materials/vgui/entities/gmod_playx.vmt")
resource.AddFile ("materials/vgui/entities/gmod_playx_repeater.vmt")


Make sure you have the materials in the correct folder.
If you have a FastDL, make sure you have the correct structure.

And for the addons part, you often have a folder in the addon called “lua” where you may have a autorun folder in it. There you place the forcedownload.lua IF the materials you were to add was for that Addon.

But I highly suggest you to skip the Addons part and just copy lua to root/lua, materials to root/materials, etc, since not all Addons are made in “Addons” format and people dont seem to tell if they are or not. If the readme.txt file says “Copy files to steam/steamapps/USERNAME/garrysmod/garrysmod/addons” it is CLIENT-SIDE addon format. Servers are not suppose to have it as addon format then. CSS Realistic weapons is in addons format though…

EDIT: I sugget you to visit this site and review what folders you should add:

EDIT2: If you want to, you can add me on steam, just search for Svenskunganka (I’m sure I will be the only one).

I don’t get it… you add in the lua file the path of this same lua file ? I’ll try now but it’s a bit strange to me. (Moreover, I have already installed TF2 servers but in fact GMod is way more complicated x) )

I have already seen the link you gave me, but I thank you though :slight_smile:
And I’ll search you on steam. Mine is hucastgyoung.

EDIT : I copied the code you gave for a first fast try, but it doesn’t change anything unfortunately.

If you have the PlayX folder in the Addons folder, you are suppose to move the forcedownloads.lua file to: root/addons/playx/lua/autorun/ folder.

But if you’ve moved the materials, lua, etc folder out of PlayX folder and move them to root/materials, root/lua you have to move the forcedownloads.lua to root/lua/autorun/

And I dont really know why I use the command AddCSLuaFile(“filename.lua”) in the script but there was one time it didn’t work for me and then I added that and it started working again.

Thank you (again and again x) ) for the help you gave me through steam :slight_smile:

No problemow :slight_smile: