devTools
|
  |
| Joined: 06 Sep 2014 |
| Total Posts: 7950 |
|
|
| 22 Jul 2015 03:17 PM |
Basically I am trying to make it where you can buy this devProduct and then it will make you the DJ or put you in line for it, but only once. Right now when I join the server, it makes me DJ automatically even though I didn't purchase it in that specific server.
function FindPlayer(id) local players = game.Players:GetChildren() for i = 1, #players do if players[i].userId == id then return players[i] end end return nil end
local MarketplaceService = game:GetService("MarketplaceService") local ds = game:GetService("DataStoreService"):GetDataStore("PurchaseHistory")
MarketplaceService.ProcessReceipt = function(receiptInfo) if Enum.ProductPurchaseDecision.PurchaseGranted and receiptInfo.ProductId == devId then if FindPlayer(receiptInfo.PlayerId) ~= nil then local p = FindPlayer(receiptInfo.PlayerId) local dj = ds:GetAsync(receiptInfo.PlayerId .. " " .. receiptInfo.PurchaseId) or 0 if dj ~= receiptInfo.PurchaseId then table.insert(signedUp,#signedUp+1,p) ds:SetAsync(receiptInfo.PlayerId .. " " .. receiptInfo.PurchaseId, receiptInfo.PurchaseId) end end end end
| devTools || Sky Admiral of The Sky Clan of ROBLOX | |
|
|
| Report Abuse |
|
|
devTools
|
  |
| Joined: 06 Sep 2014 |
| Total Posts: 7950 |
|
|
| 22 Jul 2015 03:18 PM |
And yes, I have another script where it prompts them to buy the devProduct. All I am looking for is how to save the purchaseId for that server and in the next server, make sure that the purchaseId isn't the same as the one from the previous server.
| devTools || Sky Admiral of The Sky Clan of ROBLOX | |
|
|
| Report Abuse |
|
|
devTools
|
  |
| Joined: 06 Sep 2014 |
| Total Posts: 7950 |
|
|
| 22 Jul 2015 03:31 PM |
Bump Please help :)
| devTools || Sky Admiral of The Sky Clan of ROBLOX | |
|
|
| Report Abuse |
|
|
devTools
|
  |
| Joined: 06 Sep 2014 |
| Total Posts: 7950 |
|
|
| 22 Jul 2015 03:39 PM |
bump
| devTools || Sky Admiral of The Sky Clan of ROBLOX | |
|
|
| Report Abuse |
|
|
devTools
|
  |
| Joined: 06 Sep 2014 |
| Total Posts: 7950 |
|
|
| 22 Jul 2015 03:45 PM |
bumpp
| devTools || Sky Admiral of The Sky Clan of ROBLOX | |
|
|
| Report Abuse |
|
|
|
| 22 Jul 2015 04:02 PM |
| Why save it if it's just for once |
|
|
| Report Abuse |
|
|
devTools
|
  |
| Joined: 06 Sep 2014 |
| Total Posts: 7950 |
|
|
| 22 Jul 2015 04:46 PM |
Because when I join the server, the if statement detects that I already bought that product so it adds me to the list right away. I need it to compare the current server's purchase to the last saved purchase so it doesn't automatically put them in.
|devTools| |
|
|
| Report Abuse |
|
|
devTools
|
  |
| Joined: 06 Sep 2014 |
| Total Posts: 7950 |
|
|
| 22 Jul 2015 05:25 PM |
bump Any other ways to do this? |
|
|
| Report Abuse |
|
|
devTools
|
  |
| Joined: 06 Sep 2014 |
| Total Posts: 7950 |
|
| |
|
devTools
|
  |
| Joined: 06 Sep 2014 |
| Total Posts: 7950 |
|
| |
|
|
| 22 Jul 2015 06:17 PM |
local assetId = 00000
local marketplaceService = game:GetService("MarketplaceService") local djStore = game:GetService("DataStoreService"):GetDataStore("DjPurchaseHistory")
local Dj = {}
--TODO: Implement this function --And handle making players DJ function Dj:SignUp(player, purchases) if self.CurrentDj == nil then self.CurrentDj = player end end
function playerAdded(player) local djPurchases = djStore:GetAsync(player.userId) or 0 if djPurchases > 0 then Dj:SignUp(player, djPurchases) end end
function processPurchase(receiptInfo) local player = game.Players:GetPlayerByUserId(receiptInfo.PlayerId) if player then if receiptInfo.ProductId == assetId then local totalPurchases = 0 djStore:UpdateAsync(player.userId, function(oldValue) oldValue = oldValue or 0 local newValue = oldValue + 1 totalPurchases = newValue return newValue end) Dj:SignUp(player, totalPurchases) return Enum.ProductPurchaseDecision.PurchaseGranted end end return Enum.ProductPurchaseDecision.NotProcessedYet end
marketplaceService.ProcessReceipt = processPurchase game.Players.PlayerAdded:connect(playerAdded) |
|
|
| Report Abuse |
|
|
devTools
|
  |
| Joined: 06 Sep 2014 |
| Total Posts: 7950 |
|
|
| 22 Jul 2015 06:23 PM |
hm ill have to tinker with this when I get home, but thanks!
|devTools| |
|
|
| Report Abuse |
|
|
devTools
|
  |
| Joined: 06 Sep 2014 |
| Total Posts: 7950 |
|
|
| 22 Jul 2015 10:45 PM |
Bump That's a bit too complex for me to understand lol, I'm only intermediate and rather new with datastores. Could someone just show me how to have it save the purchaseid for the next time they do it so it checks if it is the current purchase rather than the last one or from a previous server?
| devTools || Sky Admiral of The Sky Clan of ROBLOX | |
|
|
| Report Abuse |
|
|
|
| 22 Jul 2015 10:48 PM |
http://wiki.roblox.com/index.php?title=API:Class/Players/GetPlayerByUserId This link trumps your function
if Enum.ProductPurchaseDecision.PurchaseGranted and receiptInfo.ProductId == devId then This is your problem I think |
|
|
| Report Abuse |
|
|
devTools
|
  |
| Joined: 06 Sep 2014 |
| Total Posts: 7950 |
|
|
| 22 Jul 2015 11:13 PM |
@cody o thanks, it's working fine now :D
| devTools || Sky Admiral of The Sky Clan of ROBLOX | |
|
|
| Report Abuse |
|
|