question

chrystian-sil avatar image
chrystian-sil asked

Initial set of characters from server

Hello,

I want to be able to set up some starting characters to be available for the user form the server, like a starter bundle of characters they can choose from. But our attempts have failed so far, this is what we have been trying to do.

I've been trying to set an initial set of characters for every new user that enters the game.

So far I've tried to hook a cloudscript function from the playstream (player_added_tittle) and then give a starter bundle with the items that can be converted to characters.

With the next 2 options:

1.- in the same hooked function get player inventory, then consume bundle and grant characters, then consume character items. But fails mid way due to the ammount of calls.

2.- Create aplaystream event that triggers when the bundle is added to consume it (this works well)

2.1.- Create a playstream event that triggers when a character from the starter bundle is added, and grant the character and consume it (this one is failing). And debbug it is hard because I only get errors and not the logs or anything else on the playstream viewer.

Any ideas of how could I achieve the result, the characters are about 12, but that can change later on development.

Thanks in advance,

Chrys

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

About Limits:

Essential Tier users can execute 15 APIs per Cloud Script execution. If you have specific needs, you may need to upgrade your tier. The thing is you don’t need to initialize all characters when player is created. My suggestion is that initializing it only when player clicks it and starts to play with this character.

About Rules:

Currently Rules are not able to trace Character related events, which means rules cannot be triggered by character_created event.

Work around:

So now the work around solution I suggest is that you may make 2 API calls and first is creating character and next is initializing the character via Cloud Script.

After the success callback from GrantCharacterToUser is received, you may call ExecuteCloudScript and pass through the character ID to the cloud script function. Meanwhile in the Cloud Script, you should verify if this character is newly generated (e.g. via checking if there is some KVP in this character’s Player Internal Data) then do the initialization process.

Please try to add all items in a list and use GrantItemsToCharacter if you need to grant items. APIs like UpdateCharacterData and UpdateCharacterStatistics are all capable of updating multiple KVPs in a single API call. Hence, the basic ideas is try to reduce the amounts of calls and if there are too many duplicated items, you should also consider grant one and directly modify the remaining use numbers of item instances in character’s inventory.

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.