Hi! Just a small request that would help alot of people! Is there anybody who can make a small generator that can make a lua file with the resource.AddWorkshop from all addons in a collection? I don't really want to sit down and copy and paste 56 addons into a text file. Thanks!
If all/most of your addons are in a collection and there is a lot look into [URL=http://wiki.garrysmod.com/page/Workshop_for_Dedicated_Servers]this[/URL]
It shows you how to add a whole collection instead of individual addons.
This isn't exactly what you want but it works really well and you only add or remove addons to the collection to add or remove from server downloads.
I know about this but what im saying is to force download a workshop addon to a client, you have to use resource.AddWorkshop but I dont want to go through each of my 56 addons in my collections. If somebody could make a script or some program that could automatically get the IDs and add them to a lua file using resource.AddWorkshop.
It might need a little cleaning up if/when valve changes the page ( class names / data values ), but this is more or less what you want:
[code]function resource.AddWorkshopCollection( id )
http.Fetch( "http://steamcommunity.com/sharedfiles/filedetails/?id=" .. id, function( page )
for k in page:gmatch( [[<div id="sharedfile_(.-)" class="collectionItem">]] ) do
resource.AddWorkshop( k )
end
end )
end[/code]
You'd then use it like this:
[code]resource.AddWorkshopCollection( "your collection id" )[/code]
[QUOTE=Kogitsune;45124991]It might need a little cleaning up if/when valve changes the page ( class names / data values ), but this is more or less what you want:
[code]function resource.AddWorkshopCollection( id )
http.Fetch( "http://steamcommunity.com/sharedfiles/filedetails/?id=" .. id, function( page )
for k in page:gmatch( [[<div id="sharedfile_(.-)" class="collectionItem">]] ) do
resource.AddWorkshop( k )
end
end )
end[/code]
You'd then use it like this:
[code]resource.AddWorkshopCollection( "your collection id" )[/code][/QUOTE]
Thanks man! I'll test it tommorrow!
If you start your server and the server automatically downloads them: [url]https://dl.dropboxusercontent.com/u/26074909/tutoring/server_srcds_steamcmd/setting_up_a_server_with_steamcmd.lua.html[/url]
Then you can just loop through engine.GetAddons( ) for them. If you have any maps in them, then I'd recommend processing them with file.Read( "*", v.title ) to list the files/folders and see if there are any maps; if so then only allow it to be added if the map file is the current map the server is on. ( However, they are supposed to be automatic so you could try skipping them )
Additionally, if you want to ensure the client has all of the files the server does, you can create a list and sync it with the client as they connect.
[lua]//
// Adds all server addons to download list - Josh 'Acecool' Moser
//
hook.Add( "Initialize", "CompareAddons:BuildList", function( )
// For syncing with clients; global list
-- if ( !COMPARE_ADDONS_LIST ) then COMPARE_ADDONS_LIST = { }; end
for k, v in pairs( engine.GetAddons( ) ) do
// Custom system for reading addons; listed above
-- local _files = fileio:GenerateAddonFileList( v );
-- local _info = fileio:GenerateAddonInfoList( _files );
// Don't download maps, they're automatic.
-- if ( _info.maps > 0 ) then continue; end
// Create a list of addons ( WORK SHOP IDs ) that we send to the client for verification.
// Some addons don't have proper .wsids, parse the name if that occurs.
local _file = v.wsid && v.wsid || string.gsub( tostring( v.file ), "%D", "" );
// Adds them to list to sync...
-- table.insert( COMPARE_ADDONS_LIST, _file );
// Make the client download it.
resource.AddWorkshop( _file );
end
end );[/lua]
[QUOTE=Acecool;45130075]If you start your server and the server automatically downloads them: [url]https://dl.dropboxusercontent.com/u/26074909/tutoring/server_srcds_steamcmd/setting_up_a_server_with_steamcmd.lua.html[/url]
Then you can just loop through engine.GetAddons( ) for them. If you have any maps in them, then I'd recommend processing them with file.Read( "*", v.title ) to list the files/folders and see if there are any maps; if so then only allow it to be added if the map file is the current map the server is on. ( However, they are supposed to be automatic so you could try skipping them )
Additionally, if you want to ensure the client has all of the files the server does, you can create a list and sync it with the client as they connect.
[lua]//
// Adds all server addons to download list - Josh 'Acecool' Moser
//
hook.Add( "Initialize", "CompareAddons:BuildList", function( )
// For syncing with clients; global list
-- if ( !COMPARE_ADDONS_LIST ) then COMPARE_ADDONS_LIST = { }; end
for k, v in pairs( engine.GetAddons( ) ) do
// Custom system for reading addons; listed above
-- local _files = fileio:GenerateAddonFileList( v );
-- local _info = fileio:GenerateAddonInfoList( _files );
// Don't download maps, they're automatic.
-- if ( _info.maps > 0 ) then continue; end
// Create a list of addons ( WORK SHOP IDs ) that we send to the client for verification.
// Some addons don't have proper .wsids, parse the name if that occurs.
local _file = v.wsid && v.wsid || string.gsub( tostring( v.file ), "%D", "" );
// Adds them to list to sync...
-- table.insert( COMPARE_ADDONS_LIST, _file );
// Make the client download it.
resource.AddWorkshop( _file );
end
end );[/lua][/QUOTE]
Oh wow thanks! I'm going to test right now!
[QUOTE=Acecool;45130075]If you start your server and the server automatically downloads them: [url]https://dl.dropboxusercontent.com/u/26074909/tutoring/server_srcds_steamcmd/setting_up_a_server_with_steamcmd.lua.html[/url]
Then you can just loop through engine.GetAddons( ) for them. If you have any maps in them, then I'd recommend processing them with file.Read( "*", v.title ) to list the files/folders and see if there are any maps; if so then only allow it to be added if the map file is the current map the server is on. ( However, they are supposed to be automatic so you could try skipping them )
Additionally, if you want to ensure the client has all of the files the server does, you can create a list and sync it with the client as they connect.
[lua]//
// Adds all server addons to download list - Josh 'Acecool' Moser
//
hook.Add( "Initialize", "CompareAddons:BuildList", function( )
// For syncing with clients; global list
-- if ( !COMPARE_ADDONS_LIST ) then COMPARE_ADDONS_LIST = { }; end
for k, v in pairs( engine.GetAddons( ) ) do
// Custom system for reading addons; listed above
-- local _files = fileio:GenerateAddonFileList( v );
-- local _info = fileio:GenerateAddonInfoList( _files );
// Don't download maps, they're automatic.
-- if ( _info.maps > 0 ) then continue; end
// Create a list of addons ( WORK SHOP IDs ) that we send to the client for verification.
// Some addons don't have proper .wsids, parse the name if that occurs.
local _file = v.wsid && v.wsid || string.gsub( tostring( v.file ), "%D", "" );
// Adds them to list to sync...
-- table.insert( COMPARE_ADDONS_LIST, _file );
// Make the client download it.
resource.AddWorkshop( _file );
end
end );[/lua][/QUOTE]
Ok i've tested it and it works like a charm! Thanks man!
[QUOTE=xXsquirr3lsXx;45139244]Ok i've tested it and it works like a charm! Thanks man![/QUOTE]
How do you actually use this?
Just paste into lua/autorun/server/workshop_resources.lua
It seems as though engine.GetAddons( ) is broken on the server ( it doesn't seem to show the collection data for me any-longer ); I am told that this is fixed in the dev version though.
The problem with such "generators" is that not all addons need to be forced to be downloaded. Only those with models/sounds/materials need to be forced to download.
[QUOTE=Robotboy655;45258714]The problem with such "generators" is that not all addons need to be forced to be downloaded. Only those with models/sounds/materials need to be forced to download.[/QUOTE]
Easy to solve. Just make a table with an addon whitelist that don't need to be downloaded.
[QUOTE=BFG9000;45263793]Easy to solve. Just make a table with an addon whitelist that don't need to be downloaded.[/QUOTE]
This kinda defeats the purpose of auto generating scripts unless you manually open each addon and check if it has content or not.
I use engine.GetAddons( ) for all of them, except ones I remove Lua from; so it is a 2 part script, unfortunately; although it is only 1 additional clause for the standard recursive script for gamemode/mine/content/ dir using the workshop/ dir and empty .gma files...
Because we can't stop addon Lua from loading, I create several empty ds_xxx.gma files inside of gamemodes/mine/content/workshop/* - and those are AddWorkshopped for clients ( extracted for models on server -- only 1 extra clause for the standard gamemode/content/ resource.AddSingleFile system );
Then, the engine.GetAddons( ) ( which is currently broken, but fixed on dev I'm told ) but the fileio uses local _files, _folders file.Find( "*", v.title ); to grab the files. The Info generator creates a header which specifies which types of files are in. That is why I left the commented segments in when I pasted ( uncommented in mine ), so it doesn't download un-needed addons.
[QUOTE=Robotboy655;45263958]This kinda defeats the purpose of auto generating scripts unless you manually open each addon and check if it has content or not.[/QUOTE]
Not really. Stuff like stacker and advanced duplicator you can pretty much whitelist off the top of your head.
[QUOTE=BFG9000;45264384]Not really. Stuff like stacker and advanced duplicator you can pretty much whitelist off the top of your head.[/QUOTE]
You still have to manually do it.
But for a typical DarkRP server owner this would be useful since their collection is 90% custom content that only VIPs are allowed to use anyways
[QUOTE=Acecool;45264286]I use engine.GetAddons( ) for all of them, except ones I remove Lua from; so it is a 2 part script, unfortunately; although it is only 1 additional clause for the standard recursive script for gamemode/mine/content/ dir using the workshop/ dir and empty .gma files...
Because we can't stop addon Lua from loading, I create several empty ds_xxx.gma files inside of gamemodes/mine/content/workshop/* - and those are AddWorkshopped for clients ( extracted for models on server -- only 1 extra clause for the standard gamemode/content/ resource.AddSingleFile system );
Then, the engine.GetAddons( ) ( which is currently broken, but fixed on dev I'm told ) but the fileio uses local _files, _folders file.Find( "*", v.title ); to grab the files. The Info generator creates a header which specifies which types of files are in. That is why I left the commented segments in when I pasted ( uncommented in mine ), so it doesn't download un-needed addons.[/QUOTE]
Hey Acecool, quick question. I see you have in the script you gave me options to make comparable lists and the ability to disable map downloads because they're automatic. How do I enable these options?
You can get the file / folder list by using file.Find( "*", v.title ); in the for k, v in pairs( engine.GetAddons( ) ) do... and recurse through folders to grab all of the details... I'll be releasing by resources.lua which does the workshop addition, plus standard content and an override ( for gmas you want to extract to only use models instead of lua files ).
resource.AddWorkshop = You server having potential back-doors. Plus its unreliable and doesn't work half the time. Put the effort in and make a image of your servers files that you can run Fox Warriors resource generator across.
[QUOTE=Steeze;45288883]resource.AddWorkshop = You server having potential back-doors. Plus its unreliable and doesn't work half the time. Put the effort in and make a image of your servers files that you can run Fox Warriors resource generator across.[/QUOTE]
1. You have as much as a potential to having a backdoor as downloading a random addon from garrysmod.org and not looking at the code.
2. That's totally dependent on your regional Steam server.
3. Believe it or not, sometimes, people don't have access to their own webserver.
4. It's not your place to convince people what they can and cannot use.
I agree; which is one of the reasons I requested a way to prevent Lua files from loading... No word back on that, but it is why I made the other clause so that an empty .gma will let clients download the models instead of having the server download it...
Sorry, you need to Log In to post a reply to this thread.