1. Post #1
    Gyoo's Avatar
    December 2011
    34 Posts
    Hello everybody.

    First of all, as I'm a french student, my Engilsh can be a bit broken. Apologizes if so.

    So, I think my problem is already explained in the title of the topic : I've tried many ways to make people donwload custom files from the server (like new materials or models from addons I installed), but there's no way it works.
    Here are some infos : I started to config my brand new server this morning, so I installed everything from a clean thing. My sv_downloadurl is well configured as I can download maps, but not the other files. (I also have an other known problem with Lua cache if I remember well).
    The last thing I made was to put directly the files from the addons to the folders of the game, and try to force download with resource.AddFile() commands in garrysmod/lua/autorun/server. It seems to download files, as I get a list of about 500 files to download while connecting to the server, but I get ingame when there are about 375 files left to download. Weird...

    Here is my forceddownloads.lua :
    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("addons")
    AddDir("cache")
    AddDir("data")
    AddDir("materials")
    AddDir("models")
    AddDir("settings")
    AddDir("sound")
    
    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
    
    AddDirLua("lua")
    So, if you have some solutions to fix this trouble, it would be great :)

    Gyoo.

  2. Post #2
    Gyoo's Avatar
    December 2011
    34 Posts
    Bump, hopin' it's not against the rules...

    I've tried things all night long, but I can't fix this problem ><

    (No ad intented) If you want to see what happens while connecting to the serveur, the IP is 88.190.216.186:27014

  3. Post #3
    Gold Member
    Svenskunganka's Avatar
    September 2011
    1,430 Posts
    Gyoo, you're doing this all wrong. You are only suppose to make clients download CUSTOM files instead of the whole freaking models folders. And the way you do it doesn't work.

    If you have any custom files, and you want to add them using AddDir, you have to find every folder.

    Lua isn't that easy that it detects everything that is custom in a folder.

    This is how you do it:
    You are only suppose to add custom files, so if you have any custom files, you have to make clients download them.
    So, lets say, you have a custom model installed on your server, and the folder structure is made like this:
    root/models/custommodel/
    root/materials/custommodel/materials/
    root/materials/custommodel/


    Take time reviewing the structure.
    As you can see, there is a folder in the "root/materials/custommodel folder.
    You may think it is just to add this to the AddDir function: AddDir ("materials/custommodel") but what you really have to do is to add this:
    Code:
    AddDir ("materials/custommodel/")
    AddDir ("materials/custommodel/materials")
    AddDir DOES NOT add file in a folder which are in the folder you specified. So if you only write
    Code:
    AddDir("materials/custommodel")
    to the AddDir function it will only take the FILES in that folder and not the files in the folder which is in the folder you specified.

    Also, if you add for example this:
    Code:
    AddDir ("models/player")
    and you have custom models in there, all files in there will be downloaded which clients do not need. And there's a whole bunch of DEFAULT models which is in there. So, if you have any CUSTOM models in there, you have to write:
    Code:
    resource.AddFile ("models/player/yourfile.mdl")
    Note: You only have to write the .mdl path, since GMod automatically detects the .dx80, dx90, etc.
    Although, for materials (.vmt & .vtf) you have to write this:
    Code:
    resource.AddFile("materials/player/yourfile.vmt")
    the vtf file is automatically detected by GMod. Do the above code for EACH .vmt file you find which are CUSTOM and put in there by you.

    There's ALOT of other folders in models/ and materials/ which contains default models and materials.

    So, as long as you custom models and materials are in the same folder as defaul models, you HAVE to use resource.AddFile
    Reply With Quote Edit / Delete Reply Windows 7 Sweden Show Events Agree Agree x 1 (list)

  4. Post #4
    Gyoo's Avatar
    December 2011
    34 Posts
    Thank you for your answer.

    I'll try to make it the way you describe it, and I hope I won't have to restart from scratch because I fear to have a big mess in the folders with all the files I added ^^'

    Therefore, I found some topics on other websites, with people trying to make the client download directly from the addons folder (with AddDir("addons/etc..."). It sounded weird to me, so I didn't try this method, but should it work ?

    EDIT : I wanted to try something like this :

    for k, v in pairs( g_File.Find("../materials/models/cores/fact/*.*") ) do
    resource.AddSingleFile("materials/models/cores/fact/"..v);
    end;
    for k, v in pairs( g_File.Find("../materials/models/cores/rick/*.*") ) do
    resource.AddSingleFile("materials/models/cores/rick/"..v);
    end;
    for k, v in pairs( g_File.Find("../materials/models/cores/sputnik/*.*") ) do
    resource.AddSingleFile("materials/models/cores/sputnik/"..v);
    end;
    for k, v in pairs( g_File.Find("../materials/models/cores/wheatley/*.*") ) do
    resource.AddSingleFile("materials/models/cores/wheatley"..v);
    end;
    for k, v in pairs( g_File.Find("../materials/models/props/*.*") ) do
    resource.AddSingleFile("materials/models/props/"..v);
    end;
    for k, v in pairs( g_File.Find("../materials/vgui/entities/*.*") ) do
    resource.AddSingleFile("materials/vgui/entities/"..v);
    end;
    for k, v in pairs( g_File.Find("../materials/VGUI/entities/*.*") ) do
    resource.AddSingleFile("materials/VGUI/entities/"..v);
    end;
    for k, v in pairs( g_File.Find("../models/cores/*.*") ) do
    resource.AddSingleFile("models/cores/"..v);
    end;
    for k, v in pairs( g_File.Find("../models/props/*.*") ) do
    resource.AddSingleFile("models/props/"..v);
    end;
    for k, v in pairs( g_File.Find("../sound/vo/core01/*.*") ) do
    resource.AddSingleFile("sound/vo/core01/"..v);
    end;
    for k, v in pairs( g_File.Find("../sound/vo/core02/*.*") ) do
    resource.AddSingleFile("sound/vo/core02/"..v);
    end;
    for k, v in pairs( g_File.Find("../sound/vo/core03/*.*") ) do
    resource.AddSingleFile("sound/vo/core03/"..v);
    end;
    for k, v in pairs( g_File.Find("../sound/vo/wheatley/*.*") ) do
    resource.AddSingleFile("sound/vo/wheatley/"..v);
    end;
    for k, v in pairs( g_File.Find("../lua/autorun/client/*.*") ) do
    resource.AddCSLuaFile("lua/autorun/client/"..v);
    end;
    for k, v in pairs( g_File.Find("../lua/autorun/server/*.*") ) do
    resource.AddCSLuaFile("lua/autorun/server/"..v);
    end;
    for k, v in pairs( g_File.Find("../lua/autorun/*.*") ) do
    resource.AddCSLuaFile("lua/autorun/"..v);
    end;
    for k, v in pairs( g_File.Find("../lua/entities/gmod_playx/*.*") ) do
    resource.AddCSLuaFile("lua/entities/gmod_playx/"..v);
    end;
    for k, v in pairs( g_File.Find("../lua/entities/gmod_playx_repeater/*.*") ) do
    resource.AddCSLuaFile("lua/entities/gmod_playx_repeater/"..v);
    end;
    for k, v in pairs( g_File.Find("../lua/entities/sent_adventurecore/*.*") ) do
    resource.AddCSLuaFile("lua/entities/sent_adventurecore/"..v);
    end;
    for k, v in pairs( g_File.Find("../lua/entities/sent_factcore/*.*") ) do
    resource.AddCSLuaFile("lua/entities/sent_factcore/"..v);
    end;
    for k, v in pairs( g_File.Find("../lua/entities/sent_spacecore/*.*") ) do
    resource.AddCSLuaFile("lua/entities/sent_spacecore/"..v);
    end;
    for k, v in pairs( g_File.Find("../lua/entities/sent_wheatley/*.*") ) do
    resource.AddCSLuaFile("lua/entities/sent_wheatley/"..v);
    end;
    for k, v in pairs( g_File.Find("../lua/playx_client/client/handlers/*.*") ) do
    resource.AddCSLuaFile("lua/playx_client/client/handlers/"..v);
    end;
    for k, v in pairs( g_File.Find("../lua/playx_client/client/vgui/*.*") ) do
    resource.AddCSLuaFile("lua/playx_client/client/vgui/"..v);
    end;
    for k, v in pairs( g_File.Find("../lua/playx_client/client/*.*") ) do
    resource.AddCSLuaFile("lua/playx_client/client/"..v);
    end;
    for k, v in pairs( g_File.Find("../lua/playx_client/providers/*.*") ) do
    resource.AddCSLuaFile("lua/playx_client/providers/"..v);
    end;
    for k, v in pairs( g_File.Find("../lua/playx_client/*.*") ) do
    resource.AddCSLuaFile("lua/playx_client/"..v);
    end;
    for k, v in pairs( g_File.Find("../lua/*.*") ) do
    resource.AddCSLuaFile("lua/"..v);
    (not sure for LUA files)
    Is it correct ?

    New edit : I tried to download two simple files that I put in materials/vgui/entities
    Here is the command to force the download :
    resource.AddFile ("materials/vgui/entities/gmod_playx.vmt")
    resource.AddFile ("materials/vgui/entities/gmod_playx_repeater.vmt")
    Still, it doesn't download anything (I deleted the other forceddownloads.lua with the AddDir function to start with a clean one), even with only two small files... I checked everything : on the server and on the fast download server, the files are well placed.

  5. Post #5
    Gold Member
    Svenskunganka's Avatar
    September 2011
    1,430 Posts
    Lua files should not be downloaded to clients unless it is a REALLY rare moment of Lua code or whatever to call it. So remove all that and never create it again.

    Here's what you should do when creating a script, you HAVE to put it in /lua/autorun/ folder:
    Name of Lua File: forcedownloads.lua
    Code:
    Code:
    resource.AddFile ("materials/vgui/entities/gmod_playx.vmt")
    resource.AddFile ("materials/vgui/entities/gmod_playx_repeater.vmt")
    
    AddCSLuaFile("forcedownloads.lua")
    Make sure you have the materials in the correct folder.
    If you have a FastDL, make sure you have the correct structure.

    And for the addons part, you often have a folder in the addon called "lua" where you may have a autorun folder in it. There you place the forcedownload.lua IF the materials you were to add was for that Addon.

    But I highly suggest you to skip the Addons part and just copy lua to root/lua, materials to root/materials, etc, since not all Addons are made in "Addons" format and people dont seem to tell if they are or not. If the readme.txt file says "Copy files to steam/steamapps/USERNAME/garrysmod/garrysmod/addons" it is CLIENT-SIDE addon format. Servers are not suppose to have it as addon format then. CSS Realistic weapons is in addons format though..

    EDIT: I sugget you to visit this site and review what folders you should add: http://wiki.garrysmod.com/?title=Set...sv_downloadurl

    EDIT2: If you want to, you can add me on steam, just search for Svenskunganka (I'm sure I will be the only one).

  6. Post #6
    Gyoo's Avatar
    December 2011
    34 Posts
    I don't get it... you add in the lua file the path of this same lua file ? I'll try now but it's a bit strange to me. (Moreover, I have already installed TF2 servers but in fact GMod is way more complicated x) )

    I have already seen the link you gave me, but I thank you though :)
    And I'll search you on steam. Mine is hucastgyoung.

    EDIT : I copied the code you gave for a first fast try, but it doesn't change anything unfortunately.

  7. Post #7
    Gold Member
    Svenskunganka's Avatar
    September 2011
    1,430 Posts
    If you have the PlayX folder in the Addons folder, you are suppose to move the forcedownloads.lua file to: root/addons/playx/lua/autorun/ folder.

    But if you've moved the materials, lua, etc folder out of PlayX folder and move them to root/materials, root/lua you have to move the forcedownloads.lua to root/lua/autorun/

    And I dont really know why I use the command AddCSLuaFile("filename.lua") in the script but there was one time it didn't work for me and then I added that and it started working again.

  8. Post #8
    Gyoo's Avatar
    December 2011
    34 Posts
    Thank you (again and again x) ) for the help you gave me through steam :)
    Reply With Quote Edit / Delete Reply Windows 7 France Show Events Friendly Friendly x 1 (list)

  9. Post #9
    Gold Member
    Svenskunganka's Avatar
    September 2011
    1,430 Posts
    No problemow :)