Advertisement
Guest User

cl_autorun.lua

a guest
Jul 18th, 2013
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.02 KB | None | 0 0
  1. local autosub_workshop_prompt = CreateClientConVar( "autosub_workshop_prompt", "1", true, false )
  2.  
  3. /*local function sub(id) --unfortunately not working at the moment
  4.     steamworks.Vote( id, true )
  5.     steamworks.Subscribe( id )
  6.     steamworks.ApplyAddons()
  7. end*/
  8. local addons = {}
  9.  
  10.  
  11. net.Receive( "autosub", function( len, pl )
  12.  
  13.     addons = net.ReadTable()
  14.    
  15.     local container = addons.container or {}
  16.     local ch = 0
  17.     local ac = 0
  18.     local an = #container
  19.     local openworkshop = (addons.workshop ~= nil)
  20.    
  21.     if openworkshop then
  22.         chat.AddText("The servers collection is located here: http://steamcommunity.com/sharedfiles/filedetails/?id="..addons.workshop)
  23.     end
  24.     for k,v in pairs(container) do
  25.         local result = steamworks.FileInfo( tonumber(v), function( result )
  26.             ac = ac + 1
  27.             if result then
  28.                 if not result.installed then
  29.                     print(result.title.." (ID: "..v..") by "..result.ownername.." is not installed.")
  30.                     ch = ch + 1
  31.                     --sub(tonumber(v))
  32.                 end
  33.                
  34.                 if ch > 0 and ac == an then
  35.                     chat.AddText(ch.." addons are missing. Type \"autosub_list\" in the console to get more information.")
  36.                     if autosub_workshop_prompt:GetInt() >= 1 then
  37.                         steamworks.ViewFile( addons.workshop )
  38.                         chat.AddText("You can turn the workshop prompt off by typing \"autosub_workshop_prompt 0\" in console")
  39.                     else
  40.                         chat.AddText("prompt off")
  41.                     end
  42.                     --steamworks.ApplyAddons()
  43.                 elseif ch == 0 and ac == an then
  44.                     chat.AddText("You got all addons required for this server.")
  45.                 end
  46.             end
  47.         end )
  48.     end
  49. end )
  50.  
  51. concommand.Add( "autosub_list", function()
  52.     if addons ~= nil and addons ~= {} then
  53.         local container = addons.container or {}
  54.         local ch = 0
  55.         local ac = 0
  56.         local an = #container or 0
  57.         local openworkshop = (addons.workshop ~= nil)
  58.         local txt = ""
  59.         local txt1 = ""
  60.         if an > 0 then
  61.             for k,v in pairs(container) do
  62.                 local result = steamworks.FileInfo( tonumber(v), function( result )
  63.                     ac = ac + 1
  64.                     if result then
  65.                         if not result.installed then
  66.                             txt1 = txt1.."\n"..result.title.." by "..result.ownername.."-> http://steamcommunity.com/sharedfiles/filedetails/?id="..v
  67.                         else
  68.                             txt = txt.."\n"..result.title.." by "..result.ownername.."-> http://steamcommunity.com/sharedfiles/filedetails/?id="..v
  69.                         end
  70.                     end
  71.                     if not openworkshop and ac == an then
  72.                         print("##########ADDON-LIST##########")
  73.                         print(txt.."\n\nMISSING:\n"..txt1.."\n")
  74.                         print("##############################")
  75.                     end
  76.                 end )
  77.             end
  78.            
  79.             if openworkshop then
  80.                 local result = steamworks.FileInfo( tonumber(addons.workshop), function( result )
  81.                     print("##########ADDON-LIST##########")
  82.                     print("Collection: "..result.title.." by "..result.ownername.."-> http://steamcommunity.com/sharedfiles/filedetails/?id="..addons.workshop)
  83.                     print("")
  84.                     print(txt.."\n\nMISSING:\n"..txt1.."\n")
  85.                     print("##############################")
  86.                 end )
  87.             end
  88.         else
  89.             print("No addons required.")
  90.         end
  91.     else
  92.         print("No addons found.")
  93.     end
  94. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement