question

timpson-63 avatar image
timpson-63 asked

Creating New Player w/ defined PlayerData (Title)

Hello,

I'm looking for advice on how to create a new player with PlayerData (Title) that is already instantiated at default values.

OR

Is there a function I can use that, when trying to load PlayerData, if a particular data variable isn't defined, it will create it and set it to a default value?

The issue is this:

When I update the client, and a new PlayerData item is added, all existing players don't have that defined, and so when I try to use it at the beginning of the game when I am loading data, an error is returned which could potentially break the game.

I'm trying to find method where current users will be updated with any new data that I add to the game during development. Is there a solution to this?

Thanks,

Player Datadata
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

·
brendan avatar image
brendan answered

The best approach would be to set a PlayStream Rule on the player_added_title event, which calls a Cloud Script handler which adds the data you need.

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

timpson-63 avatar image timpson-63 commented ·

Okay. I can look into that.

Is there a similar thing that can be used when an existing player tries to access data that they do not yet have defined in their PlayerData that would, instead or returning an error, define the data using a default value?

0 Likes 0 ·
brendan avatar image brendan timpson-63 commented ·

No, there's no built-in system where you can pre-define default values for player data, currently. If that's an important feature for you, I'd recommend adding it to the Feature Requests forum, so that others can "like" the idea (which helps with determining prioritization).

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.