Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local DataStoreService = game:GetService('DataStoreService')
- local MarketplaceService = game:GetService('MarketplaceService')
- local DataStore = DataStoreService:GetDataStore('BLOXVIP', 1)
- local Gamepasses = {
- ['Outside Eating'] = 4690786;
- ['Premium Lounge'] = 4690829;
- ['Golden Name'] = 4691572;
- }
- local DeveloperProducts = {
- [517458124] = 60 *60 *24 *30.42 *1; -- 1 month
- [517457979] = 60 *60 *24 *30.42 *3; -- 3 month
- [517458058] = 60 *60 *24 *30.42 *6; -- 6 month
- [517458171] = 60 *60 *24 *30.42 *12; -- 1 year
- }
- for i,v in pairs(DeveloperProducts) do
- print(i, v)
- end
- local function CreateFolder(Name, Parent)
- local NewFolder = Instance.new('Folder')
- NewFolder.Name = Name
- NewFolder.Parent = Parent
- end
- game.Players.PlayerAdded:Connect(function(plr)
- local GamepassFolder = Instance.new('Folder')
- GamepassFolder.Name = 'GamepassesOwned'
- GamepassFolder.Parent = plr
- for GamepassName, GamepassId in pairs(Gamepasses) do
- if MarketplaceService:UserOwnsGamePassAsync(plr.UserId, GamepassId) then
- CreateFolder(GamepassName, GamepassFolder)
- end
- end
- local SUCC, PAST_TRANSACTION_TIME = pcall(DataStore.GetAsync, DataStore, plr.UserId)
- if SUCC then
- if PAST_TRANSACTION_TIME then
- if os.time()>PAST_TRANSACTION_TIME then
- pcall(DataStore.RemoveAsync, DataStore, plr.UserId)
- else
- print('PLAYER: '..plr.Name..' STILL HAS '..PAST_TRANSACTION_TIME-os.time()..' SECONDS LEFT')
- for GamepassName, GamepassId in pairs(Gamepasses) do
- CreateFolder(GamepassName, GamepassFolder)
- end
- end
- end
- else
- warn('FATAL DATASTORE ERROR: '..PAST_TRANSACTION_TIME)
- end
- end)
- MarketplaceService.ProcessReceipt = function(receiptInfo)
- local PlayerId = receiptInfo['PlayerId']
- local productId = receiptInfo['ProductId']
- local Player
- for _, GamePlayer in pairs(game.Players:GetPlayers()) do
- if GamePlayer.UserId == PlayerId then
- print('Found '..GamePlayer.Name)
- Player = GamePlayer
- end
- end
- if Player then
- for ProductId, ProductLength in pairs(DeveloperProducts) do
- if ProductId == productId then
- -- Player purchased this
- DataStore:UpdateAsync(PlayerId, function(oldVal)
- return oldVal and oldVal + ProductLength or os.time() + ProductLength
- end)
- print('ADDED '..ProductLength..' TO THE PLAYER')
- for GamepassName, GamepassId in pairs(Gamepasses) do
- if not Player.GamepassesOwned:FindFirstChild(GamepassName) then
- CreateFolder(GamepassName, Player.GamepassesOwned)
- end
- end
- return Enum.ProductPurchaseDecision.PurchaseGranted
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement