question

kennyroy avatar image
kennyroy asked

GetUserDataResult doesn't have PlayFabID?

Using the client API, I am having players in a photon room that have OnPhotonPlayerConnected() called attempt to download the new player's Data and customize their model based on the values i've stored there. But the GetUserDataResult does not have the PlayFabID anywhere in the object.

Am I doing something wrong? I am setting PhotonNetwork.nickname to the PlayFabID. Someone joins the room I am called GetUserData with a request with PlayFabID == PhotonPlayer other.nickname). But then when I get the data, the GetUserDataResult 'result' has no ID attached to it.

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.

kennyroy avatar image kennyroy commented ·

The only thing I can think of off the bat is to have a monobehavior on the instantiated player object itself. That way, it can call the GetUserData itself, and reference a callback method that is on the same GameObject. I'll have the owner.Nickname somewhere on that object that the callback can grab when it fires. I typically like managers to do everything setup-related on game objects though, it feels like the wrong structure to have a player object fire it's own GetUserData, and have its own callback.

0 Likes 0 ·

1 Answer

·
v-humcin avatar image
v-humcin answered

When making a request using one of our SDKs, the result should include a "Request" field that will allow you to access the parameters passed into the request such as the PlayFabId.

Accessing the fields of the request may slightly differ depending on the SDK. For example, when using Unity you will have to cast the "Request" object stored in the "Result" as the appropriate type of request as below. This is because the request is initially of the generic "PlayFabResultCommon.Request" type.

GetUserDataRequest request = (GetUserDataRequest) result.Request;
string id = request.PlayFabId;
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.

kennyroy avatar image kennyroy commented ·

That's what I first tried, and don't see that data returned.

0 Likes 0 ·
capture.jpg (13.1 KiB)
kennyroy avatar image kennyroy commented ·

Oh I guess I don't know the C# reason why I have to cast it like you did. Yours works.

0 Likes 0 ·
v-humcin avatar image v-humcin ♦ kennyroy commented ·

Glad to hear it worked! The C# reason that the cast is important is that the generic form of "PlayFabResultCommon.Request" that the request is passed as, has no actual fields to access or concept of what "PlayFabId" is. So you must cast it to "GetUserDataRequest" so that the compiler knows what you are trying to access is a string called "PlayFabId".

0 Likes 0 ·
kennyroy avatar image kennyroy v-humcin ♦ commented ·

Yeah thanks for that. I assumed since the request is a type that derives from ClientModels that it knew what it was.

0 Likes 0 ·
Show more comments

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.