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}; };
The problem is that sometimes I get a mail, saying that "CloudScript execution API requests issued (triggered action)" regarding that function (and that I make 6 API calls when the limit is 5). I guess it's probably because sometimes I make too many server API calls using that while.
But how could I get random items from the tables and ensure that they are unique between them? I have around 12 items (4 rarities, 3 items for each rarity, each drop table has different chances of dropping an item from a rarity, some have a chance for each rarity, some have chances to drop only 2 rarities).
Any idea/ workaround about how to fix this?? This is more of an MVP also, so it doesn't need to be 100% safe or efficient.