Hey everyone,
we are trying to move some custom server logic to CloudScript, more specifically for reporting the results of a match.
Parameters:
- Match Players
- Match Winners
Script:
- For each player:
- Get current wins, losses and matchmaking rating of that player.
- If the player won, increase wins and matchmaking rating.
- Else, increase losses and reduce matchmaking rating.
- Call server.UpdatePlayerStatistics with the new values.
We'd love to do so in CloudScript. However, CloudScript can be called from clients as well, which we don't want to allow them to do.
Right now, we're calling the CloudScript function from server-side on behalf of any of the players, and send a server secret along with the JSON payload. The CloudScript function then verifies the secret before applying the above changes.
It this the correct way to do so, or do you recommend another approach?
Our next step would be to write a CloudScript function for initializing player statistics with reasonable default values (e.g. matchmaking rating other than zero). How would we go about that?