Advertisement
qsenko1

AssetManager

Jun 2nd, 2022
772
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.64 KB | None | 0 0
  1. local AssetManager = {}
  2.  
  3. local HttpService = game:GetService("HttpService")
  4. local UrlA = "https://catalog.roproxy.com/v1/search/items/details?Category=3&CreatorName="
  5.  
  6. local function getUserGeneratedTShirtsRecursive(username, SignPrices, tshirts, cursor)
  7.     tshirts = tshirts or {}
  8.     local requestUrl = UrlA
  9.     local data = HttpService:JSONDecode(HttpService:GetAsync(UrlA .. username)).data
  10.     if data then
  11.         table.sort(data,
  12.             function(a,b)
  13.                 return a.price < b.price
  14.             end
  15.         )
  16.         for _, item in ipairs(data) do
  17.             local e,s = pcall(function()
  18.                 table.insert(tshirts, item.id)
  19.                 local newBtn = script.Template:Clone()
  20.                 local price = item.price
  21.                 newBtn.PurchaseButton.Text = "$"..price
  22.                 newBtn.LayoutOrder = price
  23.                 newBtn.Name = price
  24.                 newBtn.ImportantValues.AssetId.Value = item.id
  25.                 newBtn.Parent = SignPrices
  26.  
  27.             end)
  28.         end
  29.     end
  30.     return tshirts
  31. end
  32.  
  33. local UrlB = "https://www.roproxy.com/users/inventory/list-json?assetTypeId=34&cursor=&itemsPerPage=100&pageNumber=%s&userId=%s"
  34.  
  35. local function getUserCreatedGamepassesRecursive(userId, SignPrices, gamepasses, pageNumber, lastLength)
  36.     gamepasses = {}
  37.     pageNumber = pageNumber or 1
  38.     lastLength = lastLength or math.huge
  39.  
  40.     local requestUrl = UrlB:format(pageNumber, userId)
  41.     local success, result = pcall(function()
  42.         return HttpService:GetAsync(requestUrl)
  43.     end)
  44.  
  45.     if success then
  46.         if result then
  47.             local success2, result2 = pcall(function()
  48.                 return HttpService:JSONDecode(result)
  49.             end)
  50.  
  51.             if success2 then
  52.                 if result2 then
  53.                     for _, gamepass in ipairs(result2.Data.Items) do
  54.                         if gamepass.Creator.Id == userId and table.find(gamepasses, gamepass.Item.AssetId) == nil then
  55.                             table.insert(gamepasses, gamepass.Item.AssetId)
  56.                             local e,s = pcall(function()
  57.  
  58.                                 local newBtn = script.Template:Clone()
  59.                                 local price = gamepass.Product.PriceInRobux
  60.                                 newBtn.Name = price
  61.                                 newBtn.PurchaseButton.Text = "$"..price
  62.                                 newBtn.LayoutOrder = price
  63.                                 newBtn.ImportantValues.AssetId.Value = gamepass.Item.AssetId
  64.                                 newBtn.ImportantValues.AssetType.Value = "Gamepass"
  65.                                 newBtn.Parent = SignPrices
  66.                             end)
  67.                         end
  68.                     end
  69.                 else
  70.                     warn(result)
  71.                     getUserCreatedGamepassesRecursive(userId, gamepasses, pageNumber, lastLength)
  72.                 end
  73.             end
  74.         else
  75.             warn(result)
  76.             getUserCreatedGamepassesRecursive(userId, gamepasses, pageNumber, lastLength)
  77.         end
  78.         return gamepasses
  79.     end
  80. end
  81.  
  82.  
  83. function AssetManager:GetAssets(Player, BoothUI)
  84.     getUserGeneratedTShirtsRecursive(Player.Name, BoothUI)
  85.     getUserCreatedGamepassesRecursive(Player.UserId, BoothUI)
  86. end
  87.  
  88. return AssetManager
  89.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement