question

brendan avatar image
brendan asked

Adding custom user data on creation of new account

iregi
started a topic on Wed, 21 January 2015 at 6:33 AM

How would I go about adding custom user data (initialize the fields) to a newly created account without using client-side API calls to UpdateUserData? Example would be adding a "XP" field which is initialized to 0 on account creation which my gameplay server can then keep updating.

Is there any way I can specify title-specific default fields to add to a newly created user through the Game Manager?

Alternatively, would using a Cloud Script be a way to implement this? The steps as I see them are: Check if an account exists for the user. If not, create a new account and run a cloud script which initializes all the fields I need.

10 |1200

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

brendan avatar image
brendan answered

Best Answer
Brendan Vanous said on Thu, 22 January 2015 at 1:19 AM

There are a couple of ways you could enable this. One (and particularly for a numeric value, like XP) would be to use a virtual currency, defined in the Catalog setup for the title. Alternately, you could use Cloud Script to enable this, as that gives you the ability to have server-authoritative logic for your title (without the need for a full-on server). Cloud Script would require that you initiate the logic via a call from the client, but apart from any inputs you send from the client to the Cloud Script (or to read/write user data that the script uses), there would be no way for the client to interfere in the results.

Brendan


4 Comments
Brendan Vanous said on Thu, 22 January 2015 at 1:19 AM

There are a couple of ways you could enable this. One (and particularly for a numeric value, like XP) would be to use a virtual currency, defined in the Catalog setup for the title. Alternately, you could use Cloud Script to enable this, as that gives you the ability to have server-authoritative logic for your title (without the need for a full-on server). Cloud Script would require that you initiate the logic via a call from the client, but apart from any inputs you send from the client to the Cloud Script (or to read/write user data that the script uses), there would be no way for the client to interfere in the results.

Brendan


iregi said on Fri, 23 January 2015 at 2:58 AM

Going the virtual currency way seems a bit like a hack to be frank. Also, I would need to add other text fields too, so that would not be the best solution.

I will try the CloudScript route. I had found a tutorial for CloudScripts (using the example rewards script), but cant find the link anymore. Can you please provide the link to that page?

Thanks.


Brendan Vanous said on Fri, 23 January 2015 at 8:37 AM

Sure thing - the link to our main Cloud Script page is: https://playfab.com/cloud-script. We'll make sure the site is updated to make this easier to find.

Brendan


iregi said on Fri, 23 January 2015 at 8:41 AM

Thanks for the quick responses!

5 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.

terrypapamarkou avatar image terrypapamarkou commented ·

If we use the cloud script approach for player data initialisation, will be limited by the "Player data updates per request" limit (10 on the free plan) or can a single cloud script call execute multiple calls to update the player data?

0 Likes 0 ·
brendan avatar image brendan terrypapamarkou commented ·

Can you clarify what it is you're trying to do? Why would you be trying to update the player data for a single player more than once in the script?

0 Likes 0 ·
terrypapamarkou avatar image terrypapamarkou brendan commented ·

we only want to update the data once, but we want to set initial values for many properties in that update. eg

gold = 2000

gems = 20

playerName = "tempName"

cardsCollected1 = 0

cardsCollected2 = 1

cardsCollected3 = 0

//etc

There are more than 10 initial values that we want to set when the account is first created so I'm unsure of the best way to go about it.

Thanks

0 Likes 0 ·
Show more comments
blindgoat avatar image
blindgoat answered

Terry - why store data that is default? Can your client just check if the field exists, and if it doesn't, assume the default value for each variable?

It'll save you PlayFab requests and storage to not save variables at all unless they differ from the default values.

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.