Hello, it's me again. I have this CloudScript function, which, for now, I call from the client with ExecuteCloudScript method, but soon I will call it every 24 hours using scheduled task:
handlers.getRandomDropTableItems = function (args, context) { var first_item = server.EvaluateRandomResultTable({"TableId" : "item_slot_one"}); var second_item = server.EvaluateRandomResultTable({"TableId" : "item_slot_two"}); var third_item = server.EvaluateRandomResultTable({"TableId" : "item_slot_three"}); while(first_item.ResultItemId == second_item.ResultItemId || first_item.ResultItemId == third_item.ResultItemId || second_item.ResultItemId == third_item.ResultItemId) { first_item = server.EvaluateRandomResultTable({"TableId" : "item_slot_one"}); second_item = server.EvaluateRandomResultTable({"TableId" : "item_slot_two"}); third_item = server.EvaluateRandomResultTable({"TableId" : "item_slot_three"}); } var data = {}; data["item_one"] = first_item.ResultItemId; data["item_two"] = second_item.ResultItemId; data["item_three"] = third_item.ResultItemId; server.UpdateUserReadOnlyData({"PlayFabId" : currentPlayerId, "Data" : {data: JSON.stringify(data)}}); return { messageValue: data}; };
Answer by Brendan · Nov 21, 2020 at 12:21 AM
Yes, don't use EvaluateRandomResultTables - use GetRandomResultTables, and use the odds in the table to determine the items to give the player in the script. That would also be faster, since it wouldn't be making 3+ Web API calls from the script - just 1.
Hey Brendan,
Thanks a lot for the fast answer. I am afraid I am not exactly sure how to use GetRandomResultTables. I looked over the API documentation and also over Drop Tables example, but it is still not very clear for me. I am not sure how to use the odds in the tables and to give the player those items
Some more details, in case they help:
I have 4 drop tables for each rarity (common, rare, epic, legendary), each drop table containing the items corresponding to that rarity. I have another 3 drop tables, each having a specific drop chance:
item_slot_one -> common_items (70%), epic_items (10%), legendary_items (5%), rare_items (15%)
item_slot_two -> rare_items (50%), epic_items (50%)
item_slot_three -> epic_items (33%), rare_items (33%), legendary_items (33%)
As you can see in my snippet, I am getting each item from those item_slot tables and setting them in Player Read Only Data.
Could you provide me a code snippet or some hints/ more details about using EvaluateRandomResultTables in my case?
Thanks again for all the help!