question

brendan avatar image
brendan asked

Coding with Playfab

Standingstonegames
started a topic on Wed, 29 July 2015 at 6:12 PM

This might seem like a rather stupid question but I thought it'd be worth asking. When I'm adding in my playfab functions and code from the docs (this is in Unity by the way), do I just treat it as if it were any other piece of code, and just put that in there. So lets say I wanted to give a player a coin everytime he pressed X, would this suffice

if (Input.GetKeyDown("X")){

Playfab.addcoin (not literally the code but you know what I mean)

}

Or do I have to code it in playfab specific way?

Cheers

Tom

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

1 Comment
Brendan Vanous said on Sun, 09 August 2015 at 2:54 PM

HI Tom,

Apologies for the delay on this - it appears that a couple of cases fell through the cracks recently, which should never happen. If you don't get a response from us within a couple of days, you should always feel free to ping us directly at devrel@playfab.com.

For your specific question, no, there's no PlayFab requirement for the code, so you should feel free to follow any coding best practices you prefer. In almost all cases, there's a request object you'll need to pass in as part of the request. For example, here's the OnRegistrationCompleted call from our Union MOBA demo (available in GitHub: https://github.com/PlayFab/UNION-OpenSource-MOBA).

    void OnRegistrationCompleted(RegisterPlayFabUserResult result)
    {
        playerID = result.PlayFabId;
        playerUsername = result.Username;

        Dictionary<string, string> playerData = new Dictionary<string, string>();
        playerData.Add(GameConstants.accountLevelKey, "0");
        playerData.Add(GameConstants.accountExpKey, "0");

        UpdateUserDataRequest request = new UpdateUserDataRequest();
        request.Data = playerData;
        request.Permission = UserDataPermission.Public;

        PlayFabClientAPI.UpdateUserData(request, OnAddDataSuccess, OnAddDataError);
    }

Brendan

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.