clark

Steam Group Avatars

Dec 21st, 2013
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.79 KB | None | 0 0
  1. Players = {}
  2.  
  3. local Group = "razetheworld"
  4. local num = 1
  5.  
  6. local function Success( str, len, head, http )
  7.     str = string.Replace(str, "</steamID64>", "")
  8.    
  9.     local tbl = string.Explode("<steamID64>", str)
  10.    
  11.     table.remove(tbl, 1)
  12.    
  13.     tbl[#tbl] = string.Replace(tbl[#tbl], "</members>", "")
  14.     tbl[#tbl] = string.Replace(tbl[#tbl], "</memberList>", "")
  15.    
  16.     for k, v in pairs(tbl) do
  17.         table.insert(Players, v)
  18.     end
  19. end
  20.  
  21. local function Success2( str, len, head, http )
  22.     local tbl = string.Explode("<memberCount>", str)
  23.    
  24.     table.remove(tbl, 1)
  25.    
  26.     tbl = string.Explode("</memberCount>", tbl[2])
  27.     num = string.Replace(tbl[1], "</memberCount>", "")
  28.     num = math.Clamp(math.Round(tonumber(num) / 1000), 1, 1000)
  29.    
  30.     compile()
  31. end
  32. http.Fetch("http://steamcommunity.com/groups/" .. Group .. "/memberslistxml/?xml=1", Success2, nil)
  33.  
  34. function compile()
  35.     for i=1,num do
  36.         http.Fetch("http://steamcommunity.com/groups/" .. Group .. "/memberslistxml/?xml=1&p=" .. i, Success, nil)
  37.     end
  38. end
  39.  
  40. function Wall()
  41.     startTime = CurTime()
  42.     local w, h = ScrW(), ScrH()
  43.     local x, y = 0, 0
  44.     local size = 64
  45.    
  46.     local DFrame1 = vgui.Create("DFrame")
  47.     DFrame1:SetPos(0, 0)
  48.     DFrame1:SetSize(w, h)
  49.     DFrame1:SetTitle(#Players .. " users in " .. Group .. " steam group")
  50.     DFrame1:SetDraggable(false)
  51.     DFrame1:ShowCloseButton(true)
  52.     DFrame1:MakePopup()
  53.     DFrame1.Paint = function()
  54.         draw.RoundedBox(2, 0, 0, DFrame1:GetWide(), DFrame1:GetTall(), Color(35, 35, 35))
  55.         draw.RoundedBox(2, 0, 0, DFrame1:GetWide(), 25, Color(255, 104, 104))
  56.     end
  57.     DFrame1.lblTitle:SetFont("Trebuchet24")
  58.    
  59.     local DScrollPanel1 = vgui.Create("DScrollPanel", DFrame1)
  60.     DScrollPanel1:SetPos(0, 25)
  61.     DScrollPanel1:SetSize(w, h - 25)
  62.     DScrollPanel1:GetVBar():SetSize(DScrollPanel1:GetVBar():GetWide() / 2, DScrollPanel1:GetVBar():GetTall())
  63.     DScrollPanel1:GetVBar().Paint = function()
  64.         draw.RoundedBox(2, 0, 0, DScrollPanel1:GetVBar():GetWide(), DScrollPanel1:GetVBar():GetTall(), Color(35, 35, 35))
  65.     end
  66.     DScrollPanel1:GetVBar().btnUp:SetSize(DScrollPanel1:GetVBar().btnUp:GetWide() / 2, DScrollPanel1:GetVBar().btnUp:GetTall())
  67.     DScrollPanel1:GetVBar().btnUp.Paint = function()
  68.         draw.RoundedBox(2, 0, 0, DScrollPanel1:GetVBar().btnUp:GetWide(), DScrollPanel1:GetVBar().btnUp:GetTall(), Color(65, 65, 65))
  69.     end
  70.     DScrollPanel1:GetVBar().btnDown:SetSize(DScrollPanel1:GetVBar().btnDown:GetWide() / 2, DScrollPanel1:GetVBar().btnDown:GetTall())
  71.     DScrollPanel1:GetVBar().btnDown.Paint = function()
  72.         draw.RoundedBox(2, 0, 0, DScrollPanel1:GetVBar().btnDown:GetWide(), DScrollPanel1:GetVBar().btnDown:GetTall(), Color(65, 65, 65))
  73.     end
  74.     DScrollPanel1:GetVBar().btnGrip:SetSize(DScrollPanel1:GetVBar().btnGrip:GetWide() / 2, DScrollPanel1:GetVBar().btnGrip:GetTall())
  75.     DScrollPanel1:GetVBar().btnGrip.Paint = function()
  76.         draw.RoundedBox(2, 0, 0, DScrollPanel1:GetVBar().btnGrip:GetWide(), DScrollPanel1:GetVBar().btnGrip:GetTall(), Color(255, 104, 104))
  77.     end
  78.    
  79.     for k, v in pairs(Players) do
  80.         local AvatarImage1 = vgui.Create("AvatarImage", DScrollPanel1)
  81.         AvatarImage1:SetPos(x, y)
  82.         AvatarImage1:SetSteamID(v, size)
  83.         AvatarImage1:SetSize(size, size)
  84.        
  85.         local DButton1 = vgui.Create("DButton", AvatarImage1)
  86.         DButton1:SetPos(0, 0)
  87.         DButton1:SetSize(64, 64)
  88.         DButton1:SetText("")
  89.         DButton1:SetToolTip("http://www.steamcommunity.com/profiles/" .. v .. "\n" .. util.SteamIDFrom64(v))
  90.         DButton1.Paint = function() end
  91.         DButton1.DoClick = function()
  92.             gui.OpenURL("http://www.steamcommunity.com/profiles/" .. v)
  93.         end
  94.         DButton1.DoRightClick = function()
  95.             //("http://www.steamcommunity.com/profiles/" .. v) -- I forget what the copy text function is
  96.         end
  97.        
  98.         if x + (size + 1) >= w then
  99.             x, y = 0, y + (size + 1)
  100.         else
  101.             x = x + (size + 1)
  102.         end
  103.     end
  104.    
  105.     DFrame1.btnMaxim:SetVisible(false)
  106.     DFrame1.btnMinim:SetVisible(false)
  107. end
Add Comment
Please, Sign In to add comment