question

Michael Brilz avatar image
Michael Brilz asked

Cant add virtual currency

Englisch

Hello, I cannot add a currency to the player's account with the following code.
public void AddDC()
    {

        AddUserVirtualCurrencyRequest request = new AddUserVirtualCurrencyRequest();
        {

            request.VirtualCurrency = "DC";
            request.Amount = 1000;
        }


        PlayFabClientAPI.AddUserVirtualCurrency(request, _Result, _Error);


    }

    private void _Error(PlayFabError obj)
    {
        Debug.Log("DC wurde nicht hinzugefügt");
    }

    private void _Result(ModifyUserVirtualCurrencyResult obj)
    {
        Debug.Log("DC wurde hinzugefügt");
    }
}

unity3ddataCharacter Data
10 |1200

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

cusyabasic avatar image
cusyabasic answered

I'm a unreal engine 4 blueprint scripter so I could be wrong on this, however I'vew been using cloud script a lot lately so I'm getting used to code.

I believe your issue is with the request you are submitting, your calling the function but are listing the params outside of the line you are calling it.

It should look more like this:

 AddUserVirtualCurrencyRequest request = new AddUserVirtualCurrencyRequest(
{             
	request.VirtualCurrency = "DC";
            request.Amount = 1000;
}
);        

Once more I could be wrong, I'm not used to working with raw code.

,

I'm a unreal engine 4 blueprint scripter, so this info could be wrong.
however i've been using cloud script alot lately so I'm getting used to actual code.

I believe your error lies with your request.
Your declaring paramaters outside of the function you are calling:

AddUserVirtualCurrencyRequest request = new AddUserVirtualCurrencyRequest(); 

       {          

   request.VirtualCurrency = "DC";    

        request.Amount = 1000;   

     }

should be:

AddUserVirtualCurrencyRequest request = new AddUserVirtualCurrencyRequest(

        {       

      request.VirtualCurrency = "DC";      

      request.Amount = 1000;    

    });

Once more I could be wrong.

10 |1200

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

Seth Du avatar image
Seth Du answered

You may try to output more detailed error message so that we can help you dig into it. In addition, normally the detailed error message sometimes can directly reveal the cause. And for more information, you may see in the PlayFabError instance. Please refer to the following code:

private void _Error(PlayFabError obj) 
{ 
Debug.Log(obj.GenerateErrorReport()); 
}
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.