question

seehundy avatar image
seehundy asked

How to update other player data needs a detailed explanation

Hello, I have read many answers to this question, but I am too big a noob to understand these answers. I would like PlayerA to be able to change PlayerB's PlayerData (Title). I always read the answer "UpdateUserData". However, I don't know exactly how to use this command to make it work. I have: PlayFabClientAPI.UpdateUserData (new UpdateUserDataRequest () { Data = new Dictionary <string, string> () { {"Name", data}, }, Permission = UserDataPermission.Public }, SendMessageSuccess, OnErrorLeaderboard);

With this I can change the data of the player myself, but not of another player. To do that I think I have to insert the PlayerId of the other player somewhere. I just don't know where.

I have written:

PlayFabClientAPI.UpdateUserData (new UpdateUserDataRequest () { PlayFabId = OtherPLayerId, Data = new Dictionary <string, string> () { {"Name", data}, }, Permission = UserDataPermission.Public }, SendMessageSuccess, OnErrorLeaderboard);

But there I only get the error message: 'UpdateUserDataRequest' does not contain a definition for 'PlayFabId'

Please help!

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

·
Rick Chen avatar image
Rick Chen answered

The players are not supposed to change other players’ PlayerData. In your case, PlayerA cannot use the client API UpdateUserData to change PlayerB’s PlayerData. A workaround to allow that is to expose the server API UpdateUserData on the CloudScript. The client API and the server API are different, server API has wider scope and should be called from server side. For more detail about the CloudScript, please check this document: CloudScript quickstart. You can refer to this thread: How to update other player data needs a detailed explanation - Playfab Community

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.