0% found this document useful (0 votes)
23 views2 pages

Stream Snipe

The document describes fetching a user's avatar image from Roblox and then searching through game servers to find which one the user is currently playing on by matching the avatar image URL. It uses the Roblox APIs to get server data and batch process avatar images to efficiently search for a match.

Uploaded by

A
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views2 pages

Stream Snipe

The document describes fetching a user's avatar image from Roblox and then searching through game servers to find which one the user is currently playing on by matching the avatar image URL. It uses the Roblox APIs to get server data and batch process avatar images to efficiently search for a match.

Uploaded by

A
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

local user_id = "1496182794"

local game_id = tostring(game.PlaceId)

local start_tick = tick()


local http_service = game:GetService("HttpService")

local image_request = request({


Url = "https://thumbnails.roblox.com/v1/users/avatar-headshot?userIds="..
user_id .. "&size=150x150&format=Png&isCircular=false"
})

local image_url = http_service:JSONDecode(image_request.Body).data[1].imageUrl

local servers, cursor = {}

local index = 0
while true do
local data = request({
Url = string.format("https://games.roblox.com/v1/games/%s/servers/Public?
sortOrder=Desc&limit=100%s", game_id, cursor and "&cursor=" .. cursor or "")
})
data = http_service:JSONDecode(data.Body)
index = index + 1
cursor = data.nextPageCursor
task.spawn(function()
for _, server in pairs(data.data) do
local server_data = {}
for i = 1, #server.playerTokens do
table.insert(server_data, {
token = server.playerTokens[i],
type = "AvatarHeadshot",
size = "150x150",
requestId = server.id
})
end
local post_request = request({
Url = "https://thumbnails.roblox.com/v1/batch",
Method = "POST",
Body = http_service:JSONEncode(server_data),
Headers = {
["Content-Type"] = "application/json"
}
})
local post_data = http_service:JSONDecode(post_request.Body).data
if not post_data then
return
end
if post_data[index] then
rconsoleprint("searching server " .. post_data[index].requestId ..
"\n")
end
for _, v in next, post_data do
if v.imageUrl == image_url then
warn("found server " .. v.requestId .. " in " ..
math.floor(tick() - start_tick) .. " seconds\n")

game:GetService("TeleportService"):TeleportToPlaceInstance(game_id, v.requestId)
end
end
end
end)
end

You might also like