So right now I am trying to make the clients on my server download custom songs to route through PCMOD2. I already have the PCmod2 side of the matter all working.
What I am having trouble with is getting my AddDir function to work so that the client downloads these custom songs.
My current function is as follows
[lua]
function AddDir(dir) // recursively adds everything in a directory to be downloaded by client
2. local list = file.FindDir("…/"…dir…"/")
3. for _, fdir in pairs(list) do
4. if fdir != “.svn” then // don’t spam people with useless .svn folders
5. AddDir(fdir)
6. end
7. end
8.
9. for k,v in pairs(file.Find("…/"…dir…"/")) do
So as you can see I am trying to make the client download everything within the “sound/music” directory, the music being a custom added folder within my server.
I currently have this script listed under “resources.lua” in my “lua/autorun/server” directory.
Actually no, I don’t post a lot on facepunch as you can see by my post count so when I tried to do the [lua] quotes they failed when I previewed my post so really quickly found another thread replied it to get the [lua][/lua] code and put it in, I guess when I previewed it again I didn’t realize it wasn’t quite lined up, and apparently I didn’t realize my numbers pasted over.
Anyone else willing to help? Code pasted in pic above/below still not working…
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
<span class="highlight">resource</span>.AddFile(dir.."/"..v)
end
end
AddDir("sound/music")
That isn’t part of the Lua syntax, that is the result of you (or someone who gave you the code) searching on facepunch and its fail attempt to highlight the words you searched. Just remove the html code (<span class=“highlight”> and </span>) from the code and it should be ok.