Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local HttpService = game:GetService("HttpService")
- function GetRandomGame(filter)
- --if not HttpService.HttpEnabled then print("You must activate the HttpService !") return false end
- local Keywords = filter["keywords"]
- local IsSponso = filter["isSponso"]
- local IsFree = filter["isFree"]
- local EndPointNull = "https://agentbugr.glitch.me/listnull"
- local EndPointKey = "https://agentbugr.glitch.me/list/"
- local data
- local Game
- local DataToReturn = {
- ["placeId"] = 0,
- ["creatorId"] = 0,
- ["creatorName"] = 0,
- ["name"] = 0,
- ["playerCount"] = 0,
- ["totalUpVotes"] = 0,
- ["totalDownVotes"] = 0,
- ["VisitedCount"] = 0,
- ["Description"] = 0
- }
- local function niltoBool(value)
- if value == nil then
- return false
- else
- return true
- end
- end
- local Headers = {["Accept-Charset"] = "utf-8"}
- local s,m = pcall(function()
- if Keywords ~= nil and Keywords ~= "" then
- data = HttpService:GetAsync(EndPointKey..HttpService:UrlEncode(table.concat(Keywords," ")),false,Headers)
- else
- data = HttpService:GetAsync(EndPointNull,false,Headers)
- end
- data = HttpService:JSONDecode(data)["data"]["games"]
- Game = data[math.random(1,#data)]
- end)
- if s then
- if Game["isSponsored"] == IsSponso then
- if Game["price"] ~= nil then
- if Game["price"] == IsFree then
- for i,v in next,DataToReturn do
- DataToReturn[i] = Game[i]
- end
- local Details = HttpService:JSONDecode(HttpService:GetAsync("https://agentbugr.glitch.me/details/"..DataToReturn["placeId"],false,Headers))["data"]
- DataToReturn["Description"] = Details["Description"]
- DataToReturn["VisitedCount"] = Details["VisitedCount"]
- end
- else
- for i,v in next,DataToReturn do
- DataToReturn[i] = Game[i]
- end
- local Details = HttpService:JSONDecode(HttpService:GetAsync("https://agentbugr.glitch.me/details/"..DataToReturn["placeId"],false,Headers))["data"]
- DataToReturn["Description"] = Details["Description"]
- DataToReturn["VisitedCount"] = Details["VisitedCount"]
- end
- end
- return DataToReturn
- else
- print("Error : "..m)
- end
- end
Add Comment
Please, Sign In to add comment