Scoreoid highscores;

I haven’t found this in any of the threads and I am just asking if anyone has done a high scores table in unity with scoreoid? I have done one in XNA and just wondered if anyone has gotten it to work in Unity and could give me some tips?

Thanks

Alright so I will try again I have managed to find some code that works with the scoreoid snippet and now I need to display all the scores that I have managed to create in scoreoid but for some reason I only get one score to display in guiText if someone could answer why this code doesn’t display all the scores I would be greatful:

  IEnumerator GetBestScores(){
     
    var url = "https://www.scoreoid.com/api/getScores";
     
    /* Unity WWW Class used for HTTP Request */
    var form = new WWWForm();

    form.AddField("api_key", "");
    form.AddField("game_id", "");
    form.AddField( "response", "xml");
    form.AddField("username", "Player Username");
    form.AddField( "order_by", "score");
    form.AddField( "order", "desc");
    form.AddField( "limit ", "10");
     
    var www = new WWW( url, form );
     
    /* Wait for request to complete */
    yield return  www;
     
    /* Check for errors */
    //remove url quotes from www.data if you need this script works on Unity
    if (www.error == null)
    {
        /* Request completed! */
    //remove url quotes from [url]www.data[/url] if you need this script works on Unity
        Debug.Log("request completed!: " + [url]www.text);[/url]
        
         XmlDocument xml = new XmlDocument();
              //remove url quotes from [url]www.data[/url] if you need this script works on Unity
          xml.LoadXml([url]www.text);[/url]
     
            //for first value
          var username = xml.GetElementsByTagName("player").Item(0).Attributes.GetNamedItem("username").Value;
          var score = xml.GetElementsByTagName("score").Item(0).Attributes.GetNamedItem("score").Value;
          if (Results.Length > 0)
          {
              for (int i = 0; i < Results.Length; i++)
              {
                  Results[i].text = i+". " + username + "......" + score;
                
              }
          }
     
       
         
    } 
        else {
        /* Something wrong! */
     //remove url quotes from [url]www.error[/url] if you need this script works on Unity
        Debug.Log("WWW Error: "+ [url]www.error);[/url]
     }
    }

it is the Array with guitext that is giving me issues

Thanks

looking at your code :

possible problem : you are parsing the xml values only once outside of your loop to populate your items

Thanks for reply, I just tried your suggestion and may have done it wrong because it kept crashing unity. I am pretty sure I have something jacked up but I am going to look at the Scoreoid API one more time and see what I am missing.

If you can open a support ticket would be glad to see if I can help you.

Thanks,
Almog

Thanks for the reply Almog will do.

This is what I have so far:

 XMLParser parsing = new XMLParser();
    void Start()
    {StartCoroutine(GetBestScores());}

 IEnumerator GetBestScores()
    {
          var url = "https://www.scoreoid.com/api/getScores";



        /* Unity WWW Class used for HTTP Request */

        var form = new WWWForm();



        form.AddField("api_key", "");

        form.AddField("game_id", "");

        form.AddField("response", "xml");

        form.AddField("order_by", "score");

        form.AddField("order", "desc");

        form.AddField("limit ", "10");
       

        var highscoreurl = new WWW(url,form);



        /* Wait for request to complete */

        yield return highscoreurl;
       
        /* Check for errors */

        //remove url quotes from www.data if you need this script works on Unity

        if (highscoreurl.error == null)
        {

            /* Request completed! */

            //remove url quotes from [url]www.data[/url] if you need this script works on Unity
          
            Debug.Log("request completed!: " + highscoreurl.text);
            XmlDocument xml = new XmlDocument();

            //remove url quotes from [url]www.data[/url] if you need this script works on Unity
             xml.LoadXml(highscoreurl.text);
             
       var node = parsing.Parse( gameObject.guiText.text = highscoreurl.text);
       }
        else
        {


            /* Something wrong! */

            //remove url quotes from [url]www.error[/url] if you need this script works on Unity

            Debug.Log("WWW Error: " + highscoreurl.error);

        }

    }

Now I am trying to use the lightweight parser script from the community wiki but to no avail because I am getting all my username and score information in xml style code not just the string values.

Any suggestions.

Just a question to the community, does anyone know how to parse the xml data derived for the WWW class, such as the sample that I have in scoreoid, I have to tried to try and catch the int32.parse of the the data but getting the same result as the the layout on the server where nothing is organized by just grabbing the name and the score.

Thanks

Got it solved with only two responses, thanks for those who responded, Almog I will probably write a tut to show how I did it but for now I am going to sleep.

Here is the code for Scoreoid in case anyone is trying to find a server to host their highscores, even though scoreoid does more than that but I have seen a few people ask about it and didn’t understand the api on how to get high scores or even post them, I am doing the get high scores as posting them should be easy

     WWW highscoreurl;
     public GUIText[] Text_1,Text_2;
    void Start()
    {
        var url = "https://www.scoreoid.com/api/getScores"; // api url to get the highscores 



        /* Unity WWW Class used for HTTP Request */

        var form = new WWWForm();



        form.AddField("api_key", "secret key from scoreoid");

        form.AddField("game_id", "game id from scoreoid");

        form.AddField("response", "xml");

        form.AddField("order_by", "score");

        form.AddField("order", "desc");

        form.AddField("limit ", "10");


        highscoreurl = new WWW(url, form);
        StartCoroutine(GetBestScores(highscoreurl));
    
    }

 IEnumerator GetBestScores(WWW highURL)
    {
        /* Wait for request to complete */

        yield return highURL;
       
        /* Check for errors */

        //remove url quotes from www.data if you need this script works on Unity

        if (highURL.error == null)
        {

            /* Request completed! */

            //remove url quotes from [url]www.data[/url] if you need this script works on Unity

            Debug.Log("request completed!: " + highURL.text);
            XmlDocument xmlDoc = new XmlDocument();
    
            //remove url quotes from [url]www.data[/url] if you need this script works on Unity
            xmlDoc.LoadXml(highURL.text);
           
          
            var username = xmlDoc.GetElementsByTagName("player");
            var score = xmlDoc.GetElementsByTagName("score");
         
            for (int i = 0; i < username.Count; i++)
            {
                
                for (int j = 0; j < score.Count; j++)
                {
                    if (i == 0  j == 0)
                    {
                        Text_1[i].pixelOffset = new Vector2(-375, 250);
                        Text_2[j].pixelOffset = new Vector2(350, 250);
                        Text_1[i].text = ( i+1+". "  +username[i].Attributes.GetNamedItem("username").Value); 
                        Text_2[j].text = (score[j].Attributes.GetNamedItem("score").Value);
                    }
                   
                }
            }
         
         
}
        else
        {


            /* Something wrong! */

            //remove url quotes from [url]www.error[/url] if you need this script works on Unity
           
            Debug.Log("WWW Error: " + highscoreurl.error);

        }

    }

I was over thinking this wayyyy too much, it is already parsed and I am use the XML DOM method to get the certain strings that I need in order to display. Don’t forget to put up a gui text and just make them an array to do it. Here is a screen shot of our game, this game is on windows phone 7 and we are bringing it to Android: Get Cho’Chickn the high scores in unity

Is Scoreoid gone?

Great question, I can’t find it anywhere now.