question

ryandj avatar image
ryandj asked

cloud script data

Hi I'm making a game a bit like a draw.

where each player has one number and every day a draw picks a winner on the cloud script and once the player logs in can look at what the drawn number was for that day. I tried doing this with cloud script to save the players ball number on it and randomly draw but I quickly realized the code was for each player not global.

where can I be storing these numbers that can then be quickly accessed by the cloud script to then be sent to everyone.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
Seth Du avatar image
Seth Du answered

I’d like to recommend you to store it at player’s Statistics, and Statistics data from all players can be eventually retrieved via Leaderboard. You can retrieve Leaderboard in the Cloud Script and generate a random number according to the length of Leaderboard retrieval callback result, then get the winning player from the callback list. I actually have considered some other solutions for example, storing these data at shared place like Title Data (as a JSON string or formatted list). When multiple players execute the same Cloud Script function that updates the same data, there is a high possibility that error may occur due to the service concurrency limit. Hence we do not recommend it.

Also be aware that you should disable clients to post statistics in case of cheating and please navigate to [Game Manager]-> [Settings] -> [API Features] for the setting.

Besides, you can create a Schedule Task at [Game Manager] ->[Automation] ->[Scheduled Tasks] to run the picking winner function daily so that you don’t have to manually trigger it.

3 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

ryandj avatar image ryandj commented ·

Thanks alot. I will give it a go with leader board and stat

0 Likes 0 ·
brendan avatar image brendan commented ·

To be clear, writing to title data or player data by a large number of players is not supported. Title data is only supported for occasional changes are driven by the developer/publisher directly and cannot be updated due to a player action. And yes, trying to write to the same player data key/value pair would result in a high level of contention - hence, it is also not supported.

0 Likes 0 ·
ryandj avatar image ryandj brendan commented ·

OK thanks. Alot, I will I have resorted to using player stats and the leaderboard and running my code from there thanks alot guys

1 Like 1 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.