I was reading the wikia recently and it said I need to have the processReceipt callback only in one script. Is that true? Or is it just a recommendation?
It is good practice to keep it in 1 script, wouldn’t it make sense to have only 1 and not 1-10 scripts of processing purchases
Could you explain the use case for needing it across multiple scripts? Rather, how do you expect the property to be able to take multiple functions without being a table?
a = 1
a = 2
a
doesn’t become 1 and 2, a
becomes 2
ProcessReceipt
is a callback. If you set it again from a different script, the old one will no longer work, similarly to RemoteFunction.OnServerInvoke
.
That’s why you should only set it in a single script.
Ok then I’m making a little wrapper for it so I can do it.
I used to have a bunch of developer products on which they were completely different things, one for cash, one for vip acess like, it becomes complex, but anyways;
It doesn’t have to be complex, even if you have multiple developer products. Have one process receipt that calls on helper functions to handle each dev product.
The wiki has a good example where a table storing all the functions (with keys for each dev product’s ID) is used to make calls to other functions.
EDIT: To answer the original question, you must have one ProcessReceipt script. It isn’t possible to have multiple and it wouldn’t make sense to either. Ultimately, only one function can be called back.
What would be the alternative to this? Like currently I’m having 3 different leaderboards and with them all being a required script, I’m unable to change the script code. Even so I would not be able to do anything with it as it would simply be too hard to fit 1.500 lines of code into a single script.
Any alternative?
Sincerely.
Yes, its better to be in one script, if you have codes which do different things, i normally have some table containing the ids for something coins, gems etc, and if the id of that purchase is on a certain table then make it do whatever you want so if it is in the coins table it will give coins etc
Nevermind, sorry! I thought you were replying to me. (deleted the msg)
I was trying to understand what u said lmao, np tho!
No worries man : )
but I still don’t get how ill make everything work…
So lets say you have an id for giving coins and one for gems so do this
local coinIds = {
1111;
}
local gemIds = {
2222;
}
--in your ProccesReceipt function
if table.find(id , coinsIds) do
elseif table.find(id , gemsIds) do
end
--and so on