Forceddownloads skipping some files :S (DARKRP)

My forceddownloads.lua is skipping some files. I wanted to add a car to my DARKRP server. Here’s the forceddownloads…


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(dir.."/"..fdir)
		end
	end
 
	for k,v in pairs(file.Find(dir.."/*", true)) do
		resource.AddFile(dir.."/"..v)
	end
end
 
AddDir("lua/weapons/gmod_tool") 
AddDir("lua/entities/gmod_adv_dupe_paster")
AddDir("lua/effects/PasteBeam")
AddDir("lua/autorun")
AddDir("lua/weapons/gmod_tool/stools/door.lua")
AddDir(lua/weapons/gmod_tool/stools/ol_stacker.lua")
AddDir("lua/weapons/gmod_tool/stools/fadingdoor.lua")
AddDir("lua/weapons/gmod_tool/stools/keypad.lua")
AddDir("lua/weapons/gmod_tool/stools/keypad_adv.lua")
AddDir("lua/weapons/gmod_tool/stools/keypad_wire.lua")
AddDir("lua/entities/sent_keypad")
AddDir("lua/entities/sent_keypad_wire")
AddDir("settings/controls")
AddDir("addons/DarkRPAssasinMod")
AddDir("addons/ATM Banker v2")
AddDir("lua/autorun/server/atmspawn.lua")
AddDir("lua/entities/ATM_Machine")
AddDir("lua/models/sickness")
AddDir("data/adv_duplicator/=Public Folder=/PERP cars")
AddDir("addons/Food And Household items")
AddDir("addons/Cars")
AddDir("addons/VehicleUpgrade")

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


AddDir(“addons/Cars”) is the directory for it “addons/Cars/Fueled Mod Vehicle Pack/models/lambo/lambo.mdl”

Heres my addentities.lua


AddCustomVehicle("Lambo", "addons/Cars/Fueled Mod Vehicle Pack/models/lambo/lambo.mdl", 50000 )

Thanks everyone.

Alright, first off, clients don’t need Lua files because they are sent through the cache. Only CUSTOM materials, models, particles and sound. Aswell as the cache and maps but they are automatically forced.

Secondly, AddDir doesn’t add the files in the sub-directories. It only adds the files in the directory you specified. Let’s say you added this folder: AddDir(“materials/models/mymodels”) and it has 4 files and one sub-folder called Test with another 4 files in it, the AddDir would only add the 4 files in the folder “mymodels” and not in the “mymodels/Test” folder. You would have to do this to make it work:



AddDir("materials/models/mymodels")
AddDir("materials/models/mymodels/Test")


Third, If you have some files in the addons folder, you have to put the forcedownloads lua file in “addons/myaddon/lua/autorun” and those “forcedownloads” ONLY applies to the folders in the dir “addons/myaddon” so you cannot force downloads for both “addons/myaddon” and “addons/myaddon2” and only put the forcedownloads in the “addons/myaddon/lua/autorun” folder.

Fourth, Move ALL files and folders from “addons/Cars/Fueled Mod Vehicle Pack/” to the root folder which is the “garrysmod” folder where the cache, lua, materials etc is located. The folders you will move will probably be named “materials”, “models” and “scripts”. Materials and Models are a for sure.
Now change the code to


AddCustomVehicle("Lambo", "models/lambo/lambo.mdl", 50000 )

Fifth, Remove the last AddDir function from your code. You only need the function to be declared once.

Sixth, Next time, search the forum before posting. There’s around 2K threads about this here already.

Tell me if you need any further help.

Thanks:) But how will people download the models? They won’t see it:\ Because It doesn’t download

[editline]29th February 2012[/editline]

Yeah actually none of that worked… Don’t worry.

FOUND THE PROBLEM. I had AddDir(lua/weapons/gmod_tool/stools/ol_stacker.lua") instead of AddDir(“lua/weapons/gmod_tool/stools/ol_stacker.lua”)

Like he said, you dont need to do the lua files… I don’t know how changing that worked but its not a smart thing to do, it almost useless, the only reason why it isnt is because it managed to work. Everything he said is what i do on my server except instead of using AddDir i use Resource.AddSingleFile(“filepath”) and i bzip and fast dl all the files.

A guy called Kogitsune made a great application for what i said
You can get to it by clicking here http://facepunch.com/threads/842886
The program is pretty self explanatory, i highly recommend doing it this way, saves alot of time.