question

sezerbulanik avatar image
sezerbulanik asked

Invalid input parameters ( Gold = result.InfoResultPayload.UserVirtualCurrency["GD"];),

 void Start()
    {
        PhotonNetwork.ConnectUsingSettings();
        LoginWithPlayFabRequest LoginRequest = new LoginWithPlayFabRequest();
        LoginRequest.InfoRequestParameters = info;
        PlayFabClientAPI.LoginWithPlayFab(LoginRequest, result =>
        {
            Gold = result.InfoResultPayload.UserVirtualCurrency["GD"];
        }, error => { Debug.LogError(error.ErrorMessage); });
        foreach (GameObject obj in EnableOnLogin)
        {
            obj.SetActive(true);
        }
        
        GetNews();
        //PhotonNetwork.ConnectToRegion("au");
    }
    public void GiveBasicChets()
    {
        PurchaseItemRequest request = new PurchaseItemRequest();
        request.CatalogVersion = "Characters";
        request.ItemId = "NinjaChest";
        request.VirtualCurrency = "GD";
        request.Price = 0;
        PlayFabClientAPI.PurchaseItem(request, result =>
        {

        }, error =>
        {
            Debug.LogError(error.ErrorMessage);
        });
    }
    public override void OnConnectedToMaster()
    {
        foreach (GameObject obj in EnableObjectsOnConnect)
        {
            obj.SetActive(true);
        }
        Debug.Log("We are now connected to Photon!");
        foreach (GameObject obj in DislabeObjectsOnConnect)
        {
            obj.SetActive(false);
        }
        Debug.Log("We are now connected to Photon!");
    }
    public void JoinF4A()
    {
        PhotonNetwork.AutomaticallySyncScene = true;
        PhotonNetwork.JoinRandomRoom();
    }
    public override void OnJoinRandomFailed(short returnCode, string message)
    {
        CreateF4A();
    }
    public void CreateF4A()
    {
        PhotonNetwork.AutomaticallySyncScene = true;
        RoomOptions ro = new RoomOptions { MaxPlayers = 10, IsOpen = true, IsVisible = true };
        PhotonNetwork.CreateRoom("defaultF4A", ro, TypedLobby.Default);
    }
    public override void OnJoinedRoom()
    {
        SceneManager.LoadScene("FreeForAll");
    }
    public void Market()
    {
        SceneManager.LoadScene("Shop");
    }
    void GetNews()
    {
        GetTitleNewsRequest request = new GetTitleNewsRequest();
        request.Count = 10;
        PlayFabClientAPI.GetTitleNews(request, result =>
        {
            List<TitleNewsItem> news = result.News;
            foreach (TitleNewsItem item in news)
            {
                string[] output = item.Body.Split(';');
                GameObject u = Instantiate(NewsPanel, NewsView.transform.position, Quaternion.identity);
                u.transform.SetParent(NewsView.transform);

                u.transform.GetChild(0).GetComponent<Text>().text = item.Title;
                u.transform.GetChild(1).GetComponent<Text>().text = output[0];
                StartCoroutine(GetImage(output[1], u.transform.GetChild(3).GetComponent<Image>()));
            }
        }, error =>
        {
        });

    }
    IEnumerator GetImage(string url, Image image)
    {
        WWW www = new WWW(url);
        yield return www;
        Texture2D texture = new Texture2D(1, 1);
        texture.LoadImage(www.bytes);
        texture.Apply();
        Sprite sprite = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), Vector2.zero);
        image.sprite = sprite;
        image.preserveAspect = true;
    }
    void Update()
    {
        GoldText.text = "Gold: " + Gold;
    }
}
,
10 |1200

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

Citrus Yan avatar image
Citrus Yan answered

I don’t think this is the proper way to use the LoginWithPlayFab API, referring to this API reference, you must provide username, password and title id in order to call it properly, please refer to the following sample code:

void Start()
    {
        LoginWithPlayFabRequest loginRequest = new LoginWithPlayFabRequest()
        {
            TitleId = PlayFab.PlayFabSettings.TitleId,
            Username = "",  // the player's username
            Password = "",  // the player's password
            InfoRequestParameters = new GetPlayerCombinedInfoRequestParams()
            {
                GetUserVirtualCurrency = true
            }
    };
        PlayFabClientAPI.LoginWithPlayFab(loginRequest, result =>
        {
            int Gold = result.InfoResultPayload.UserVirtualCurrency["GD"];
            Debug.Log("Gold Amount: " + Gold.ToString());
        }, error => { Debug.LogError(error.ErrorMessage); });
    }

10 |1200

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

sezerbulanik avatar image
sezerbulanik answered
 public InputField Username;
    public InputField Password;
    public string LevelToload;
    public GetPlayerCombinedInfoRequestParams info;
    public int Gold = 0;
    public Text GoldText;
   
    public void Login()
    {
        LoginWithPlayFabRequest request = new LoginWithPlayFabRequest();
        request.InfoRequestParameters = info;
        request.Username = Username.text;
        request.Password = Password.text;
        PlayFabClientAPI.LoginWithPlayFab(request, result =>
        {
            Gold = result.InfoResultPayload.UserVirtualCurrency["GD"];
            Debug.Log("Gold Amount: " + Gold.ToString());
            Alerts a = new Alerts();
            StartCoroutine(a.CreateNewAlert(Username.text + "You have logged in!"));
            SceneManager.LoadScene(LevelToload);
        }, error =>
        {
            Debug.LogError(error.ErrorMessage);
            {
                Alerts a = new Alerts();
                StartCoroutine(a.CreateNewAlert(error.ErrorMessage));
            }
        });

    }
    
    private void Update()
    {
        GoldText.text = "GOLD :" + Gold;
    }


