question

Reid Taylor avatar image
Reid Taylor asked

Saving Player Data

I have a conundrum... So I allow the player to change avatar picture. When doing this it saves an index to player data. When the player chooses an avatar too much too fast it doesn't save because PlayFab limits saves. So then next time they log in, it is not the newest avatar they chose. What do I do about this?

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.

Citrus Yan avatar image
Citrus Yan answered

You are not supposed to update player data very often, which will hit the rate limit. It's recommended to cache player data changes locally and update them periodically, or when application exits.

1 comment
10 |1200

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

Reid Taylor avatar image Reid Taylor commented ·

This kinda makes sense... I still don't totally understand why there is a limit :)

0 Likes 0 ·
Talha avatar image
Talha answered

I am not sure What the issue is and why you are saving an index in player data but here's what I do.

I Use the Playfabs UpdateAvatarUrl call to update my Player's avatar.

After The Player updates the Avatar I add a cool down timer, 1 hour( depends) , and make the button interactable= false for an hour ( to optimize the calls made to playfab server).

void Start()

{

	if(currentTime > timeSinceLastUpdatedAvatar+ 1 hour) 
	{
		//Unfreeze The UdpateAvatarButton
	}
	else 
	{
		//Freeze The  UdpateAvatarButton
	}

}
void UpdateAvatar(){


if(currentTime > timeSinceLastUpdatedAvatar+ 1 hour) {

 PlayFabClientAPI.UpdateAvatarUrl(new UpdateAvatarUrlRequest
        {
            ImageUrl = AvatarUrl_forPlayfab

        }, result =>
        {
            Debug.Log("Avatar Updated.  New avatar is:"+ AvatarUrl_forPlayfab);
		//Freeze The  UdpateAvatarButton
          

        }, error => {

            Debug.Log("Avatar Update Failed");
        }
}
}
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.