function getServerList(placeId)
local cursor
local servers = {}
repeat
local response = HttpService:JSONDecode(HttpService:GetAsync("https://games.roblox.com/v1/games/"..placeId.."/servers/Public?sortOrder=Asc&limit=10" .. (cursor and "&cursor=" .. cursor or "")))
for _, v in pairs(response.data) do
table.insert(servers, v)
end
cursor = response.nextPageCursor
until not cursor
return servers
end
More Info:
From what I’ve seen people say its that I can’t directly get the data from roblox. How should I go about doing this? All this is a bit confusing for me too so if anyone can explain a bit more how this stuff works I’d appreciate it. I’ve never used anything with http before and even had that disabled on studio until now.
You could do this with DataStore. Basically create a DataStore and every time a new server starts call :UpdateAsync() and save that server ID to the DataStore, and when the server ends just delete it from the DataStore. Then :GetAsync() on the server to recieve the list of servers. I’m not familiar with HTTP :GetAsync() or :PostAsync() but I don’t think you can recieve the list of servers through that.
I think it would be more efficient to use the Messaging Service inestead of Http Requests, it would be something like this: By the way this only works in your game, but maybe it can help.
local Players = game:GetService("Players")
local HttpService = game:GetService("HttpService")
local MessagingService = game:GetService("MessagingService")
MessagingService:SubscribeAsync("Servers",function(Message)
--Stuff Here
end)
while true do
local Data = {
game.JobId -- This will return the job id from the current server of your game
}
local Encoded = HttpService:JSONEncode(Data)
local Sucess,Error = pcall(function()
MessagingService:PublishAsync("Servers",Encoded)
end)
task.wait(5)
end
local HttpService = game:GetService("HttpService")
function getServerList(placeId)
local cursor
local servers = {}
repeat
local response = HttpService:JSONDecode(HttpService:GetAsync("https://games.rprxy.xyz/v1/games/"..placeId.."/servers/Public?sortOrder=Asc&limit=10" .. (cursor and "&cursor=" .. cursor or "")))
for _, v in pairs(response.data) do
table.insert(servers, v)
end
cursor = response.nextPageCursor
until not cursor
return servers
end
@Sougood This option seems like it can work and I might give it a try if message service fails me.
@Zadkay Yeah I ended up trying that and the info sending is pretty quick and effective!
@AC_Starmarine I’ve tried using rprxy.xyz too but it is no longer available. An alternative is if I setup my own http thing which I’m still a bit clueless about.