Autodownload?

Is it possible to make clients that join my server download everything in my models/materials/sounds/maps and lua folder automaticly? I can’t exactly use resource.AddFile("") because there is 1000’s of files.

I’m sure there will be a way, i just need to know how.

Thanks for reading.


local ClientResources = 0;
local function ProcessFolder ( Location )
	for k, v in pairs(file.Find(Location .. '*')) do
		if file.IsDir(Location .. v) then
			ProcessFolder(Location .. v .. '/')
		else
			local OurLocation = string.gsub(Location .. v, '../gamemodes/PERP2.5/content/', '')
			
			if string.sub(Location, -2) != 'db' then			
				ClientResources = ClientResources + 1;
				resource.AddFile(OurLocation);
			end
		end
	end
end

if isDedicatedServer() then
	ProcessFolder('../gamemodes/PERP2.5/content/models/');
	ProcessFolder('../gamemodes/PERP2.5/content/materials/');
	ProcessFolder('../gamemodes/PERP2.5/content/sound/');
	ProcessFolder('../gamemodes/PERP2.5/content/resource/');
	ProcessFolder('../gamemodes/PERP2.5/content/particles/');
	ProcessFolder('../gamemodes/PERP2.5/content/maps/');
end

Msg("Sent " .. ClientResources .. " client resources.
");

Snippet from PERP’s method.

What do I have to do with that? What do i change, etc.

Bump…