Force Download

Hello, i’m running a listen server, and there’s a few models, textures and sounds needing to be downloaded that aren’t being. I heard i needed to use a lua code. It’s currently in garrysmod/garrysmod/lua/autorun/server/forcedl/forcedl.lua
I used


resource.AddFile("file path here")

to link to the files, so my code looks a little something like this.


resource.AddFile("models/Doctor_Who/tardis/tardis.mdl")

There’s some other lines linking to different files, the full path of the example file is garrysmod/garrysmod/addons/doctorwho/modelse/Doctor_Who/tardis/tardis.mdl
Do i need to add anything at the beginning or end of the code, rename anything, move anything or change the path? Please help, i would be very grateful.

I don’t think the code is even being run, take forcedl.lua out of lua/autorun/server/forcedl and place it directly into lua/autorun/server

Tried that, but they still don’t have to download them, however, now when they connect, it apparantly disconnects them for reason “.” which is kinda weird.

Any advice?

What a nice disconnecting reason. Wow.

Not my fault, my guess is the script is doing it because they dont have the files.

Can anyone help?

Have you looked in the console right after your listen server starts up? Mabye there is an error with the path of the file you are trying to force download. A resource error starts with something like [resource.AddFile].

Also, if you have tried putting the lua file into lua/autorun/server/forcedl.lua, try adding the lua file and model as an addon. A bit more work, but it should work.

EDIT:
I’ve noticed the path to your model:

Is that exactly how the addon’s model folder is printed? If so, you’ll have to change it to models and not modelse

Well if it works the same as a dedicated server then the name of the file has to be resources.lua. And make sure that it is lua and its not named as resources.lua.txt. And yes, it has to be in lua/autorun/server

I’m not sure if it’s possible to use resource.AddFile from within addons. I’ve never seen it done.

Anything run before the gamemode initializes can use resource.AddFile. That being said, addons are no different.

If he’s trying to add the files from addons, then the appropriate thing to do would be


resource.AddFile("addons/doctorwho/models/Doctor_Who/tardis/tardis.mdl")

Wouldn’t it?

Last time I checked, resource.AddFile works from your steamapps/<steam name>/garrysmod/garrysmod/ folder. If that doesn’t work, move each of the files needed into their respective folders (models/materials) and add them from there.

Thanks for trying to help, but i typed that on another computer, not copypasted it, the filepaths are fine.

Will try that, but i made the file with SCITE, so it should be a lua, plus it seems to be doing something as it disconnected the guy.

Hm, will try that later as well, it was addons/doctorwho before when it was in the wrong file but i changed it and haven’t changed it back since.

I’ll try all these things in a few hours, thanks to everyone for helping.

Right, the file is located in garrysmod/garrysmod/lua/autorun/server and is called resources.lua. These are the exact contents, copypasted.


# resource.AddFile("addons/doctorwho/Models/Doctor_Who/Tardis/Tardis_Closed.dx80.vtx")
# resource.AddFile("addons/doctorwho/Models/Doctor_Who/Tardis/Tardis_Closed.dx90.vtx")
# resource.AddFile("addons/doctorwho/Models/Doctor_Who/Tardis/tardis_closed.mdl")
# resource.AddFile("addons/doctorwho/Models/Doctor_Who/Tardis/Tardis_Closed.phy")
# resource.AddFile("addons/doctorwho/Models/Doctor_Who/Tardis/Tardis_Closed.sw.vtx")
# resource.AddFile("addons/doctorwho/Models/Doctor_Who/Tardis/tardis_closed.vvd")
# resource.AddFile("addons/doctorwho/Models/Doctor_Who/Tardis/Tardis_Closed.xbox.vtx")
# resource.AddFile("addons/doctorwho/Materials/Doctor_Who/Tardis/Tardis.vmt")
# resource.AddFile("addons/doctorwho/Materials/Doctor_Who/Tardis/Tardis.vtf")
# resource.AddFile("addons/doctorwho/Materials/Doctor_Who/normals/Tardis/Tardis_NRM.vtf")


Can anyone see what’s wrong with it?

Yes remove the, # and addons/doctorwho/

I removed the #, but not the addons/doctorwho, and supposedly, it had to download for them. But now when i spawn the prop, it shows as an error to them! (from the two who have tested it for me)

Any ideas?

Remove the ‘addons/doctorwho/’.

Remove the ‘addons/doctorwho/’ – with the /

Since content from addons/ are mounted when the game starts, they’ll have to restart GMod before they can see the models.

There is no workaround. You have to move the content and remove “addons/doctorwho/” from the target file name.

I removed addons/doctorwho and it works! Thanks guys!

Np :slight_smile:

Btw, i didn’t need to move the content. By simply removing the addons/doctorwho, it works without client restart.