Scheduled Events or C# Module?

In my game, there are contests that other players vote on. Players can vote for randomly selected contests, primarily for those who received fewer votes - some additional minor logic regarding this is also implied. These contests are supposed to end over time. Participants can be online or offline at the end of the contest; if they are offline, they should receive a notification the next time they log into the game.

If I understood correctly from reading the documentation, to close the contests and distribute rewards, I need to use Schedule events.

Or is it possible to use a C# module that will initiate a timer, close the contests upon its completion, and thus avoid using Schedule events (I havenā€™t figured out if this is possible)?

Please clarify: Which of these options is possible? Which is more practical? Thank you.

Hi @Kurutah - Scheduling an event to trigger a C# module function at the close of the contest is currently poossible. You should be able to follow the New year sample here Use case sample: Wish players a happy new year to achieve the behaviour you are after.

Attempting to use a C# module to initiate a timer would not be a good option as we canā€™t guarantee the C# module resource will be available and running for the lifetime of the timer.

1 Like

Thank you for your response. Could you possibly show me the principle (or provide a link to the documentation) on how to save active users and work with them, preferably (excluding schedules) through C# modules?

Iā€™ve spent many hours reading the documentation and studying examples, but all the methods I try either donā€™t work, are outdated, or relate to the Player and save data in their field - but I need a separate list that players can populate with their data (by entering a contest), vote (by downloading and modifying something in the list), and receive rewards when their entry is winning. That is, participants do not know the IDs of other players when using this list; they simply receive it and vote.

It seems that the documentation mentions ā€œGame Dataā€ which could be suitable for storing player IDs and information about their contests. However, Iā€™m uncertain as I havenā€™t found any practical examples of how to manipulate this data using C#.

ā€œGame clients can only read custom items. They cannot create, modify or delete Custom items. Custom Items can be written to using Cloud Code, a game server, using the HTTP API or from the Unity Cloud Dashboard.ā€ - from docs.

Alternatively, as I considered later, should I be using Cloud Save Queries to handle this aspect?

But anyway, I also would like to manage a list of player clones who have previously participated in contests, to compare with a clone of a player of a corresponding level during voting. How should I manage and work with such a list of clones? Is there a specific Unity service or pattern that would allow me to implement this feature?

Thank you.

Could you possibly show me the principle (or provide a link to the documentation) on how to save active users and work with them, preferably (excluding schedules) through C# modules?

Would you be able to expand on the question further? Iā€™m not sure what you mean by ā€œsaving active usersā€ and working with them e.g. what type of operations would you like to do?

I need a separate list that players can populate with their data (by entering a contest), vote (by downloading and modifying something in the list), and receive rewards when their entry is winning

Have you considered the leaderboards service Leaderboards? It sounds like it would facilitate this use case and you are able to associate additional metadata to entries.

Additionally, I would like to manage a list of player clones who have previously participated in contests, to compare with a clone of a player of a corresponding level during voting

The leaderboards service can provide archives of leaderboards scores either paginated Unity Services Web API docs or by player Unity Services Web API docs.

If the leaderboards service would not suit your needs, then the combination of using Cloud Save Game Data with indexed fields which you can query could help.

I can point you in the direction of the leaderboards Cloud Code sample Access Leaderboards via Cloud Code C# Modules but unforuntately we donā€™t currently have any up to date samples using the Cloud Save Game Data and queries. However the latest Cloud Save SDK should follow the Data API Unity Services Web API docs so will have methods available to get Game (Custom) Data and run queries e.g. The current Cloud Save sample Integrate with other Unity services could be expanded upon with the following

            await gameApiClient.CloudSaveData.SetCustomItemAsync(...);
            await gameApiClient.CloudSaveData.QueryPrivateCustomDataAsync(...);
            await gameApiClient.CloudSaveData.QueryDefaultCustomDataAsync(...);

The general principle is as follows: some players send one (or several) contestants to competitions. Other players will vote for these contests. Iā€™m not planning to strictly monitor cheating protection in this game since multiplayer is just an addition to the single-player game, so players will store their data in JSON format on their local computers and use UGS primarily for conducting contests.

I need a practical method to:

  • Allow other players to access data about current contestants and vote for them. - If I understand correctly, Cloud Save Queries would be best suited for this? Is it okay if there are (hypothetically) 100 000 players in the database, but only about 100 active contests? Iā€™m asking because it sounds like sifting through a large number of players for those participating in contests seems like costly work - and it would be easier to have a separate list tied to player IDs - but Iā€™m not sure if itā€™s really costly and how to have a separate list :slight_smile:
  • Maintain an additional ā€˜botsā€™ list, which is periodically updated with copies of actual contest participants to keep it current. This list, sorted by rating, will be used in voting so that voters are always presented with a choice between a real player and a ā€˜botā€™ with a comparable rating (allowing voting to commence immediately without waiting for another player of a matching rating to become available).

I hope Iā€™ve explained the principle. What concerns me is when the methods I come across in training are marked as outdated, or I see examples in JavaScript with which I have no experience. But I will continue to figure it out if Iā€™m confident that Iā€™ve at least chosen the right services.

After your response, I started considering the use of Leaderboards as well. However, I would still like to understand what to focus on specificallyā€¦

Thank you.

No problem, Iā€™ve asked if someone from the Cloud Save/ Leaderboards team could take a look at your use case and suggest which solution would be appropriate to focus on. In the mean time could you point me in the direction of the problem examples/ samples so I can flag those to get updated.

Thanks!

1 Like