Advertisement
Guest User

a

a guest
May 10th, 2017
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.19 KB | None | 0 0
  1.  
  2.  
  3.  
  4.  
  5. tableOfGamepassesAndTheirEffects = {}
  6.  
  7.  
  8. tableOfGamepassesAndTheirEffects[543274611]=(function(Player, loadedGamepassesForPlayer, Id)
  9. if loadedGamepassesForPlayer[Id]~= nil then print(Id, "Already loaded") return end --if you already successfully checked this gamepass id, dont check again
  10.  
  11.  
  12. if thisIsALobbyServer == false and marketplaceService:PlayerOwnsAsset(Player, Id) then --if the server is a game server(to avoid a worthless call) and the player also owns the gamepass,
  13. Instance.new("BoolValue", Player.GamepassesOwned).Name=Id --create the boolvalue so the client knows,
  14. playersTab[Player.Name].skinsOwned[tostring(Id)]=true --remember it in the table for future things
  15. end
  16. loadedGamepassesForPlayer[Id]=true --if no errors happened, the check was successful
  17. return loadedGamepassesForPlayer
  18. end)
  19.  
  20. --lot more gamepasses, but they all look the same
  21.  
  22.  
  23.  
  24.  
  25.  
  26.  
  27. function loadGamepassesForPlayer(Player, loadedGamepassesForPlayer)
  28. loadedGamepassesForPlayer = loadedGamepassesForPlayer or {} --if there's no table passed in, create an empty one
  29. local successfullyLoadedAllGamepasses = true
  30. for Id, v in pairs(tableOfGamepassesAndTheirEffects) do --scan through all the gamepass IDs and their functions
  31. local Success, errorMessage = pcall(function()
  32.  
  33. loadedGamepassesForPlayer = tableOfGamepassesAndTheirEffects[Id](Player, loadedGamepassesForPlayer, Id) or loadedGamepassesForPlayer -- run the function for that gamepass id and send the table of gamepasses that have been successfully checked
  34.  
  35. end)
  36.  
  37.  
  38. if Success ~= true then --if the function above failed for some reason, then not all gamepasses were successfully checked
  39. warn("Fail here", errorMessage)
  40. successfullyLoadedAllGamepasses = false -- loop through the table again
  41. end
  42.  
  43.  
  44. end
  45.  
  46.  
  47.  
  48.  
  49.  
  50. if successfullyLoadedAllGamepasses == false and Player~= nil and Player.Parent == Players then --if there were any errors last loop, and the player is still again, run through the list of gamepasses again
  51. wait(1)
  52. warn("Running load gamepasses func again")
  53. loadGamepassesForPlayer(Player, loadedGamepassesForPlayer)
  54. end
  55.  
  56.  
  57.  
  58.  
  59. print("Finished checking for gamepasses")
  60. return true
  61.  
  62.  
  63. end
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. loadGamepassesForPlayer(Player)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement