generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: anyone know DevProducts well?

Previous Thread :: Next Thread 
billylones is not online. billylones
Joined: 15 Jun 2009
Total Posts: 33959
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 is not online. 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
billylones is not online. billylones
Joined: 15 Jun 2009
Total Posts: 33959
20 Jul 2015 02:28 PM
can't even test it now as for some reason my DevProducts have broken..
Report Abuse
billylones is not online. billylones
Joined: 15 Jun 2009
Total Posts: 33959
20 Jul 2015 02:47 PM
Nope, that doesn't seem to work :/
Report Abuse
nQqzRYVpIKA5jLP is not online. nQqzRYVpIKA5jLP
Joined: 05 Mar 2015
Total Posts: 4135
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
billylones is not online. billylones
Joined: 15 Jun 2009
Total Posts: 33959
21 Jul 2015 04:21 AM
still no luck with that :/
Report Abuse
AlgyLacey is not online. 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
billylones is not online. billylones
Joined: 15 Jun 2009
Total Posts: 33959
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 is not online. 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 is not online. 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
billylones is not online. billylones
Joined: 15 Jun 2009
Total Posts: 33959
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 is not online. sd10099
Joined: 13 Sep 2011
Total Posts: 12804
21 Jul 2015 07:45 AM
"in ipairs" wht is that
Report Abuse
AlgyLacey is not online. 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
Rocketerkid is not online. Rocketerkid
Joined: 10 Oct 2011
Total Posts: 1237
21 Jul 2015 07:46 AM
http://wiki.roblox.com/index.php?title=Function_dump/Basic_functions#ipairs
Report Abuse
HyperProduct is not online. HyperProduct
Joined: 11 Nov 2012
Total Posts: 3362
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 is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. sd10099
Joined: 13 Sep 2011
Total Posts: 12804
21 Jul 2015 07:55 AM
Annoying*
Report Abuse
billylones is not online. billylones
Joined: 15 Jun 2009
Total Posts: 33959
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 is not online. 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
billylones is not online. billylones
Joined: 15 Jun 2009
Total Posts: 33959
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
billylones is not online. billylones
Joined: 15 Jun 2009
Total Posts: 33959
21 Jul 2015 07:59 AM
Ok thanks@sd I'll try that now
Report Abuse
Tycooons is not online. 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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image