Search Unity

Free easy to implement LeaderBoard

Discussion in 'Works In Progress - Archive' started by carmine, May 6, 2012.

  1. adev

    adev

    Joined:
    May 30, 2013
    Posts:
    3
    alright. thanks Carmine. i'll work the way around around it.
    i think it could be a cool feature if you're still mantaining the server code.
     
  2. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
    Understandable. You had mentioned though that it was also used for another project so I thought I'd bring it up.
     
  3. copypasteearth

    copypasteearth

    Joined:
    Jun 7, 2013
    Posts:
    14
    hello carmine, im getting 404 Not Found when running the example, do you have a suggestion, im really anxious to use this, its easy to understand and all, you didnt remove the example and put on unity store did you?
     
  4. carmine

    carmine

    Joined:
    Jan 4, 2012
    Posts:
    394
    I was literally just updating the website... try again:

    http://dreamlo.com
     
  5. copypasteearth

    copypasteearth

    Joined:
    Jun 7, 2013
    Posts:
    14
    im still getting the same thing
     
  6. copypasteearth

    copypasteearth

    Joined:
    Jun 7, 2013
    Posts:
    14
    now it say error unknown verb
     
  7. copypasteearth

    copypasteearth

    Joined:
    Jun 7, 2013
    Posts:
    14
    maybe i got my url when you were updating, ill start over again
     
  8. copypasteearth

    copypasteearth

    Joined:
    Jun 7, 2013
    Posts:
    14
    still unknown verb 0, anything?
     
  9. carmine

    carmine

    Joined:
    Jan 4, 2012
    Posts:
    394
    Email me directly: carmine@carmine.com

    Cut and paste the URL it's trying to access.
     
  10. carmine

    carmine

    Joined:
    Jan 4, 2012
    Posts:
    394
    Did you go to the website and get your private/public URL codes and put them in the code?
     
  11. copypasteearth

    copypasteearth

    Joined:
    Jun 7, 2013
    Posts:
    14
    im going to email you right now
     
  12. avatsaev

    avatsaev

    Joined:
    Jul 25, 2013
    Posts:
    1
    thank you for this i will add it to my game.
     
  13. stevesalmond

    stevesalmond

    Joined:
    Aug 14, 2013
    Posts:
    7
    This looks awesome! I'm planning to use it for my 7dfps game jam entry. Nice work :)
     
  14. stevesalmond

    stevesalmond

    Joined:
    Aug 14, 2013
    Posts:
    7
  15. bigkahuna

    bigkahuna

    Joined:
    Apr 30, 2006
    Posts:
    5,434
    Just a head's up, this package (and the zip file) crashes Unity 3.5.7 (in the case of the package) and locks it up (in the case of the zip file). Probably why in the Asset store it says it only works with versions 4.0+. Might want to edit the first post to mention this.
     
  16. TheIncognito

    TheIncognito

    Joined:
    May 9, 2013
    Posts:
    5
    How would I modify it to go into only the time it takes to finish the level?
     
  17. Le-Capitaine

    Le-Capitaine

    Joined:
    Jan 23, 2014
    Posts:
    33
    TREMBLE BEFORE THE MIGHT OF THE THREAD NECROMANCER!

    So I tried this out and so far, I can't say I've had any luck. Would you happen to know a way to put the data not into Labels, but into GUIText? I tried

    Code (csharp):
    1.  
    2.  
    3.     public GUIText[] scoresText;
    4.     void Start () {
    5.         board = GameObject.Find ("dreamloLeaderboard").GetComponent<dreamloLeaderBoard> ();
    6.  
    7.         dreamloLeaderBoard.Score[] scoreList = board.ToScoreArray();
    8.         foreach (dreamloLeaderBoard.Score currentScore in scoreList) {
    9.         scoresText[currentScore].text = currentScore.playerName + " " + currentScore.score.ToString();
    only to discover that it doesn't work that way. Furthermore, trying to straight-up call the array on one specific line nets me an NRE within the leaderboard script...

    edit: Actually, nevermind all of that...I finally got it to work. This whole necromancy business was all for nothing. Welp.
     
    Last edited: Apr 21, 2014
  18. carmine

    carmine

    Joined:
    Jan 4, 2012
    Posts:
    394

    You need to have the GUIText attached to an object. Then you need to get a reference to the GUIText components attached to that object.

    So lets say you made an object called "GUITextThing" and you attached 10 GUITexts to it....

    I'm just typing this off the top of my head.

    Code (csharp):
    1.  
    2. GameObject textThing = GameObject.Find("GUITextThing");
    3. scoresText = textThing.GetComponents<GUIText>();
    4. foreach (dreamloLeaderBoard.Score currentScore in scoreList) {
    5.  
     
  19. Le-Capitaine

    Le-Capitaine

    Joined:
    Jan 23, 2014
    Posts:
    33
    Lots of thanks nevertheless -- I slogged myself through to a solid-ish implementation. I see there's a little hack above to allow for multiple times the same name, but what's the line I need to tinker with to allow actual doubles within the playerName variable?

    (That's of course assuming I'm allowed to tinker with these lines at all.)
     
    mhmtemnacr likes this.
  20. carmine

    carmine

    Joined:
    Jan 4, 2012
    Posts:
    394
    dl.AddScore(this.playerName, totalScore);

    It expects the playerName field field to be unique, but you can really put whatever you want in there. So for instance, you could make the playerName field something unique every time and then do a string split to get the playerName part out. Such as

    dl.AddScore(this.playerName + "~" + totalScore, totalScore);

    So for instance, if my name is Carmine and my score is 100, it would store: "Carmine~100, 100"

    Then when you're displaying the scores you could do something like...

    Code (csharp):
    1.  
    2. foreach (dreamloLeaderBoard.Score currentScore in scoreList) {
    3.   string[] temp = currentScore.playerName.Split(new char[] {'~'});  // creates an array of strings "Carmine" and "100"
    4.  
    5.   string theName = temp[0];  // now we got the name...
    6.    
    7.    // do whatever here.
    8.  
    9. }
    10.  
     
  21. Le-Capitaine

    Le-Capitaine

    Joined:
    Jan 23, 2014
    Posts:
    33
    Effing excellent. The only problem I've got now is random (literally random) NREs that get thrown up, possibly due to frame-skipping. (On an unrelated note -- you happen to have something for that? To update coroutines more than once per frame?)
     
  22. carmine

    carmine

    Joined:
    Jan 4, 2012
    Posts:
    394

    Not sure what you mean... maybe want to check the scripting forum for help on that.
     
  23. akkiDev

    akkiDev

    Joined:
    Aug 7, 2013
    Posts:
    70
  24. zbig

    zbig

    Joined:
    Aug 11, 2014
    Posts:
    8
    Hi, Im am having a blast with my first Unity project, and was looking for a online leaderboard solution.
    I really like your approach carmine. I will test it hopefully today and post the results.
    What I like best is that you can simply try it out without making any accounts, unlike those pseudo free sites akkiDev linked to.
    I do not want to "burn" my free ticket by the try and error on my first project. I can still choose something more complex later. You seem to fill the gap with your solution.

    Edit: I just gave dreamlo a try. It works like a charm!
    It took me a bit longer, as I use JS in my game, so I had to adjust the code taken from the sample a bit. My scoreboard is working. Thank you carmine !
     
    Last edited: Aug 11, 2014
  25. zbig

    zbig

    Joined:
    Aug 11, 2014
    Posts:
    8
    I thought I will post it here as it might be interesting for others:
    My score is based on time. The shorter time the better. Because I use JS I have to work with String array. I added following method to the "dreamloLeaderBoard", which allows me to get the String[] as result sorted ascending by "seconds":

    Code (CSharp):
    1.     public string[] ToStringArraySortedByTime()
    2.     {
    3.         Score[] scoreList = this.ToScoreArray();
    4.        
    5.         if (scoreList == null) return null;
    6.        
    7.         List<Score> genericList = new List<Score>(scoreList);
    8.        
    9.         genericList.Sort((x, y) => x.seconds.CompareTo(y.seconds));
    10.  
    11.         string[] rows = new string[genericList.Count];
    12.         int i = 0;
    13.  
    14.         foreach (Score s in genericList) {
    15.  
    16.             string current = s.playerName.ToString() + "|" +
    17.                 s.score.ToString() + "|" +
    18.                     s.seconds.ToString() + "|" +
    19.                     s.shortText + "|" +
    20.                     s.dateString;
    21.  
    22.             rows[i] = current;
    23.             i++;
    24.         }
    25.         return rows;
    26.  
    27.     }
     
  26. omriysh

    omriysh

    Joined:
    Sep 3, 2014
    Posts:
    4









    Hi Carmine!

    First of all, I would like to thank you. Dreamlo is awesome!
    But I do have a problem. I made a board yesterday, and my scene is able to save scores (I see the scores on dreamlo.com), but not able to pull them properly. I am trying to get the position of the player, out of 4 scores that are saved. This is my code:


    List<dreamloLeaderBoard.Score> scoreList = leaderboard.ToListLowToHigh();

    Debug.Log("Starting to look");
    Debug.Log (scoreList.Count);
    for(int i = 0; i < scoreList.Count; i++)
    {
    Debug.Log (scoreList.playerName);
    if(scoreList.playerName == playerName)
    {
    Debug.Log("Found");
    leaderboardText.text = "Your leaderboard position is: " + i;
    break;
    }
    }



    When I run the game, the logs I get are: "Srarting to look", "0".
    I don't know why there aren't any players on the list when 4 are saved on the website.

    Did I do anything wrong?
     
  27. carmine

    carmine

    Joined:
    Jan 4, 2012
    Posts:
    394
    Hello.. It looks like your code is weird a bit... I think you mean something more like

    for (int i = 0; i < scoreList.Count; i++)
    {
    if (scoreList.playerName == playerName
    ...

    }

    Also... when are you hitting the website to get the scores?

    Feel free to email me directly: carmine@carmine.com so I can respond more quickly.
     
  28. gamersden

    gamersden

    Joined:
    Nov 18, 2014
    Posts:
    8
  29. Amexoz

    Amexoz

    Joined:
    Mar 18, 2015
    Posts:
    1

    Hi.

    Im developing an Android App and wanted to try out your leaderbord... But im stuck with it (Im new to Unity). I have a problem finding a good documentation for how to integrate the leaderbord into the app.. It shows the URL:s... But not WHERE to put it.. Could someone help me with it?
     
  30. heipp123

    heipp123

    Joined:
    Aug 1, 2015
    Posts:
    8
    hi
    i was trying to do simple score submit
    i added gui button with this
    dl.AddScore(playerName, totalScore);
    i have the reference but not happens thanks.

    -solved.

    how can i print(Debug.log) his ranking.
    thanks.
     
    Last edited: Sep 28, 2015
  31. carmine

    carmine

    Joined:
    Jan 4, 2012
    Posts:
    394

    I'm glad you solved it. You can go into my .cs files and put in your own debugging code if you want.
     
  32. danny1111

    danny1111

    Joined:
    Nov 24, 2015
    Posts:
    5
    Hi, I've done 'dreamloLeaderBoard dl;', 'this.dl = dreamloLeaderBoard.GetSceneDreamloLeaderboard ();', and...
    dl.AddScore (username, SpeedController.score);
    dl.LoadScores ();
    print (dl.highScores);

    It comes up with the error: Assets/Scripts/ClickController.cs(54,17): error CS0120: An object reference is required to access non-static member `ClickController.dl'.
    What's wrong?
     
  33. carmine

    carmine

    Joined:
    Jan 4, 2012
    Posts:
    394
    I have no idea what ClickController.dll is. That's something else in your code and is unrelated to dreamlo. It's in a completely different scripts folder than my asset.
     
  34. tvance929

    tvance929

    Joined:
    May 15, 2015
    Posts:
    14
    So 3 years ago you said you could guarantee this would be up for a couple of years but not 5 ... I was just getting ready to use your AWESOME FREE service ... but do you happen to have any updates on how long this will continue to exist?
     
  35. carmine

    carmine

    Joined:
    Jan 4, 2012
    Posts:
    394
    Hello,
    It's still up and running! and I got millions of scores in there now! I have no intention of taking it down. It's working out really great for me, and I'm happy to provide this service.

    -Carmine
     
    RavenOfCode likes this.
  36. tvance929

    tvance929

    Joined:
    May 15, 2015
    Posts:
    14
    Amazing...I'll make sure to give something for the effort! THANKS SO MUCH!!!
     
  37. RavenOfCode

    RavenOfCode

    Joined:
    Apr 5, 2015
    Posts:
    869
    I just found this thread, when I realized it was 3 years old I was disappointed as I thought it was no longer working, but you proved me wrong. :)
     
  38. tvance929

    tvance929

    Joined:
    May 15, 2015
    Posts:
    14
    RavenOfCode likes this.
  39. carmine

    carmine

    Joined:
    Jan 4, 2012
    Posts:
    394
    Hey everyone!
    I think I may have gotten the CORS issue working for WebGL builds. Please give it a shot.

    Thanks!

    -Carmine
     
  40. kafanasiff

    kafanasiff

    Joined:
    Sep 25, 2013
    Posts:
    31
    Hi, thanks for making this, it's great! I've implemented your leaderboardd service in my latest game for Ludum Dare 35, called Munchy Monsters.

    I've noticed that the leaderboards are working in my PC version and when I run a web version off my machine, but when I host the web version online (like the embedded version on the page linked above), then the leaderboards don't work. Do you know if that's a limitation of web builds in Unity, or am I doing something wrong that could get this to work?

    Thanks a bunch!
     
  41. carmine

    carmine

    Joined:
    Jan 4, 2012
    Posts:
    394
    There are issues with cross-site-scripting in web versions. I have the necessary setup on my server, but I'm wondering if you need to place a .xml file or something on your end to allow it.
     
  42. kafanasiff

    kafanasiff

    Joined:
    Sep 25, 2013
    Posts:
    31
    Thanks for getting back to me so quickly! I think you are correct about the xml file. It seems like this page from the Unity docs might contain the answer: http://docs.unity3d.com/Manual/SecuritySandbox.html

    I'm at a bit of a loss on how to implement this... any suggestions?

    I tried making the crossdomain.xml file and uploading it with my content to dropbox, but that didn't seem to work. I notice in the browser console that it is loading that file from your end, which seems like the correct way as per the documents above. Not sure what it is that I'm supposed to do on my end to make this work. Do I need another xml file?

    edit - also tried adding the url of my game to the project settings -> www security emulation field but that doesn't seem to work...
     
  43. carmine

    carmine

    Joined:
    Jan 4, 2012
    Posts:
    394
    Try a host other than dropbox. I've heard of a lot of problems with this kind of thing and dropbox.
     
  44. kafanasiff

    kafanasiff

    Joined:
    Sep 25, 2013
    Posts:
    31
    Thanks, I will do that!

    Edit - Same problem when hosted on Google Drive. Will try somewhere else...
     
    Last edited: Apr 18, 2016
  45. artouiros

    artouiros

    Joined:
    Mar 10, 2015
    Posts:
    8
    Hello, this looks so easy to implement. I was trying to use google play serivices for leaderboards, but it has so much problems, if the user doesn't have GPServices updated it ask user to update and then install play games which noone will do when he wants just to play the game.

    But I have one question, if one uses pushes score as "username35" and another user uses the same username, what happens? I guess it will update the score of previous user, any way to avoid this?
     
  46. carmine

    carmine

    Joined:
    Jan 4, 2012
    Posts:
    394
    Hello. The username is the unique key. You could always add a guid to the name and later on do a split. Or use the machine's unique ID in the name and then split the reuslts as well.


    Also.. I don't know what GPServices is? but the code literally only uses the WWW object. (take a look for yourself it's very little code) it isn't using anything special at all.
     
  47. artouiros

    artouiros

    Joined:
    Mar 10, 2015
    Posts:
    8
    google play servicies + google play games, it's a leaderboard/achievement which is using google accounts, but ir requires a pretty big library + user haave to install play servicies which is around 100mb
     
    Last edited: Sep 1, 2016
  48. carmine

    carmine

    Joined:
    Jan 4, 2012
    Posts:
    394
    I'm not using google play services or anything. It's just the WWW library which is party of Unity. You can look at the code.
     
  49. artouiros

    artouiros

    Joined:
    Mar 10, 2015
    Posts:
    8
    What's the best practice to tell user he is not in the 5000 list? (because dreamlo supports only 5000 entires). I don't want to tell user he is so bad so he is not in leaderboard. Is dreamlo source code closed? It would be great if you can share it with community.
     
  50. carmine

    carmine

    Joined:
    Jan 4, 2012
    Posts:
    394
    Hey,
    If you donate $5 I also raise the limit to 10,000 scores. I've had a handful of people donate more and I gave them more scores. I limit it to 5,000 scores for free users.

    Out of the thousands of leaderboards in the system, only 0.5% (less than 1%) have reached 5,000 scores.

    -Carmine