SHARE
TWEET

Untitled

a guest Apr 19th, 2019 155 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local DataStoreService = game:GetService('DataStoreService')
  2. local MarketplaceService = game:GetService('MarketplaceService')
  3.  
  4. local DataStore = DataStoreService:GetDataStore('BLOXVIP', 1)
  5.  
  6. local Gamepasses = {
  7.     ['Outside Eating'] = 4690786;
  8.     ['Premium Lounge'] = 4690829;
  9.     ['Golden Name'] = 4691572;
  10. }
  11.  
  12. local DeveloperProducts = {
  13.     [517458124] = 60        *60     *24     *30.42      *1; -- 1 month
  14.     [517457979] = 60        *60     *24     *30.42      *3; -- 3 month
  15.     [517458058] = 60        *60     *24     *30.42      *6; -- 6 month
  16.     [517458171] = 60        *60     *24     *30.42      *12; -- 1 year
  17. }
  18.  
  19. for i,v in pairs(DeveloperProducts) do
  20.     print(i, v)
  21. end
  22.  
  23.  
  24. local function CreateFolder(Name, Parent)
  25.     local NewFolder = Instance.new('Folder')
  26.     NewFolder.Name = Name
  27.     NewFolder.Parent = Parent
  28. end
  29.  
  30. game.Players.PlayerAdded:Connect(function(plr)
  31.     local GamepassFolder = Instance.new('Folder')
  32.     GamepassFolder.Name = 'GamepassesOwned'
  33.     GamepassFolder.Parent = plr
  34.    
  35.     for GamepassName, GamepassId in pairs(Gamepasses) do
  36.         if MarketplaceService:UserOwnsGamePassAsync(plr.UserId, GamepassId) then
  37.             CreateFolder(GamepassName, GamepassFolder)
  38.         end
  39.     end
  40.    
  41.     local SUCC, PAST_TRANSACTION_TIME = pcall(DataStore.GetAsync, DataStore, plr.UserId)
  42.    
  43.     if SUCC then
  44.         if PAST_TRANSACTION_TIME then
  45.             if os.time()>PAST_TRANSACTION_TIME then
  46.                 pcall(DataStore.RemoveAsync, DataStore, plr.UserId)
  47.             else
  48.                 print('PLAYER: '..plr.Name..' STILL HAS '..PAST_TRANSACTION_TIME-os.time()..' SECONDS LEFT')
  49.                 for GamepassName, GamepassId in pairs(Gamepasses) do
  50.                     CreateFolder(GamepassName, GamepassFolder)
  51.                 end
  52.             end
  53.         end
  54.     else
  55.         warn('FATAL DATASTORE ERROR: '..PAST_TRANSACTION_TIME)
  56.     end
  57. end)
  58.  
  59. MarketplaceService.ProcessReceipt = function(receiptInfo)
  60.     local PlayerId = receiptInfo['PlayerId']
  61.     local productId = receiptInfo['ProductId']
  62.    
  63.     local Player
  64.     for _, GamePlayer in pairs(game.Players:GetPlayers()) do
  65.         if GamePlayer.UserId == PlayerId then
  66.             print('Found '..GamePlayer.Name)
  67.             Player = GamePlayer
  68.         end
  69.     end
  70.    
  71.     if Player then
  72.         for ProductId, ProductLength in pairs(DeveloperProducts) do
  73.             if ProductId == productId then
  74.                 -- Player purchased this
  75.                 DataStore:UpdateAsync(PlayerId, function(oldVal)
  76.                     return oldVal and oldVal + ProductLength or os.time() + ProductLength
  77.                 end)
  78.                
  79.                 print('ADDED '..ProductLength..' TO THE PLAYER')
  80.                
  81.                 for GamepassName, GamepassId in pairs(Gamepasses) do
  82.                     if not Player.GamepassesOwned:FindFirstChild(GamepassName) then
  83.                         CreateFolder(GamepassName, Player.GamepassesOwned)
  84.                     end
  85.                 end
  86.                
  87.                 return Enum.ProductPurchaseDecision.PurchaseGranted
  88.             end
  89.         end
  90.     end
  91. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top