Upscalefanatic3

(Roblox) Place Roulette Script

Feb 27th, 2020
242
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.58 KB | None | 0 0
  1. local HttpService = game:GetService("HttpService")
  2.  
  3.  
  4. function GetRandomGame(filter)
  5.     --if not HttpService.HttpEnabled then print("You must activate the HttpService !") return false end
  6.    
  7.     local Keywords = filter["keywords"]
  8.     local IsSponso = filter["isSponso"]
  9.     local IsFree = filter["isFree"]
  10.     local EndPointNull = "https://agentbugr.glitch.me/listnull"
  11.     local EndPointKey = "https://agentbugr.glitch.me/list/"
  12.    
  13.     local data
  14.     local Game
  15.     local DataToReturn = {
  16.         ["placeId"] = 0,
  17.         ["creatorId"] = 0,
  18.         ["creatorName"] = 0,
  19.         ["name"] = 0,
  20.         ["playerCount"] = 0,
  21.         ["totalUpVotes"] = 0,
  22.         ["totalDownVotes"] = 0,
  23.         ["VisitedCount"] = 0,
  24.         ["Description"] = 0
  25.     }
  26.    
  27.         local function niltoBool(value)
  28.             if value == nil then
  29.                 return false
  30.             else
  31.                 return true
  32.             end
  33.         end
  34.    
  35.     local Headers = {["Accept-Charset"] = "utf-8"}
  36.    
  37.     local s,m = pcall(function()
  38.         if Keywords ~= nil and Keywords ~= "" then
  39.             data = HttpService:GetAsync(EndPointKey..HttpService:UrlEncode(table.concat(Keywords," ")),false,Headers)
  40.         else
  41.             data = HttpService:GetAsync(EndPointNull,false,Headers)
  42.         end
  43.        
  44.         data = HttpService:JSONDecode(data)["data"]["games"]
  45.         Game = data[math.random(1,#data)]
  46.         end)
  47.        
  48.         if s then
  49.             if Game["isSponsored"] == IsSponso then
  50.                 if Game["price"] ~= nil then
  51.                     if Game["price"] == IsFree then
  52.                         for i,v in next,DataToReturn do
  53.                             DataToReturn[i] = Game[i]
  54.                         end
  55.                         local Details = HttpService:JSONDecode(HttpService:GetAsync("https://agentbugr.glitch.me/details/"..DataToReturn["placeId"],false,Headers))["data"]
  56.                         DataToReturn["Description"] = Details["Description"]
  57.                         DataToReturn["VisitedCount"] = Details["VisitedCount"]
  58.                     end
  59.                 else
  60.                     for i,v in next,DataToReturn do
  61.                         DataToReturn[i] = Game[i]
  62.                     end
  63.                         local Details = HttpService:JSONDecode(HttpService:GetAsync("https://agentbugr.glitch.me/details/"..DataToReturn["placeId"],false,Headers))["data"]
  64.                         DataToReturn["Description"] = Details["Description"]
  65.                         DataToReturn["VisitedCount"] = Details["VisitedCount"]
  66.                 end
  67.             end
  68.             return DataToReturn
  69.         else
  70.             print("Error : "..m)
  71.         end
  72. end
Add Comment
Please, Sign In to add comment