local autosub_workshop_prompt = CreateClientConVar( "autosub_workshop_prompt", "1", true, false )
/*local function sub(id) --unfortunately not working at the moment
steamworks.Vote( id, true )
steamworks.Subscribe( id )
steamworks.ApplyAddons()
end*/
local addons = {}
net.Receive( "autosub", function( len, pl )
addons = net.ReadTable()
local container = addons.container or {}
local ch = 0
local ac = 0
local an = #container
local openworkshop = (addons.workshop ~= nil)
if openworkshop then
chat.AddText("The servers collection is located here: http://steamcommunity.com/sharedfiles/filedetails/?id="..addons.workshop)
end
for k,v in pairs(container) do
local result = steamworks.FileInfo( tonumber(v), function( result )
ac = ac + 1
if result then
if not result.installed then
print(result.title.." (ID: "..v..") by "..result.ownername.." is not installed.")
ch = ch + 1
--sub(tonumber(v))
end
if ch > 0 and ac == an then
chat.AddText(ch.." addons are missing. Type \"autosub_list\" in the console to get more information.")
if autosub_workshop_prompt:GetInt() >= 1 then
steamworks.ViewFile( addons.workshop )
chat.AddText("You can turn the workshop prompt off by typing \"autosub_workshop_prompt 0\" in console")
else
chat.AddText("prompt off")
end
--steamworks.ApplyAddons()
elseif ch == 0 and ac == an then
chat.AddText("You got all addons required for this server.")
end
end
end )
end
end )
concommand.Add( "autosub_list", function()
if addons ~= nil and addons ~= {} then
local container = addons.container or {}
local ch = 0
local ac = 0
local an = #container or 0
local openworkshop = (addons.workshop ~= nil)
local txt = ""
local txt1 = ""
if an > 0 then
for k,v in pairs(container) do
local result = steamworks.FileInfo( tonumber(v), function( result )
ac = ac + 1
if result then
if not result.installed then
txt1 = txt1.."\n"..result.title.." by "..result.ownername.."-> http://steamcommunity.com/sharedfiles/filedetails/?id="..v
else
txt = txt.."\n"..result.title.." by "..result.ownername.."-> http://steamcommunity.com/sharedfiles/filedetails/?id="..v
end
end
if not openworkshop and ac == an then
print("##########ADDON-LIST##########")
print(txt.."\n\nMISSING:\n"..txt1.."\n")
print("##############################")
end
end )
end
if openworkshop then
local result = steamworks.FileInfo( tonumber(addons.workshop), function( result )
print("##########ADDON-LIST##########")
print("Collection: "..result.title.." by "..result.ownername.."-> http://steamcommunity.com/sharedfiles/filedetails/?id="..addons.workshop)
print("")
print(txt.."\n\nMISSING:\n"..txt1.."\n")
print("##############################")
end )
end
else
print("No addons required.")
end
else
print("No addons found.")
end
end)