• Does sv_downloadurl require resource.AddFile() ?
    13 replies, posted
To my understanding I just need to throw my files into a webserver folder that has the same directory structure as gmod. Then i need to put the url to that folder in the sv_downloadurl. For example my server.cfg sv_downloadurl "http://example.com/fastdl" (I have also tried with a slash at the end example.com/fastdl/) my website directory structure http://example.com/fastdl/materials/test.png After doing this i run the following command on my client lua_run_cl print( file.Exists("materials/test.png","GAME") ) and the result is false Is there something I'm missing? Do i need a lua cache file like the one listed on this wiki page (scroll down to "The Cache") since I am running the gmod server and webserver on the same computer should localhost work for sv_downloadurl?
sv_downloadurl is part of the FastDL system that is present in all Source Engine games. This system was only designed to handle maps, and by default, that is all it will send. As part of the default functionality, if the current map has an corresponding *.res file, any resources (models, materials, sounds, etc.) listed in that file will be added to the download list. This is great for maps, but in Garry's Mod, servers often have a lot of extra content that isn't map specific, so these files need to be added to the download list manually. This is where resource.AddFile() comes in. Lua scripts can use this function to specify additional resources that should be sent to clients. This isn't the only method used to send files to clients. Some addons opt to use the Steam Workshop instead. This is usually preferred, as the user gets Steam download speeds instead of whatever speed the server operator has on their HTTP server. This is done with resource.AddWorkshop() in a Lua script.
Where do i put the file containing the resource.AddFile calls? I've tried putting one under lua/autorun/server/the_file.lua on the game server (no http) and it doesn't seem to work. Heres what I have server.cfg: sv_loadingurl "" sv_downloadurl "http://example.com/gmod/fastdl" sv_allowdownload 0 sv_allowupload 1 fastdl.lua located in lua/autorun/server/fastdl.lua on the garrys server folder if ( SERVER ) then     resource.AddFile("materials/mango.png") end The file located in the webserver : /var/www/example.com/public_html/gmod/fastdl/materials/mango.png ?
That looks like it should work. I ran a test to make sure nothing is missing. Here is the server.cfg I used for my test. Note that while 127.0.0.1 will work for my own client, it will not work for anyone else joining the server. sv_downloadurl "http://127.0.0.1/fastdl/garrysmod" Here is the lua/autorun/server/fastdl_test.lua I used for my test. resource.AddFile("materials/jcw87_avatar.png") When you join with the Garry's Mod client, do you see that filename pop up on the loading screen, even for just a moment? https://files.facepunch.com/forum/upload/57895/1c0fa74f-8093-4b81-8cab-49f92631ab13/image.png Do you see attempts to download the file in your HTTP server log? (I am aware that the file 404'ed in my test, this was on purpose so that it would always try to download the file) #Software: Microsoft Internet Information Services 10.0 #Version: 1.0 #Date: 2018-08-10 00:58:30 #Fields: date time s-ip cs-method cs-uri-stem cs-uri-query s-port cs-username c-ip cs(User-Agent) cs(Referer) sc-status sc-substatus sc-win32-status time-taken 2018-08-10 00:58:30 127.0.0.1 GET /fastdl/garrysmod/materials/jcw87_avatar.png.bz2 - 80 - 127.0.0.1 Half-Life+2 hl2://192.168.1.50:27015 404 0 2 116 2018-08-10 00:58:30 127.0.0.1 GET /fastdl/garrysmod/materials/jcw87_avatar.png - 80 - 127.0.0.1 Half-Life+2 hl2://192.168.1.50:27015 404 0 2 0
xxxxxxxx - - [09/Aug/2018:23:58:49 +0100] "GET /gmod/fastdl/maps/rp_evocity2_v5p.bsp.bz2 HTTP/1.1" 404 538 "hl2://xxxxxxxx:27015" "Half-Life 2". For some reason the server requests the map but not the image.
If the client can't download the map, it gives up immediately and disconnects. If it still doesn't request the file when the client has the map, then your Lua script isn't working for some reason. Double check the path of the script file, and check the whole console log of the server for any Lua errors.
I've noticed that other people have this occur in their log when they cant get a file to load using sv_downloadurl clientside lua startup! Failed to load custom font file 'c:/program files (x86)/steam/steamapps/common/garrysmod/garrysmod/workshop/resource/fonts/bebasneue.ttf' I don't get anything like this on my server or client logs, even if I INTENTIONALLY make the file wrong. if ( SERVER ) then resource.AddFile("materials/mango.png") end ... no error if ( SERVER ) then resource.AddFile("materials/no_existant_file.png") end ... still no error Further, i can put a print statement right next to the AddFile call and it prints in the console. So i know that the resource.AddFile call is occuring. if ( SERVER ) then resource.AddFile("materials/no_existant_file.png") print("test") end ... prints test to console and no error Is there some kind of debugging option I need? This is driving me insane... /srv/gmod/server_1/srcds_run \         -authkey xxxxxxxx \         -console \         -condebug \         -debug \         -game garrysmod \         +maxplayers 12 \         +host_workshop_collection 1464737129 \         +gamemode darkrp \         +map rp_evocity2_v5p The only thing I'm not sure sure about is the point when resource.AddFile calls. It calls during server start and not when the client joins.
That font error has nothing to do with FastDL. It is more likely that you installed something that does something weird with resource.AddFile(). Maybe an addon has overridden it, or maybe some addon is trying to be """"helpful"""" by auto-adding a bunch of files and hitting the file limit, preventing new entries from getting in. You can save this script to lua/autorun/!.lua to help check what files are actually being added, and what scripts are adding them. The name and location of this script are important, as this is the earliest you can run Lua code without modifying vanilla gmod Lua scripts. if CLIENT then return end local function printf(...)     Msg(string.format(...)) end print([[     ========================================================     | resource.AddFile toubleshooter is present.           |     | Be sure to delete when you are done troubleshooting! |     ======================================================== ]]) local dbg = debug.getinfo(resource.AddFile, "S") if (dbg.what == "Lua") then     printf("resource.AddFile has been overridden from '%s'\n", dbg.short_src) else     print("resource.AddFile has NOT been overridden (yet)") end local resourceAddFile = resource.AddFile function resource.AddFile(name)     local dbg = debug.getinfo(2, "Sl")     printf("resource.AddFile> %s:%i: %s\n", dbg.short_src, dbg.currentline, name)     resourceAddFile(name) end local resourceAddSingleFile = resource.AddSingleFile function resource.AddSingleFile(name)     local dbg = debug.getinfo(2, "Sl")     printf("resource.AddSingleFile> %s:%i: %s\n", dbg.short_src, dbg.currentline, name)     resourceAddSingleFile(name) end Post your console output after running this on your server.
I called the script @.lua because !.lua made things hard to work with. When the script is loaded : ...  ========================================================     | resource.AddFile toubleshooter is present.           |     | Be sure to delete when you are done troubleshooting! |     ======================================================== resource.AddFile has NOT been overridden (yet) ... Then it loads files up until the fastdl... ... resource.AddFile> lua/autorun/server/fastdl.lua:4: materials/mango.png resource.AddFile> lua/autorun/server/fastdl.lua:5: materials/non_existant_file.png ... While running it calls resource.AddFile about 200 times I also tried adding the resource.AddFile calls to the @.lua, the results are the same and the client does not get the files. The output of PrintTable > PrintTable ( debug.getinfo ( resource.AddFile, S ) )... currentline = -1 func = function: 0xf19b60f0 isvararg = false lastlinedefined = 23 linedefined = 19 namewhat = nparams = 1 nups = 2 short_src = lua/autorun/@.lua source = @lua/autorun/@.lua what = Lua The entire output (This is filled with a lot of errors from the map being used) output.txt
As I said, the name is important. https://files.facepunch.com/forum/upload/57895/402e9cc1-51d2-4b9c-ae14-f23945a27e54/image.png Just look at all those characters that come before @. Any script with a name starting with one of those characters would run first, and not have potential resource.AddFile calls logged. Many cheats, anti-cheats, and malicious scripts love to use these early names. If any of those are using resource.AddFile, naming my script @.lua will prevent it from logging those. Other than that, I'm not seeing anything that would cause a problem with FastDL, which means there really isn't anything else left to look at other than potential silly mistakes and trial-and-error troubleshooting (my least favorite). Are you absolutely certain that the mango.png file does not already exist anywhere on the client, in any of the mounted folders and workshop addons? Does the file exist on the server? I'm not sure if this will affect it at all, but you should have it there, just in case. Are your vanillia gmod scripts unmodified? Use SteamCMD to update the server with file verification to make sure. Have you tried a server.cfg file that ONLY has the sv_downloadurl set, and nothing else? If all of the above fails, remove all addons and extras from the server (except your fastdl.lua and mango.png files, of course.) and try using FastDL again.
Okay, so its seems like after many hours of questioning my intelligence and sanity its finally been figured out. It turns out you need to have a copy of the file on your server, or at least a file with the same name. Out of sheer desperation I put a random file in my server's materials folder with the same name as the one on my web server and lo and behold the web server file was downloaded on client connection. here is the end file structure --the game server, this file is empty /server/garrysmod/materials/mango.png --the web server example.com/gmod/fastdl/materials/mango.png I'm not sure why this makes sense seeing that the files being transferred are client side only. Also the fact that the files from the game server are not validated against the ones on the web server makes even less sense to me. Thanks for all the help Jcw, I really appreciate it.
You have to remember that FastDL is an extension of the direct server download feature. It probably just checks to see if the file exists when you add it to the download list as a "sanity check", because it needs to exist for the direct server download to work. Most people just chuck the same files onto both the server and the FastDL server, so they never run into this.
Did u putted them in the right folder. Also did u make bz2 version of these files which is the compressed version of the files. Its important becuz it will download them in normal way.
You clearly haven't read the thread, the problem has already been solved. Additionally, if you had payed attention to the thread at all, you would see that the problem wasn't a case of the files not being in the right folder. The client wasn't even asking for the files in the first place (as proven by the HTTP server logs), so where they were on the FastDL wasn't even relevant yet. The root of the problem was that the server wasn't adding the files to the download list because, according to the server, the files didn't exist.
Sorry, you need to Log In to post a reply to this thread.