Skip to content
This repository has been archived by the owner on Jul 28, 2022. It is now read-only.

Commit

Permalink
Add 'OwnsGamePass' method for StoreService
Browse files Browse the repository at this point in the history
  • Loading branch information
Sleitnick committed Apr 20, 2019
1 parent ced783c commit 143dc50
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/ServerStorage/Aero/Services/StoreService.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
Server:
StoreService:HasPurchased(player, productId)
StoreService:OwnsGamePass(player, gamePassId)
StoreService:GetNumberPurchased(player, productId)
StoreService.PromptPurchaseFinished(player, receiptInfo)
Expand All @@ -18,6 +19,7 @@
Client:
StoreService:HasPurchased(productId)
StoreService:OwnsGamePass(gamePassId)
StoreService:GetNumberPurchased(productId)
StoreService.PromptPurchaseFinished(receiptInfo)
Expand All @@ -39,7 +41,7 @@ local dataStoreScope = "PlayerReceipts"
local services


function IncrementPurchase(player, productId)
local function IncrementPurchase(player, productId)
productId = tostring(productId)
local productPurchases = services.DataService:Get(player, PRODUCT_PURCHASES_KEY)
if (not productPurchases) then
Expand All @@ -52,7 +54,7 @@ function IncrementPurchase(player, productId)
end


function ProcessReceipt(receiptInfo)
local function ProcessReceipt(receiptInfo)

--[[
ReceiptInfo:
Expand Down Expand Up @@ -95,6 +97,14 @@ function StoreService:HasPurchased(player, productId)
end


function StoreService:OwnsGamePass(player, gamePassId)
local success, owns = pcall(function()
return marketplaceService:UserOwnsGamePassAsync(player.UserId, gamePassId)
end)
return (success and owns or false)
end


-- Get the number of productId's purchased:
function StoreService:GetNumberPurchased(player, productId)
local n = 0
Expand All @@ -112,6 +122,11 @@ function StoreService.Client:GetNumberPurchased(player, productId)
end


function StoreService.Client:OwnsGamePass(player, gamePassId)
return self.Server:OwnsGamePass(player, gamePassId)
end


-- Whether or not the productId has been purchased before:
function StoreService.Client:HasPurchased(player, productId)
return self.Server:HasPurchased(player, productId)
Expand Down

0 comments on commit 143dc50

Please sign in to comment.