question

Johann avatar image
Johann asked

How do you access an Item's "Items remaining" value if it's limited edition? & Suggestion

I have an item in my catalog that is limited edition. In my game, I want to be able to access the item's "Items remaining" and "Initial grant" values. I am able to access the latter, but I am unsure how to access the other.

In my game, I also want to be able to stack and trade items. However, this is not yet supported. I would greatly appreciate it if this feature is added.

10 |1200

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

1807605288 avatar image
1807605288 answered

johannpayer123

Here's the admin example you requested.

  1. If you haven't already, you will need to add our EditorExtensions to your unity project. (Strictly speaking it's optional, but it's much easier to do this using EdEx).
  2. Toggle on, the Admin API

  3. Here's your code:
using PlayFab;
using PlayFab.AdminModels; // This will throw an error if you don't have ENABLE_PLAYFABADMIN_API option defined in Unity, or "Enable Admin API" checked in EdEx
using UnityEngine;

public class NewBehaviourScript : MonoBehaviour
{
    public void OnFailure(PlayFabError error)
    {
        Debug.LogError(error.GenerateErrorReport());
    }

    public void GetRemainingLimited(string itemId)
    {
        var request = new CheckLimitedEditionItemAvailabilityRequest
        {
            ItemId = itemId
        };
        PlayFabAdminAPI.CheckLimitedEditionItemAvailability(request, OnGetLimitedRemaining, OnFailure);
    }

    private void OnGetLimitedRemaining(CheckLimitedEditionItemAvailabilityResult result)
    {
        Debug.Log("Remaining limited edition items: " + result.Amount);
        var prevRequest = (CheckLimitedEditionItemAvailabilityRequest)result.Request;
        var itemId = prevRequest.ItemId;
    }
}

I have tested that this code COMPILES, and it's simple enough that I'm fairly certain it will give you the information you want if you execute it.


enableadmin.png (13.9 KiB)
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.

Johann avatar image Johann commented ·

Can you explain how to open up the Extensions menu? It automatically opened when I first imported the PlayFab packages into Unity and set everything up. I never figured out how to open it afterward, I googled online, but to no avail, I've searched the files and still can't figure it out, and lastly, I deleted and reimported the packages. I really appreciate you taking your time to help me.

0 Likes 0 ·
Johann avatar image Johann commented ·

I figured out how to open it (Window > PlayFab > Editor Extensions). I'll try out the code right now.

0 Likes 0 ·
Johann avatar image Johann Johann commented ·

The code worked perfectly, but the result that is returned doesn't contain the ItemID or any information that I can use to identify which item the result corresponds to. Do you know how to solve this?

0 Likes 0 ·
1807605288 avatar image 1807605288 ♦ Johann commented ·

I have updated the example above to retrieve the itemId from the result.Request.

0 Likes 0 ·
Show more comments
pfnathan avatar image
pfnathan answered

You can use following API calls for remaining items.

https://api.playfab.com/documentation/Client/datatype/PlayFab.Client.Models/PlayFab.Client.Models.ItemInstance

"RemainingUses" should do the trick. and for your stack and trade items feature request, please re-direct your request to "feature request" page.

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

Johann avatar image Johann commented ·

Thank you for your response. I'll try it out as soon as possible.

0 Likes 0 ·
pfnathan avatar image pfnathan ♦ Johann commented ·

Here is an updated response, I have misunderstood the question. The correct API call to use for your inquiry is here: (https://api.playfab.com/documentation/admin/method/CheckLimitedEditionItemAvailability), This is an Admin API, we currently do not have it for Server or Client, however.

0 Likes 0 ·
Johann avatar image Johann pfnathan ♦ commented ·

Do you know how I can access this property, or is that not possible?

0 Likes 0 ·
Show more comments
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.