question

Terry Evans avatar image
Terry Evans asked

How to only allow X characters to be created via CloudScript?

I'd like for a client (using the client ExecuteCloudScript API) to be able to create up to a max of X (say 4) characters on their account - so 4 character slots. If they delete a character then it frees up a character slot. So, at any time a player can have 0 to 4 characters created.

In addition, have a token that players can purchase which can each increase their max character slots to to some final max count (say 10 character slots).

Any hints or examples as to how to implement something like this via cloud script? It's still confusing to me, so any tips would be greatly appreciated.

Characters
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

A common workaround for this scenario is to maintain a flag variable in Player Read-Only Data, where max slots and current slots are maintained. You may disable GrantCharacterToUser API in API Policy and handle the “grant character” process on Cloud Script completely. The process will be simple: first, check the flag variable from Player Read-Only Data to validate and also confirm if the player owns the token. Then, revoke the token and grant the character for the player.

Expanding the character slots will be very similar to the above process.

10 |1200

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

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.