for getting the gamepasses and catalog assets that a player has created.
local https = game:GetService("HttpService")
return function(plr)
local ALL = {}
local plrname = plr.Name
local userid = plr.UserId
local tshirturl = "https://catalog.roproxy.com/v1/search/items/details?Category=3&Subcategory=55&CreatorName="..plrname.."&salesTypeFilter=1&SortType=3"
local shirturl = "https://catalog.roproxy.com/v1/search/items/details?Category=3&Subcategory=56&CreatorName="..plrname.."&salesTypeFilter=1&SortType=3"
local panturl = "https://catalog.roproxy.com/v1/search/items/details?Category=3&Subcategory=57&CreatorName="..plrname.."&salesTypeFilter=1&SortType=3"
local loaded = 0
spawn(function()
print("Get")
local response = https:GetAsync(tshirturl)
warn(tshirturl)
local data = https:JSONDecode(response)
local items = data["data"]
for i,v in ipairs(items) do
if v["price"] then
if v["price"] > 0 then
table.insert(ALL, {v["id"],v["price"],false})
end
end
end
loaded += 1
end)
spawn(function()
print("Get")
local response = https:GetAsync(shirturl)
warn(shirturl)
local data = https:JSONDecode(response)
local items = data["data"]
for i,v in ipairs(items) do
if v["price"] then
if v["price"] > 0 then
table.insert(ALL, {v["id"],v["price"],false})
end
end
end
loaded += 1
end)
spawn(function()
print("Get")
local response = https:GetAsync(panturl)
warn(panturl)
local data = https:JSONDecode(response)
local items = data["data"]
for i,v in ipairs(items) do
if v["price"] then
if v["price"] > 0 then
table.insert(ALL, {v["id"],v["price"],false})
end
end
end
loaded += 1
end)
spawn(function() --gamepasses
local games = {}
local gameurl = "https://games.roproxy.com/v2/users/"..userid.."/games?accessFilter=2&limit=50&sortOrder=Desc"
local cur = ""
while true do
print("Get")
local response = https:GetAsync(gameurl.."&cursor="..cur)
warn(gameurl.."&cursor="..cur)
local data = https:JSONDecode(response)
local items = data["data"]
local cur = data["nextPageCursor"]
for i,v in ipairs(items) do
table.insert(games,v["id"])
end
if not cur then
break
end
end
local w = 0
for i,v in ipairs(games) do
spawn(function()
local url = "https://games.roproxy.com/v1/games/"..v.."/game-passes?limit=100&sortOrder=Asc"
print("Get")
local response = https:GetAsync(url)
warn(url)
local data = https:JSONDecode(response)
local items = data["data"]
for i,v in ipairs(items) do
if v["price"] then
table.insert(ALL, {v["id"],v["price"],true})
end
end
w += 1
end)
end
while w ~= #games do
task.wait()
end
loaded += 1
end)
while loaded ~= 4 do
task.wait()
end
return ALL
end
For handling purchases and preventing exploits where people change the price right before buying to exploit there donation amounts
local module = {}
local c = {}
-- gamepasses
function module.PromptGamepassPurchase(plr,id) --returns the robux spent when the purchase has finsihed, if the player didnt purchase it returns nil
if game:GetService("RunService"):IsClient() then
error("you must use DonationGameService from the server!")
end
if table.find(c,plr) then
warn("already open")
return
end
table.insert(c,plr)
local prices = {}
local processing = true
local toreturn = nil
spawn(function()
while processing do
local price = game:GetService("MarketplaceService"):GetProductInfo(id,Enum.InfoType.GamePass)["PriceInRobux"]
table.insert(prices,price)
--print(price)
task.wait(0.5)
end
end)
game:GetService("MarketplaceService"):PromptGamePassPurchase(plr,id)
local a = game:GetService("MarketplaceService").PromptGamePassPurchaseFinished:Connect(function(plr1,finalid,wasbought)
if plr1 ~= plr then
return
end
if not wasbought then
processing = false
table.remove(c,table.find(c,plr))
return
end
if finalid ~= id then
return
end
local didchange = false
local pricetheyspent
for i,v in ipairs(prices) do
for i,v1 in ipairs(prices) do
if v ~= v1 then
didchange = true
end
end
end
if didchange then
local lowest = math.huge
for i,v in ipairs(prices) do
if lowest > v then
lowest = v
end
end
pricetheyspent = lowest
else
pricetheyspent = prices[1]
end
processing = false
toreturn = pricetheyspent
end)
while processing do
wait()
end
table.remove(c,table.find(c,plr))
a:Disconnect()
return toreturn
end
--eg shirts, pants, tshirts
function module.PromptAssetPurchase(plr,id) --returns the robux spent when the purchase has finsihed, if the player didnt purchase it returns nil
if game:GetService("RunService"):IsClient() then
error("you must use DonationGameService from the server!")
end
if table.find(c,plr) then
warn("already open")
return
end
table.insert(c,plr)
local prices = {}
local processing = true
local toreturn = nil
spawn(function()
while processing do
local price = game:GetService("MarketplaceService"):GetProductInfo(id,Enum.InfoType.Asset)["PriceInRobux"]
table.insert(prices,price)
--print(price)
task.wait(0.5)
end
end)
game:GetService("MarketplaceService"):PromptPurchase(plr,id)
local a = game:GetService("MarketplaceService").PromptPurchaseFinished:Connect(function(plr1,finalid,wasbought)
if plr1 ~= plr then
return
end
if not wasbought then
processing = false
table.remove(c,table.find(c,plr))
return
end
if finalid ~= id then
return
end
local didchange = false
local pricetheyspent
for i,v in ipairs(prices) do
for i,v1 in ipairs(prices) do
if v ~= v1 then
didchange = true
end
end
end
if didchange then
local lowest = math.huge
for i,v in ipairs(prices) do
if lowest > v then
lowest = v
end
end
pricetheyspent = lowest
else
pricetheyspent = prices[1]
end
processing = false
toreturn = pricetheyspent
end)
while processing do
wait()
end
table.remove(c,table.find(c,plr))
a:Disconnect()
return toreturn
end
return module