Highscore with Dreamlo
Hello dear Unity Community
I'm new to coding and Unity and in need of your expertise.
I'm trying to get a highscore leaderboard for my "fall & catch" game. Right now I have a working game, that shows the score in a GUI. The Score is visible throughout all of the scenes and also in the game over view.
I've found Dreamlo (http://dreamlo.com/) but I don't have any idea, how I can implement my score/points to this script. Like I said, I'm an absolute newbie and I've tried to get it with this tutorial (https://vk.com/video-27035376_171145280) but the lack of knowledge drives me crazy.
I'm using this script to receive the player score:
#pragma strict
var points:int = 0;
var anzeige:UnityEngine.UI.Text;
function Update () {
anzeige.text = points + '';
}
... but how can I implement the points (score) to Dreamlo? Well that's the big question.
I'm already thank you for your time and appreciate your help!
Thank you Ali for your answer. Probably I'm to dumb to get it work or you misunderstood my question. The code you wrote is a simple String and all I get is a GUI that shows "score: and the points".
What I'm trying to achieve is to implement the scores in to a $$anonymous$$erboard. For that I've found the Dreamlo Database: http://dreamlo.com/.
But I don't know how to get a $$anonymous$$erboard Screen, that shows the scores of the people who played my game.
Thank you for your help! Appreciate it!
sorry i will convert it to comment i thought it's just about text .
ok i have cheeked this guy web site it seems he made his own server to host developers leader boards so i will try to cheek the tutorials & as i told you i have never worked with that but i wll try.
Thank you so much for your time! I've been watching several tutorials but I haven't figured it out how it works with my score system. I will try around - should you get it, I would appreciate to hear from you. But for sure I say already thank you for your time!!!
If I do the tutorial I get it to upload the score ... my main problem is that I don't know how to combine my existing score script with dreamlo ... in fact, all that i want is that the score that I get from my script, that this one gets uploaded and the player needs to put his name in.
The Tutorial works fine ... but I really don't have a clue how to combine the two together ...
... I've a lot to learn! :D
I appreciate your help sooooooo much!!!!
in this case all you need wen calling this function
AddNewHighscore(string generated from input field, points);
Thanks for that Ali! But you know what ... I don't have any Idea where to put it ... I'm really really really sorry for taking your time! I've started 1 month ago a with a further education to Unity ... but my knowledge is really really bad.
Right now I've my simple score unityscript and it works:
#pragma strict
var points:int = 0;
var anzeige:UnityEngine.UI.Text;
function Update () {
anzeige.text = points + '';
}
... but how i unterstand it so far, the dreamlo script would use a different kind of score system ... and now I really don't know where to put it.
If you know how, I will be soooo happy ... If not, no problem. I don't want to s$$anonymous$$l your time!
Appreciate your help a lot!
Answer by Ali-hatem · May 01, 2016 at 08:10 PM
so i have edited minor things to you & you don't need to look @ the whole script just look @ my 5 comments inside the script & sorry it's in c# :
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class Dreamlo : MonoBehaviour {
int points = 85;//add this value to AddNewHighscore function
string user = "FIVESIGN";//& this you can replace it with string from input field
public Text anzeige;
const string privateCode = "8emSDmwcGkS8-Jtzi27sCQQLT30aNynE-PUTK1w2B-0g";
const string publicCode = "572658d06e51b60644e2625c";
const string webURL = "http://dreamlo.com/lb/";
public Highscore[] highscoresList;
void Awake (){
//call this function to upload & put your variables inside braces
AddNewHighscore (user,points);
DownloadHighscores();// & this to download
}
public void AddNewHighscore(string username, int score) {
StartCoroutine(UploadNewHighscore(username,score));
}
IEnumerator UploadNewHighscore(string username, int score) {
WWW www = new WWW (webURL + privateCode + "/add/" + WWW.EscapeURL (username) + "/" + score);
yield return www;
if (string.IsNullOrEmpty (www.error))
print ("Upload Successful");
else {
print ("Error uploading: " + www.error);
}
}
public void DownloadHighscores() {
StartCoroutine("DownloadHighscoresFromDatabase");
}
IEnumerator DownloadHighscoresFromDatabase() {
WWW www = new WWW(webURL + publicCode + "/pipe/");
yield return www;
if (string.IsNullOrEmpty (www.error)) {
FormatHighscores(www.text);
}
else {
print ("Error Downloading: " + www.error);
}
}
void FormatHighscores(string textStream) {
string[] entries = textStream.Split(new char[] {'\n'}, System.StringSplitOptions.RemoveEmptyEntries);
highscoresList = new Highscore[entries.Length];
for (int i = 0; i <entries.Length; i ++) {
string[] entryInfo = entries[i].Split(new char[] {'|'});
string username = entryInfo[0];
int score = int.Parse(entryInfo[1]);
highscoresList[i] = new Highscore(username,score);
print (highscoresList[i].username + ": " + highscoresList[i].score);
//this line will change the ui text
anzeige.text = (highscoresList [i].username + ": " + highscoresList [i].score);
}
}
}
public struct Highscore {
public string username;
public int score;
public Highscore(string _username, int _score) {
username = _username;
score = _score;
}
}
What about replacing a score with a lower one not a higher score for the quickest time for ecample
Ins$$anonymous$$d of replacing the score if it is higher than the previous one, replace if it is lower.
@firebro113 the dreamlo leaderboard system don't support that its only use the higher score
check out the developers page http://dreamlo.com/developerIf the same name is added twice, we use the higher score.
How to upload username and score by taking user input and to show the input field only first time, after that update score in the existing username.?
you need to store data in the device (0/1) after taking user input set the stored value to (1) and at start load the data if (0) show input field if (1) don't show
Answer by AlexStf · Mar 31, 2017 at 12:25 PM
Hi guys, been struggling for days with this dreamlo leaderbord and can't get it to work , can you please take a look at my code ? any kind of help will be awesome ! , thank you in advance!
using UnityEngine;
using System.Collections;
public class Highscores : MonoBehaviour {
const string privateCode = "";
const string publicCode = "";
const string webURL = "http://dreamlo.com/lb/";
DisplayHighscores highscoreDisplay;
public Highscore[] highscoresList;
static Highscores instance;
int score;
string username;
void Awake() {
int score = GetComponent<GController> ().highscore;
string username = GetComponent<InputName>().username;
Highscores.AddNewHighscore (username, score);
highscoreDisplay = GetComponent<DisplayHighscores> ();
instance = this;
}
have you added privateCode and publicCode or they are = "" as in your script
i think DisplayHighscores script have a method to display highscore which you are not calling you are just calling the script in this line
highscoreDisplay = GetComponent<DisplayHighscores> ();
Answer by firebro113 · Apr 08, 2018 at 02:38 PM
Sebastian Lague has created tutorial videos on how to implement dreamlo into a Unity game.
https://www.youtube.com/watch?v=KZuqEyxYZCc&list=PLFt_AvWsXl0cgcFnNTo-Qqb9BwikZ
Your answer
Follow this Question
Related Questions
Highscore with player prefs help. (JAVASCRIPT) 0 Answers
Adding score in if statement within Update() happens continuously. 2 Answers
Scoring only one or zero in one InputField? 0 Answers
Help With Score C# Error CS0131 1 Answer
Making a league 4 Answers