Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local HttpService = game:GetService("HttpService")
- local function httpRequest(url)
- local reqFunc = (syn and syn.request) or (http and http.request) or (fluxus and fluxus.request) or request
- local success, res
- if reqFunc then
- success, res = pcall(function() return reqFunc({Url = url, Method = "GET"}).Body end)
- end
- if not success or not res then
- success, res = pcall(function() return game:HttpGet(url) end)
- end
- return success and res or nil
- end
- local gui = Instance.new("ScreenGui")
- gui.Name = "RolimonsCharts"
- gui.Parent = game:GetService("CoreGui")
- gui.ResetOnSpawn = false
- local frame = Instance.new("Frame")
- frame.Parent = gui
- frame.Size = UDim2.new(0, 750, 0, 500)
- frame.Position = UDim2.new(0.5, -375, 0.5, -250)
- frame.BackgroundColor3 = Color3.fromRGB(20, 20, 25)
- Instance.new("UICorner", frame)
- frame.Active = true
- frame.Draggable = true
- local title = Instance.new("TextLabel")
- title.Parent = frame
- title.Size = UDim2.new(1, 0, 0, 50)
- title.BackgroundTransparency = 1
- title.Text = "Top 30 Roblox Games (Rolimons)"
- title.Font = Enum.Font.GothamBold
- title.TextColor3 = Color3.fromRGB(255, 255, 255)
- title.TextSize = 20
- local loadingTxt = Instance.new("TextLabel")
- loadingTxt.Parent = frame
- loadingTxt.Size = UDim2.new(1, 0, 1, -50)
- loadingTxt.Position = UDim2.new(0, 0, 0, 50)
- loadingTxt.BackgroundTransparency = 1
- loadingTxt.Text = "Tri des jeux les plus populaires..."
- loadingTxt.TextColor3 = Color3.fromRGB(150, 150, 150)
- loadingTxt.Font = Enum.Font.GothamMedium
- local scroll = Instance.new("ScrollingFrame")
- scroll.Parent = frame
- scroll.Size = UDim2.new(1, -20, 1, -70)
- scroll.Position = UDim2.new(0, 10, 0, 60)
- scroll.BackgroundTransparency = 1
- scroll.Visible = false
- scroll.ScrollBarThickness = 4
- scroll.AutomaticCanvasSize = Enum.AutomaticSize.Y
- local layout = Instance.new("UIGridLayout")
- layout.Parent = scroll
- layout.CellSize = UDim2.new(0, 165, 0, 210)
- layout.CellPadding = UDim2.new(0, 12, 0, 12)
- layout.HorizontalAlignment = Enum.HorizontalAlignment.Center
- local function createCard(name, uId, players)
- local card = Instance.new("Frame")
- card.BackgroundColor3 = Color3.fromRGB(30, 30, 40)
- card.Parent = scroll
- Instance.new("UICorner", card)
- local img = Instance.new("ImageLabel")
- img.Parent = card
- img.Size = UDim2.new(1, 0, 0, 140)
- img.Image = "rbxthumb://type=GameIcon&id=" .. uId .. "&w=150&h=150"
- img.BackgroundTransparency = 1
- Instance.new("UICorner", img)
- local txt = Instance.new("TextLabel")
- txt.Parent = card
- txt.Size = UDim2.new(1, -10, 0, 35)
- txt.Position = UDim2.new(0, 5, 0, 145)
- txt.Text = name
- txt.TextColor3 = Color3.fromRGB(255, 255, 255)
- txt.BackgroundTransparency = 1
- txt.TextWrapped = true
- txt.Font = Enum.Font.GothamMedium
- txt.TextSize = 12
- local pCount = Instance.new("TextLabel")
- pCount.Parent = card
- pCount.Size = UDim2.new(1, -10, 0, 20)
- pCount.Position = UDim2.new(0, 5, 0, 180)
- pCount.Text = "👤 " .. players
- pCount.TextColor3 = Color3.fromRGB(0, 255, 150)
- pCount.BackgroundTransparency = 1
- pCount.Font = Enum.Font.GothamBold
- end
- local function fetch()
- local res1 = httpRequest("https://api.rolimons.com/games/v1/gamelist")
- if not res1 then loadingTxt.Text = "Erreur Rolimons"; return end
- local data1 = HttpService:JSONDecode(res1)
- if not data1 or not data1.success then return end
- -- On transforme le dictionnaire en liste pour pouvoir le trier
- local gameList = {}
- for id, info in pairs(data1.games) do
- table.insert(gameList, {
- id = id,
- playerCount = info[2] or 0
- })
- end
- table.sort(gameList, function(a, b)
- return a.playerCount > b.playerCount
- end)
- local top30Ids = {}
- local stats = {}
- for i = 1, 30 do
- local gameData = gameList[i]
- if gameData then
- table.insert(top30Ids, gameData.id)
- stats[tostring(gameData.id)] = gameData.playerCount
- end
- end
- local res2 = httpRequest("https://games.roblox.com/v1/games?universeIds=" .. table.concat(top30Ids, ","))
- if res2 then
- local data2 = HttpService:JSONDecode(res2)
- table.sort(data2.data, function(a, b)
- return (stats[tostring(a.universeId)] or 0) > (stats[tostring(b.universeId)] or 0)
- end)
- if loadingTxt then loadingTxt:Destroy() end
- scroll.Visible = true
- for _, gameInfo in ipairs(data2.data) do
- local uId = tostring(gameInfo.universeId)
- local p = stats[uId] or 0
- local formattedPlayers = p >= 1000 and string.format("%.1fk", p/1000) or tostring(p)
- createCard(gameInfo.name, uId, formattedPlayers)
- end
- else
- loadingTxt.Text = "Erreur Roblox"
- end
- end
- task.defer(fetch)
Advertisement
Add Comment
Please, Sign In to add comment