Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- -------------------------------------
- - Bytewave's Worksohp Adder -
- - -
- - Adds maps for client download -
- - based on the server's current map -
- - as well as general addons -
- - -
- - For free public use -
- -------------------------------------
- INSTRUCTIONS:
- Place this file in lua/autorun/server.
- Name it something easy-to-remember, such as workshop.lua.
- Edit this file where you are told. Do not touch
- any other part of this file unless you have no Lua knowledge
- FINDING AN ADDON'S ID:
- Look at the addon's URL in the Steam browser (make sure you can
- actually see links in the Steam browser, there's a setting
- for it under Interface I believe).
- Search for this:
- ?id=xxxxxxxxx
- Copy that string of numbers, and there ya' go.
- ]]--
- -- EDIT HERE:
- -- Add each addon ID on a new line, followed by a comma
- -- Do not place a comma on the final line
- local ADDONS = {
- 123456789,
- 987654321,
- }
- -- Add maps in this format:
- -- <mapname> = <Workshop ID>
- -- Add a comma to each line until the end
- local MAPS = {
- some_map_name = 123456789,
- some_other_map = 987654321,
- }
- -- Do not edit anything below this line!
- -- (Unless you know what you're doing, of course.)
- local players = player.GetAll()
- local format = string.format
- -- I like making things look pretty. Don't judge me.
- local function PChatToAll(msg)
- for _, ply in pairs(players) do
- if ply and IsValid(ply) then
- ply:ChatPrint(format("[WORKSHOP]: %s", msg))
- end
- end
- end
- local function PSLog(msg)
- ServerLog(format("[WORKSHOP]: %s\n", msg))
- end
- local function EchoAll(msg)
- PSLog(msg)
- PChatToAll(msg)
- end
- -- Make some global variables to not call
- -- game.GetMap() and table.Count() every time
- local curMap = string.lower(game.GetMap())
- local addonCount = table.Count(ADDONS)
- EchoAll("Starting Workshop operations, expect chat spam!")
- --[[-----------
- Addon Adder
- -----------]]--
- EchoAll("Adding Workshop addons to client downloads...")
- for num, ID in pairs(ADDONS) do
- EchoAll(format("Adding addon %d (%d of %d) for client download...", ID, num, addonCount))
- -- tostring() because someone thought it'd be a good idea
- -- to make resource.AddWorkshop take a string instead
- -- of a number
- resource.AddWorkshop(tostring(ID))
- EchoAll(format("Addon %d (%d of %d) added.", ID, num, addonCount))
- end
- --[[---------
- Map Adder
- ---------]]--
- local curMapID = MAPS[curMap]
- EchoAll(format("Server playing on map %q. Attempting to add this map for client download...", curMap))
- if not (curMapID == nil) then
- EchoAll(format("Adding map %q (ID: %d) for client download...", curMap, curMapID))
- -- tostring() because someone thought it'd be a good idea
- -- to make resource.AddWorkshop take a string instead
- -- of a number
- resource.AddWorkshop(tostring(curMapID))
- EchoAll(format("Map %q (ID: %d) added.", curMap, curMapID))
- else
- EchoAll(format("Map %q not found in the MAPS table!", curMap))
- end
- -- We're done here, now let's say we're done
- EchoAll("All Workshop operations complete! Sorry for the spam!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement