Forcing Clients to download different files

Is there any way, or lua file where i can input the path to files i WANT to force people to download before joining the server, or do i just put them all in addons, and hope for the best?

i also need this, I tried the resource force download, and placed it in lua/autorun/server/ Yet nothing happens.

Maps download, lua files download, but materials and models don’t want to download to connecting clients.

Ive search for a solution for this problem but all threads either end with no fix or go off topic. Any help would be awesome…

Use this script. Open the script in notepad and set the directory of force download to clients. ** Read the instructions in the lua file, so you dont screw it up!!!**

Thankyou very much!

Well, atleast someone is putting my script to good use.

No Problem!

Lol sorry for being a noob, but what am i doing wrong here.

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
AddDir(fdir)
end
end

for k,v in pairs(file.Find("…/"…dir…"/*")) do
resource.AddFile("…/"…dir…"/"…v)
end
end

AddDir(“models/”)

resource.AddFile(“models/weapons/w_fists_t.mdl”)
resource.AddFile(“models/weapons/w_fists_t.vvd”)
resource.AddFile(“models/weapons/w_fists_t.phy”)
resource.AddFile(“models/weapons/w_fists_t.sw.vtx”)
resource.AddFile(“models/weapons/w_fists_t.dx90.vtx”)
resource.AddFile(“models/weapons/w_fists_t.dx80.vtx”)
resource.AddFile(“models/weapons/v_punch.mdl”)
resource.AddFile(“models/weapons/v_punch.vvd”)
resource.AddFile(“models/weapons/v_punch.sw.vtx”)
resource.AddFile(“models/weapons/v_punch.dx90.vtx”)
resource.AddFile(“models/weapons/v_punch.dx80.vtx”)

Same here, i’m still not getting the models, sounds, or materials to load.

// where it says AddDir("") Where the “” is put your file dir…eg: AddDir(“sound\music”)
// resource.addfile is used to download seperate files FROM your dir you have chosen.
// Eg: resource.AddFile(“Models\materials\som.vmt”)

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
AddDir(fdir)
end
end

for k,v in pairs(file.Find("../"..dir.."/*")) do
	resource.AddFile(dir.."/"..v)
end

end

AddDir(“materials”)
AddDir(“sound”)
AddDir(“models”)

