Creates a grid of randomly generated Steam avatars which link to their corresponding Steam user pages.
function GetRandomSteamID()
return "7656119"..tostring(
7960265728+math.
random(
1,
200000000))
end
function CreateSteamUserGrid(av_size, av_res)
if(av_size
< 64)
then
Error(
"Avatar size cannot be less than 64 square pixels.\n")
return
end
if(SteamUserGrid)
then SteamUserGrid:
Remove()
end
local w_count
= math.
floor(
ScrW()
/av_size)
local h_count
= math.
floor((
ScrH()
-25)
/av_size)
SteamUserGrid
= vgui.
Create(
"DFrame")
SteamUserGrid:
SetSize(w_count
*av_size, (h_count
*av_size)
+25)
SteamUserGrid:
Center()
SteamUserGrid:
SetTitle(
"Randomly Generated Grid of Steam Users")
SteamUserGrid:
MakePopup()
local avatar, random_id
for i
= 0, (w_count
*h_count)
-1 do
random_id
= GetRandomSteamID()
avatar
= vgui.
Create(
"AvatarImage", SteamUserGrid)
avatar:
SetPos((i
%w_count)
*av_size,
25+math.
floor(i
/w_count)
*av_size)
avatar:
SetSteamID(random_id, av_res)
avatar:
SetSize(av_size, av_size)
avatar.id
= random_id
avatar.OnMousePressed
= function(self)
local url
= "http://steamcommunity.com/profiles/" .. self.id
gui.
OpenURL(url)
end
end
end Output: CreateSteamUserGrid(64, 64)
The white question mark avatars mean no custom icon used or the user hasn't set up a community profile. The blue question mark avatars mean the user doesn't exist.