I see gold on the console with debug.log but it is not reflected in the text on the game screen ?????????*
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.

Citrus Yan avatar image Citrus Yan commented ·

Did you reference the GoldText defined in your script to the Text object the in the game scene through the inspector, like this:

By the way, I don't think it's necessary to update the GlodText during every frame update because I see you placed the code in the Update() function.

0 Likes 0 ·
inspector.png (6.3 KiB)
sezerbulanik avatar image
sezerbulanik answered

I put Gold Text but nothing changed

10 |1200

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

sezerbulanik avatar image
sezerbulanik answered
public class PlayfabAuth : MonoBehaviour
{
    public InputField Username;
    public InputField Password;
    public string LevelToload;
    public GetPlayerCombinedInfoRequestParams info;
    public int Gold = 0;
    public Text GoldText;
   
    public void Login()
    {
        LoginWithPlayFabRequest request = new LoginWithPlayFabRequest();
        request.InfoRequestParameters = info;
        request.Username = Username.text;
        request.Password = Password.text;
        PlayFabClientAPI.LoginWithPlayFab(request, result =>
        {
            Gold = result.InfoResultPayload.UserVirtualCurrency["GD"];
            Debug.Log("Gold Amount: " + Gold.ToString());
            Alerts a = new Alerts();
            StartCoroutine(a.CreateNewAlert(Username.text + "You have logged in!"));
            SceneManager.LoadScene(LevelToload);
        }, error =>
        {
            Debug.LogError(error.ErrorMessage);
            {
                Alerts a = new Alerts();
                StartCoroutine(a.CreateNewAlert(error.ErrorMessage));
            }
        });
        GoldText.text = "GOLD :" + Gold;
    }
    private void Update()
    {
    }
}

Login script












public class MPManager : MonoBehaviourPunCallbacks
{
    //public string LevelToload;
    public items[] items;
    
    public GameObject[] EnableOnLogin;
    public GameObject NewsPanel;
    public GameObject NewsView;
    //public GetPlayerCombinedInfoRequestParams info;
   // public Text GoldText;
    //public int Gold = 0;
    public GameObject[] EnableObjectsOnConnect;
    public GameObject[] DislabeObjectsOnConnect;
   
    
    void Start()
    {
        PhotonNetwork.ConnectUsingSettings();
        //LoginWithPlayFabRequest LoginRequest = new LoginWithPlayFabRequest();
        
        //LoginRequest.InfoRequestParameters = info;
       //PlayFabClientAPI.LoginWithPlayFab(LoginRequest, result =>
       //{
         //   Gold = result.InfoResultPayload.UserVirtualCurrency["GD"];
          
       //}, error => { Debug.LogError(error.ErrorMessage);{
               
         //  } });
        foreach (GameObject obj in EnableOnLogin)
        {
            obj.SetActive(true);
        }
       
        GetNews();
        //PhotonNetwork.ConnectToRegion("au");
     }   
         public void GiveBasicChets() {
   
         PurchaseItemRequest request = new PurchaseItemRequest();
        
          request.CatalogVersion = "Characters";
          request.ItemId = "NinjaChest";
          request.VirtualCurrency = "GD";
          request.Price = 0;
         PlayFabClientAPI.PurchaseItem(request, result =>
        {
           
        }, error =>
        {
            Debug.LogError(error.ErrorMessage);
        });
   }
        
    
   
    public override void OnConnectedToMaster()
    {
        foreach (GameObject obj in EnableObjectsOnConnect)
        {
            obj.SetActive(true);
        }
        Debug.Log("We are now connected to Photon!");
        foreach (GameObject obj in DislabeObjectsOnConnect)
        {
            obj.SetActive(false);
        }
        Debug.Log("We are now connected to Photon!");
    }
    public void JoinF4A()
    {
        PhotonNetwork.AutomaticallySyncScene = true;
        PhotonNetwork.JoinRandomRoom();
    }
    public override void OnJoinRandomFailed(short returnCode, string message)
    {
        CreateF4A();
    }
    public void CreateF4A()
    {
        PhotonNetwork.AutomaticallySyncScene = true;
        RoomOptions ro = new RoomOptions { MaxPlayers = 10, IsOpen = true, IsVisible = true };
        PhotonNetwork.CreateRoom("defaultF4A", ro, TypedLobby.Default);
    }
    public override void OnJoinedRoom()
    {
        SceneManager.LoadScene("FreeForAll");
    }
    public void Market()
    {
        SceneManager.LoadScene("Shop");
    }
    void GetNews()
    {
        GetTitleNewsRequest request = new GetTitleNewsRequest();
        request.Count = 10;
        PlayFabClientAPI.GetTitleNews(request, result =>
        {
            List<TitleNewsItem> news = result.News;
            foreach (TitleNewsItem item in news)
            {
                string[] output = item.Body.Split(';');
                GameObject u = Instantiate(NewsPanel, NewsView.transform.position, Quaternion.identity);
                u.transform.SetParent(NewsView.transform);

                u.transform.GetChild(0).GetComponent<Text>().text = item.Title;
                u.transform.GetChild(1).GetComponent<Text>().text = output[0];
                StartCoroutine(GetImage(output[1], u.transform.GetChild(3).GetComponent<Image>()));
            }
        }, error =>
        {
        });

    }
    IEnumerator GetImage(string url, Image image)
    {
        WWW www = new WWW(url);
        yield return www;
        Texture2D texture = new Texture2D(1, 1);
        texture.LoadImage(www.bytes);
        texture.Apply();
        Sprite sprite = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), Vector2.zero);
        image.sprite = sprite;
        image.preserveAspect = true;
    }
    //void Update()
    //{
      // GoldText.text = "Gold" + Gold;

    //}
}


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