question

Last Chaos avatar image
Last Chaos asked

CloudScript function for server-only

How to determine that the CloudScript function was called by the server and not by the client? For example, a function to increase the level of the player, I would not want the client to be able to assign levels to himself.

CloudScriptPlayer Data
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

·
Rick Chen avatar image
Rick Chen answered

This doesn't make sense to me. CloudScript function is designed to be called from client. For server, there is no need to call CloudScript, you can just call the server APIs.

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.

Last Chaos avatar image Last Chaos commented ·

To give a player a new level and register it in the player's data, you need to make a request and get the current level. in practice, it happens that the server receives an incorrect result and can reset the player's level. this rarely happens and I don't know how to guarantee players that their level will not be reset and the result will be saved correctly. Maybe there is some universal recipe how to do it right?

0 Likes 0 ·
Last Chaos avatar image Last Chaos commented ·

I thought it would be nice if the server sent only the result of the current session to the playfab, and the calculations were made on the playfab side to avoid errors

0 Likes 0 ·
Rick Chen avatar image Rick Chen ♦ Last Chaos commented ·

In this case, you may write a local synchronous program to call the server APIs. So that you can make sure only if the previous call is successful can the next call be made. (you can put your set-user-level function in the successful callback of the get-user-current-level call.)

0 Likes 0 ·

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.