resource.AddFile(“Materials\models\oggmic\fx2ogg.vmt”)
resource.AddFile(“Materials\models\oggmic\fx2ogg.vtf”)
resource.AddFile(“Materials\models\oggmic\fxogg.vmt”)
resource.AddFile(“Materials\models\oggmic\fxogg.vtf”)
resource.AddFile(“Materials\models\oggmic\masogg.vmt”)
resource.AddFile(“Materials\models\oggmic\masogg.vtf”)
resource.AddFile(“Materials\models\oggmic\masogg_f.vtf”)
resource.AddFile(“Materials\models\oggmic\masogg_n.vtf”)
resource.AddFile(“Materials\models\oggmil\fx2ogg.vmt”)
resource.AddFile(“Materials\models\oggmil\fx2ogg.vtf”)
resource.AddFile(“Materials\models\oggmil\fxogg.vmt”)
resource.AddFile(“Materials\models\oggmil\fxogg.vtf”)
resource.AddFile(“Materials\models\oggmil\masogg.vmt”)
resource.AddFile(“Materials\models\oggmil\masogg_f.vtf”)
resource.AddFile(“Materials\models\oggmil\masogg.vtf”)
resource.AddFile(“Materials\models\oggmil\masogg_n.vtf”)
resource.AddFile(“Materials\models\oggmip\fx2ogg.vmt”)
resource.AddFile(“Materials\models\oggmip\fx2ogg.vtf”)
resource.AddFile(“Materials\models\oggmip\fxogg.vmt”)
resource.AddFile(“Materials\models\oggmip\fxogg.vtf”)
resource.AddFile(“Materials\models\oggmip\masogg.vmt”)
resource.AddFile(“Materials\models\oggmip\masogg.vtf”)
resource.AddFile(“Materials\models\oggmip\massog_f.vtf”)
resource.AddFile(“Materials\models\oggmip\masogg_n.vtf”)
resource.AddFile(“Materials\models\oggmix\fx2ogg.vmt”)
resource.AddFile(“Materials\models\oggmix\fx2ogg.vtf”)
resource.AddFile(“Materials\models\oggmix\fxogg.vmt”)
resource.AddFile(“Materials\models\oggmix\fxogg.vtf”)
resource.AddFile(“Materials\models\oggmix\masogg.vmt”)
resource.AddFile(“Materials\models\oggmix\masogg.vtf”)
resource.AddFile(“Materials\models\oggmix\masogg_f.vtf”)
resource.AddFile(“Materials\models\oggmix\masogg_n.vtf”)
resource.AddFile(“Materials\VGUI\entities\lightsaber.vmt”)
resource.AddFile(“Materials\VGUI\entities\lightsaber.vtf”)
resource.AddFile(“Materials\weapons\lightsaber.vmt”)
resource.AddFile(“Materials\weapons\lightsaber.vtf”)
resource.AddFile(“Materials\weapons\lightsaber_killicon.vmt”)
resource.AddFile(“Materials\weapons\lightsaber_killicon.vtf”)
resource.AddFile(“Models\weapons\v_drowbar.dx80.vtx”)
resource.AddFile(“Models\weapons\v_drowbar.dx90.vtx”)
resource.AddFile(“Models\weapons\v_drowbar.mdl”)
resource.AddFile("Models\weapons\v_drowbar.sw.vtx)
resource.AddFile(“Models\weapons\v_drowbar.vvd”)
resource.AddFile(“sound\phantom\force\heal”)
resource.AddFile(“sound\phantom\force\jump”)
resource.AddFile(“sound\phantom\force\pull”)
resource.AddFile(“sound\phantom\force\push”)
resource.AddFile(“sound\phantom\force\see”)
resource.AddFile(“sound\phantom\force\speed”)
resource.AddFile(“sound\phantom\sword\saberhup1”)
resource.AddFile(“sound\phantom\sword\saberhup2”)
resource.AddFile(“sound\phantom\sword\saberhup3”)
resource.AddFile(“sound\phantom\sword\saberhup4”)
resource.AddFile(“sound\phantom\sword\saberhup5”)
resource.AddFile(“sound\phantom\sword\saberoff”)
resource.AddFile(“sound\phantom\sword\saberon”)

Glad to see I’m not the only one with this problem.

in my gamemodes/gamemode/gamemode/init.lua
i have a list like this.


resource.AddFile("materials/gjail/halt.vtf");
resource.AddFile("materials/gjail/halt.vmt");

resource.AddFile("materials/gjail/GuardChar.vtf");
resource.AddFile("materials/gjail/GuardChar.vmt");
resource.AddFile("materials/gjail/PrisonerChar.vtf");
resource.AddFile("materials/gjail/PrisonerChar.vmt");
resource.AddFile("materials/gjail/NoGuardChar.vtf");
resource.AddFile("materials/gjail/NoGuardChar.vmt");

resource.AddFile("models/weapons/w_fists.dx80.vtx");
resource.AddFile("models/weapons/w_fists.dx90.vtx");
resource.AddFile("models/weapons/w_fists.mdl");
resource.AddFile("models/weapons/w_fists.phy");
resource.AddFile("models/weapons/w_fists.sw.vtx");
resource.AddFile("models/weapons/w_fists.vvd");
resource.AddFile("models/weapons/v_fists.dx80.vtx");
resource.AddFile("models/weapons/v_fists.dx90.vtx");
resource.AddFile("models/weapons/v_fists.mdl");
resource.AddFile("models/weapons/v_fists.sw.vtx");
resource.AddFile("models/weapons/v_fists.vvd");

*then a few lines under it is this*

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
			AddDir(fdir)
		end
	end
 
	for k,v in pairs(file.Find("../"..dir.."/*")) do
		resource.AddFile(dir.."/"..v)
	end
end


but the materials only get sent, not the models.

I don’t think we’re ever going to get a solution to this.

Well heres what i did to fix this stupid issue, i backed up my gamemode, along with a few other important folder.

Reinstalled the server and uploaded the backup, and now everything works once again, i suggest you give that a try too.

I think the server was just pmsing cause it was hack not to long ago.

I’m not trying to transfer models from the gamemode itself. The files listed above are what i use to test if it’s working, a lightsaber. It doesn’t make sense because the models and what not send if they’re attached to a gamemode like “GMStranded and The Middle Ages” but if it’s in addon format they won’t work either. The gamemodes do have a file similar to this one released in here within the files so i’m not sure what the deal is.

No, that’s not it. The problem was, that you added the Resource in init.lua, which is completely wrong.
The Resource has nothing to do with the actual gamemode, meaning, It should just be in lua; this is the correct code for you:

[lua]resource.AddFile(“materials/gjail/halt.vtf”)
resource.AddFile(“materials/gjail/halt.vmt”)

resource.AddFile(“materials/gjail/GuardChar.vtf”)
resource.AddFile(“materials/gjail/GuardChar.vmt”)
resource.AddFile(“materials/gjail/PrisonerChar.vtf”)
resource.AddFile(“materials/gjail/PrisonerChar.vmt”)
resource.AddFile(“materials/gjail/NoGuardChar.vtf”)
resource.AddFile(“materials/gjail/NoGuardChar.vmt”)

resource.AddFile(“models/weapons/w_fists.dx80.vtx”)
resource.AddFile(“models/weapons/w_fists.dx90.vtx”)
resource.AddFile(“models/weapons/w_fists.mdl”)
resource.AddFile(“models/weapons/w_fists.phy”)
resource.AddFile(“models/weapons/w_fists.sw.vtx”)
resource.AddFile(“models/weapons/w_fists.vvd”)
resource.AddFile(“models/weapons/v_fists.dx80.vtx”)
resource.AddFile(“models/weapons/v_fists.dx90.vtx”)
resource.AddFile(“models/weapons/v_fists.mdl”)
resource.AddFile(“models/weapons/v_fists.sw.vtx”)
resource.AddFile(“models/weapons/v_fists.vvd”)[/lua]

and is should be placed HERE: garrysmod/LUA/AUTORUN/SERVER/Resources.lua

P.S, I left out the Add.Dir, cause i dont know anything about that. I once ran a DarkRP server, and I just used this, and it worked like a charm - so, you dont need “add.dir”. I hope this helps you both, and all others, who are experiencing this.

It works on sending the files but it doesn’t actually download them. Here’s a screenshot. Also, a bar goes all the way to the end instantly but it doesn’t do anything…then it gets stuck like this.

and here’s my list

resource.AddFile(“gamemodes/sandbox/content/models/weapons/v_knife_t.dx90.vtx”)
resource.AddFile(“gamemodes/sandbox/content/models/weapons/v_knife_t.mdl”)
resource.AddFile(“gamemodes/sandbox/content/models/weapons/v_knife_t.sw.vtx”)
resource.AddFile(“gamemodes/sandbox/content/models/weapons/v_knife_t.vvd”)
resource.AddFile(“gamemodes/sandbox/content/models/weapons/v_knife_t.xbox.vtx”)
resource.AddFile(“gamemodes/sandbox/content/models/weapons/w_knife_t.dx80.vtx”)
resource.AddFile(“gamemodes/sandbox/content/models/weapons/w_knife_t.dx90.vtx”)
resource.AddFile(“gamemodes/sandbox/content/models/weapons/w_knife_t.mdl”)
resource.AddFile(“gamemodes/sandbox/content/models/weapons/w_knife_t.phy”)
resource.AddFile(“gamemodes/sandbox/content/models/weapons/w_knife_t.sw.vtx”)
resource.AddFile(“gamemodes/sandbox/content/models/weapons/w_knife_t.vvd”)
resource.AddFile(“gamemodes/sandbox/content/models/weapons/w_knife_t.xbox.vtx”)
resource.AddFile(“gamemodes/sandbox/content/materials/models/weapons/v_models/wii/abutton.vmt”)
resource.AddFile(“gamemodes/sandbox/content/materials/models/weapons/v_models/wii/abutton.vtf”)
resource.AddFile(“gamemodes/sandbox/content/materials/models/weapons/v_models/wii/lens_trans.vtf”)
resource.AddFile(“gamemodes/sandbox/content/materials/models/weapons/v_models/wii/wii.vmt”)
resource.AddFile(“gamemodes/sandbox/content/materials/models/weapons/v_models/wii/wii.vtf”)
resource.AddFile(“gamemodes/sandbox/content/materials/models/weapons/v_models/wii/wii1_normal.vtf”)
resource.AddFile(“gamemodes/sandbox/content/materials/models/weapons/v_models/wii/wii2_normal.vtf”)
resource.AddFile(“gamemodes/sandbox/content/materials/models/weapons/v_models/wii/wii_ref.vtf”)
resource.AddFile(“gamemodes/sandbox/content/materials/models/weapons/v_models/wii/wiibuttons.vmt”)
resource.AddFile(“gamemodes/sandbox/content/materials/models/weapons/v_models/wii/wiibuttons.vtf”)
resource.AddFile(“gamemodes/sandbox/content/materials/models/weapons/v_models/wii/wiibuttons_ref.vtf”)
resource.AddFile(“gamemodes/sandbox/content/materials/models/weapons/w_models/wii/eyebrow.vmt”)
resource.AddFile(“gamemodes/sandbox/content/materials/models/weapons/w_models/wii/eyebrow.vtf”)
resource.AddFile(“gamemodes/sandbox/content/materials/models/weapons/w_models/wii/torso.vmt”)
resource.AddFile(“gamemodes/sandbox/content/materials/models/weapons/w_models/wii/torso.vtf”)
resource.AddFile(“gamemodes/sandbox/content/materials/models/weapons/w_models/wii/v_hand_sheet.vmt”)
resource.AddFile(“gamemodes/sandbox/content/materials/models/weapons/w_models/wii/v_hand_sheet.vtf”)
resource.AddFile(“gamemodes/sandbox/content/materials/models/weapons/w_models/wii/v_hand_sheet_normal.vtf”)
resource.AddFile(“gamemodes/sandbox/content/materials/models/weapons/w_models/wii/wii.vmt”)
resource.AddFile(“gamemodes/sandbox/content/materials/models/weapons/w_models/wii/wii.vtf”)
resource.AddFile(“gamemodes/sandbox/content/materials/models/weapons/w_models/wii/wiibuttons.vmt”)
resource.AddFile(“gamemodes/sandbox/content/materials/models/weapons/w_models/wii/wiibuttons.vtf”)

Do you want your files to only be loaded when sandbox is on?

If not or if its what your always on, take them out of the sanbox folder and rename the directories.

Well I could try taking them out of the gamemodes folder and putting them in the actual materials and models folder is what you’re suggesting? Either way i thought it would work but i’ll try this.

EDIT: I can officially say that i love you? I’ve been at this for many weeks and it finally works. Thanks to everyone that helped.