I'm making my custom gamemode and forgot one vital part for it.
I need to know what the code was for clients to download and install server files automatically when joining the server.
I totally forgot what the code was for it. Someone please help.
[url]http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index5809.html[/url]
Do you people read the wiki or just type random shit into your editor?
[QUOTE=Dreken;41007058]
Do you people read the wiki or just type random shit into your editor?[/QUOTE]
I tried to look for it there but I couldn't find it. Thanks for the solution.
And I came across this when on the website sent above:
[CODE]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("models/yourmodels")[/CODE]
My question is do I need to fill in the blanks where it says:[CODE](.."/*")[/CODE] with the folder which the dictionary is being created of or just fill in the bottom with the folder?
That code is outdated and won't work. Just like that website is outdated.
[code]
function AddDir( dir ) // Recursively adds everything in a directory to be downloaded by client
local files, list = file.Find( dir.."/*", "GAME")
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( files ) do resource.AddFile(dir .. "/" .. v ) end
end
AddDir("models/yourmodels") -- You use this function to add new folders and such[/code]
This code is untested, but should work.
[QUOTE=Robotboy655;41010861]
This code is untested, but should work.[/QUOTE]
I leave it as is and just fill in the "AddDir("models/yourmodels")" at the end?
Fill in "AddDir("models/yourmodels")"
You would do the following code:
[CODE]function AddDir( dir ) // Recursively adds everything in a directory to be downloaded by client
local files, list = file.Find( dir.."/*", "GAME")
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( files ) do resource.AddFile(dir .. "/" .. v ) end
end[/CODE]
Once and then you just add the Dictionaries after that?
Yes. You declare the function once and the call it as many times as needed.
[code]
AddDir("models/yourmodels")
AddDir("sound/yousounds")
[/code]
Now when I'm attempting to join the server, its bringing me in the game then immediately kicking me for "Too many lua errors"
I don't know what could possibly going wrong i'm looking for bugs.
[B]Edit:[/B] I found an error in the Dictionary code:
[I]lua: init.lua:69: 'then' expected near '='[/I]
[B]Line 69:[/B]
[CODE] if fdir != ".svn" then[/CODE]
Someone please help!
I just ran the code I provided and it worked with no errors, means you have error somewhere else in your code.
Sorry, you need to Log In to post a reply to this thread.