Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local AssetManager = {}
- local HttpService = game:GetService("HttpService")
- local NumbersHelper = require(game:GetService("ReplicatedStorage"):WaitForChild("Common"):WaitForChild("NumberHelpers"))
- local function handleRequestErrors(success, result, errorMessage)
- if not success then
- warn("Error in HTTP request:", errorMessage)
- return nil
- end
- local decodeSuccess, decodedResult = pcall(HttpService.JSONDecode, HttpService, result)
- if not decodeSuccess then
- warn("Error decoding JSON:", decodedResult)
- return nil
- end
- return decodedResult
- end
- local function getUserCreatedTShirts(username, SignPrices)
- local tshirts = {}
- local success, result = pcall(function()
- return HttpService:GetAsync("https://catalog.roproxy.com/v1/search/items/details?Category=3&CreatorName=" .. username)
- end)
- result = handleRequestErrors(success, result, "Failed to retrieve user-created T-shirts")
- if result then
- print("T-shirt data:", result)
- for _, item in pairs(result.data) do
- if item.price then
- table.insert(tshirts, item.id)
- local newBtn = script.Template:Clone()
- local price = item.price
- newBtn.PurchaseButton.Text = NumbersHelper.format(tonumber(price)) .. "\u{E002}"
- newBtn.LayoutOrder = price
- newBtn.Name = price
- newBtn.ImportantValues.AssetName.Value = item.name
- newBtn.ImportantValues.AssetId.Value = item.id
- newBtn.ImportantValues.AssetType.Value = "Clothing"
- newBtn.Parent = SignPrices
- end
- end
- end
- return tshirts
- end
- local function getUserCreatedGamepasses(userId, boothUI)
- local gamepasses = {}
- local GetGamesUrl = "https://games.roproxy.com/v2/users/"..userId.."/games?accessFilter=1&limit=50&sortOrder=Asc"
- local success, result = pcall(function()
- return HttpService:GetAsync(GetGamesUrl)
- end)
- result = handleRequestErrors(success, result, "Failed to retrieve user's games")
- if result and result.data then
- print("Game data:", result)
- for _, GameInfo in pairs(result.data) do
- local gameId = GameInfo.id
- local url = "https://games.roproxy.com/v1/games/"..gameId.."/game-passes?limit=100&sortOrder=Asc"
- local success2, result2 = pcall(function()
- return HttpService:GetAsync(url)
- end)
- result2 = handleRequestErrors(success2, result2, "Failed to retrieve game passes for game: "..gameId)
- if result2 and result2.data then
- print("Gamepass data for game "..gameId..":", result2)
- for _, GamepassDetail in pairs(result2.data) do
- if GamepassDetail.price then
- table.insert(gamepasses, GamepassDetail.id)
- local newBtn = script.Template:Clone()
- local price = GamepassDetail.price
- newBtn.Name = price
- newBtn.PurchaseButton.Text = NumbersHelper.format(tonumber(price)) .. "\u{E002}"
- newBtn.LayoutOrder = price
- newBtn.ImportantValues.AssetId.Value = GamepassDetail.id
- newBtn.ImportantValues.AssetName.Value = GamepassDetail.displayName
- newBtn.ImportantValues.AssetType.Value = "Gamepass"
- newBtn.Parent = boothUI
- end
- end
- end
- end
- end
- return gamepasses
- end
- function AssetManager:GetAssets(Player, BoothUI)
- getUserCreatedTShirts(Player.Name, BoothUI)
- getUserCreatedGamepasses(Player.UserId, BoothUI)
- end
- function AssetManager:GetAssetsGift(PlayerName, PlayerUserId, BoothUI)
- getUserCreatedTShirts(PlayerName, BoothUI)
- getUserCreatedGamepasses(PlayerUserId, BoothUI)
- end
- return AssetManager
Advertisement
Add Comment
Please, Sign In to add comment