|
| 20 Jul 2015 02:20 PM |
local MarketplaceService = game:GetService("MarketplaceService")
local cheese = { [25018505] = 10, [25018519] = 50, [24973222] = 150, [24973311] = 2500 }
MarketplaceService.ProcessReceipt = function(receiptInfo) for i, player in ipairs(game.Players:GetPlayers()) do if player.userId == receiptInfo.PlayerId then for n,o in pairs(cheese)do if(receiptInfo.ProductId==n)then player.leaderstats.Gold.Value = player.leaderstats.Gold.Value + cheese end break end end end end return Enum.ProductPurchaseDecision.PurchaseGranted end
idk where I'm going wrong qq |
|
|
| Report Abuse |
|
|
AlgyLacey
|
  |
| Joined: 14 Jun 2013 |
| Total Posts: 3736 |
|
|
| 20 Jul 2015 02:22 PM |
player.leaderstats.Gold.Value = player.leaderstats.Gold.Value + o
{-[ Check this out! http://www.roblox.com/games/217210581/Farmulator ]-} |
|
|
| Report Abuse |
|
|
|
| 20 Jul 2015 02:28 PM |
| can't even test it now as for some reason my DevProducts have broken.. |
|
|
| Report Abuse |
|
|
|
| 20 Jul 2015 02:47 PM |
| Nope, that doesn't seem to work :/ |
|
|
| Report Abuse |
|
|
|
| 20 Jul 2015 03:22 PM |
local marketplaceService = game:GetService("MarketplaceService")
local products = { [25018505] = 10, [25018519] = 50, [24973222] = 150, [24973311] = 2500 }
local rewarded = {} marketplaceService.ProcessReceipt = function(receiptInfo) if rewarded[receiptInfo.PurchaseId] then return Enum.ProductPurchaseDecision.PurchaseGranted end local player = game.Players:GetPlayerByUserId(receiptInfo.PlayerId) local productReward = products[receiptInfo.ProductId] if not productReward then warn("No product reward is defined for: " .. receiptInfo.ProductId) return Enum.ProductPurchaseDecision.NotProcessedYet end local stat = player and player:FindFirstChild("leaderstats") and player.leaderstats:FindFirstChild("Gold") if stat then stat.Value = stat.Value + productReward rewarded[receiptInfo.PurchaseId] = true return Enum.ProductPurchaseDecision.PurchaseGranted end return Enum.ProductPurchaseDecision.NotProcessedYet end |
|
|
| Report Abuse |
|
|
|
| 21 Jul 2015 04:21 AM |
| still no luck with that :/ |
|
|
| Report Abuse |
|
|
AlgyLacey
|
  |
| Joined: 14 Jun 2013 |
| Total Posts: 3736 |
|
|
| 21 Jul 2015 04:47 AM |
What are you trying to do?
{-[ Check this out! http://www.roblox.com/games/217210581/Farmulator ]-} |
|
|
| Report Abuse |
|
|
|
| 21 Jul 2015 05:02 AM |
| Make it so that when someone buys any of those DevProducts ingame they're credited the corresponding amount of ingame Gold |
|
|
| Report Abuse |
|
|
AlgyLacey
|
  |
| Joined: 14 Jun 2013 |
| Total Posts: 3736 |
|
|
| 21 Jul 2015 05:25 AM |
And it's not awarding anything?
Try this, and see what it prints:
local MarketplaceService = game:GetService("MarketplaceService")
local cheese = { [25018505] = 10, [25018519] = 50, [24973222] = 150, [24973311] = 2500 }
MarketplaceService.ProcessReceipt = function(receiptInfo) for i, player in ipairs(game.Players:GetPlayers()) do if player.userId == receiptInfo.PlayerId then print "Is the player" for n,o in pairs(cheese)do if(receiptInfo.ProductId==n)then print "Found it" player.leaderstats.Gold.Value = player.leaderstats.Gold.Value + o print "Awarded" end break end end end end return Enum.ProductPurchaseDecision.PurchaseGranted end
{-[ Check this out! http://www.roblox.com/games/217210581/Farmulator ]-} |
|
|
| Report Abuse |
|
|
Tycooons
|
  |
| Joined: 13 Aug 2014 |
| Total Posts: 5871 |
|
|
| 21 Jul 2015 05:33 AM |
You need to change the n to o if(receiptInfo.ProductId==n)then
n just represents the index of it |
|
|
| Report Abuse |
|
|
|
| 21 Jul 2015 07:31 AM |
@Algy, yeah it's not awarding anything still :U
@tycoons, are you sure about that? the script below works fine with n there..
local MarketplaceService = game:GetService("MarketplaceService")
local gear = { [24976504] = game.ServerStorage.DualDarkhearts, [24976616] = game.ServerStorage.HealingPotion, [24976698] = game.ServerStorage.BasicStaff }
MarketplaceService.ProcessReceipt = function(receiptInfo) for i, player in ipairs(game.Players:GetPlayers()) do if player.userId == receiptInfo.PlayerId then for n,o in pairs(gear)do if(receiptInfo.ProductId==n)then if(not player.StarterGear:FindFirstChild(o.Name))then o:clone().Parent = player.Backpack o:clone().Parent = player.StarterGear end break end end end end return Enum.ProductPurchaseDecision.PurchaseGranted end
|
|
|
| Report Abuse |
|
|
sd10099
|
  |
| Joined: 13 Sep 2011 |
| Total Posts: 12804 |
|
| |
|
AlgyLacey
|
  |
| Joined: 14 Jun 2013 |
| Total Posts: 3736 |
|
|
| 21 Jul 2015 07:46 AM |
@Tycoons, in a standard table it would be:
Table = {1="a", 2="b"} But you don't see the numbers, that's why you can go print(Table[1]) That's why the "i" in "for i,v in pairs" prints a number.
In this table, which is a 'dictionary':
Table = {"Number1" = a, "Number2" = b} you can do print (Table[1]) and print (Table["Number1"])
So if you do this:
for i,v in pairs (Table) do print(i,v) end
it would print: "Number1 a"
(I may have told you something you already know. :))
{-[ Check this out! http://www.roblox.com/games/217210581/Farmulator ]-} |
|
|
| Report Abuse |
|
|
|
| 21 Jul 2015 07:46 AM |
| http://wiki.roblox.com/index.php?title=Function_dump/Basic_functions#ipairs |
|
|
| Report Abuse |
|
|
|
| 21 Jul 2015 07:46 AM |
straight from the wiki:
Returns three values: an iterator function, the table t, and 0, so that the construction
for i,v in ipairs(t) do --body end will iterate over the pairs (1,t[1]), (2,t[2]), ···, up to the first integer key absent from the table.
t = {'a', 'b', 'c', nil, 'd'} for i,v in ipairs(t) do print(i, v) end |
|
|
| Report Abuse |
|
|
AlgyLacey
|
  |
| Joined: 14 Jun 2013 |
| Total Posts: 3736 |
|
|
| 21 Jul 2015 07:48 AM |
@sd, you can do "in pairs", "in ipairs" and "in next"
http://wiki.roblox.com/index.php?title=Generic_for
Also, thanks for funding the problem. Bill, use in pairs instead of ipairs.
ipairs counts up in integers, which is why it's breaking.
{-[ Check this out! http://www.roblox.com/games/217210581/Farmulator ]-} |
|
|
| Report Abuse |
|
|
sd10099
|
  |
| Joined: 13 Sep 2011 |
| Total Posts: 12804 |
|
|
| 21 Jul 2015 07:50 AM |
| I have no idea what that does still i can't script that well |
|
|
| Report Abuse |
|
|
Tycooons
|
  |
| Joined: 13 Aug 2014 |
| Total Posts: 5871 |
|
|
| 21 Jul 2015 07:51 AM |
got it to work
local MarketplaceService = game:GetService("MarketplaceService")
local cheese = { [25018505] = 10, [25018519] = 50, [24973222] = 150, [24973311] = 2500 }
MarketplaceService.ProcessReceipt = function(receiptInfo) for i, player in ipairs(game.Players:GetPlayers()) do if player.userId == receiptInfo.PlayerId then for n,o in pairs(cheese)do if(receiptInfo.ProductId==n)then player.leaderstats:WaitForChild("Gold").Value = player.leaderstats.Gold.Value + o end break end end end return Enum.ProductPurchaseDecision.PurchaseGranted end
|
|
|
| Report Abuse |
|
|
sd10099
|
  |
| Joined: 13 Sep 2011 |
| Total Posts: 12804 |
|
|
| 21 Jul 2015 07:54 AM |
Well anyway billy this s a pretty handy scriot here. It gets annoyong to make like 3 + separate scripts |
|
|
| Report Abuse |
|
|
sd10099
|
  |
| Joined: 13 Sep 2011 |
| Total Posts: 12804 |
|
| |
|
|
| 21 Jul 2015 07:56 AM |
ok wtf tycooons I just tried it and it still doesn't work ._.
this is seriously annoying me now, should not be so difficult :U |
|
|
| Report Abuse |
|
|
sd10099
|
  |
| Joined: 13 Sep 2011 |
| Total Posts: 12804 |
|
|
| 21 Jul 2015 07:58 AM |
Did you try for i, player in pairs it's worth a try but I have no clue |
|
|
| Report Abuse |
|
|
|
| 21 Jul 2015 07:58 AM |
| I'm starting to question my ability to make leaderboard stats now lol, but nothing is wrong there.. ._. |
|
|
| Report Abuse |
|
|
|
| 21 Jul 2015 07:59 AM |
| Ok thanks@sd I'll try that now |
|
|
| Report Abuse |
|
|
Tycooons
|
  |
| Joined: 13 Aug 2014 |
| Total Posts: 5871 |
|
|
| 21 Jul 2015 08:00 AM |
It worked with me. So it's something wrong on your end definetely. I even went into the trouble of making four dev products and testing it
They went up by the correct amount |
|
|
| Report Abuse |
|
|