– This part has been solved, for the most part.
So, im attempting (for fun and to learn) to make a game similar to pls donate, where players have stands where they can sell their created gamepasses.
I have a system which gets a users gamepasses that are for sale, but it is VERY slow, like 40 seconds loading time, which i dont want.
pls donate seems to have immediate loading of the gamepasses, and i was wondering how they do this, and how i could modify the script im using to be faster.
The code im using is a slightly modified version of the code in this post.
local http = game:GetService("HttpService")
local Gamepass_baseUrl = "https://www.roproxy.com/users/inventory/list-json?assetTypeId=34&cursor=&itemsPerPage=100&pageNumber=%s&userId=%s"
module.getUserCreatedGamepassesRecursive = function(userId, gamepasses, pageNumber, lastLength)
gamepasses = gamepasses or {}
pageNumber = pageNumber or 1
lastLength = lastLength or math.huge
local requestUrl = Gamepass_baseUrl:format(pageNumber, userId)
local success, result = pcall(function()
return http:GetAsync(requestUrl)
end)
if success and result then
local success2, result2 = pcall(function()
return http:JSONDecode(result)
end)
if success2 and result2 then
for _, gamepass in ipairs(result2.Data.Items) do
if gamepass.Creator.Id == userId then
table.insert(gamepasses, gamepass.Item.AssetId)
end
end
if result:len() ~= lastLength then
lastLength = result:len()
pageNumber += 1
module.getUserCreatedGamepassesRecursive(userId, gamepasses, pageNumber, lastLength)
end
else
warn(result)
module.getUserCreatedGamepassesRecursive(userId, gamepasses, pageNumber, lastLength)
end
else
warn(result)
module.getUserCreatedGamepassesRecursive(userId, gamepasses, pageNumber, lastLength)
end
-- Remove gamepasses that arent for sale (I think, i barely understand this myself)
for i, v in pairs(gamepasses) do
if not game:GetService('MarketplaceService'):GetProductInfo(v, Enum.InfoType.GamePass).IsForSale or not game:GetService('MarketplaceService'):GetProductInfo(v, Enum.InfoType.GamePass).CanBeSoldInThisGame then
table.remove(gamepasses, table.find(gamepasses, v))
end
end
return gamepasses
end
It would be good for me to mention this:
I did look at other posts on the devforum, searched youtube, but i couldnt find anything i could understand.
If you could possible avoid making posts like this and instead, explain the of everything so my stupid brain can figure it out, that would be greatly appreciated.
I have attempted to use the post i linked as a bad example of what to respond with, and i have gotten nowhere with it. Just errors or constant failing.
--Gets the games which i then get gamepasses from, there has to be a better way, right?
local Base_URL = 'https://games.roblox.com/v2/users/%7Bid%7D/games?accessFilter=Public&limit=50'
module.getUserCreatedGamepassesRecursive_V2 = function(Player)
-- what am i supposed to do here?
--I tried formatting the string, got an error: ServerScriptService.Gamepass_Functions:57: invalid option '%B' to 'format'
local requestUrl = '???'
-- am i even doing this right?
local success, result = pcall(function()
return http:GetAsync(requestUrl)
end)
if success and result then
return result
else
-- keeps returning false when it does work
return false
end
end
And now, here is the new problem.
With my code slightly modified, it is a lot faster now, but instead of displaying only gamepasses, the game is displaying everything the player owns or something like that.