For the past day I’ve been trying to figure out how to make highscores for the game I made. I’ve finally decided to turn to the community for some help.
I’m a little bit confused with this part of the script:
function postScore(name, score) {
//This connects to a server side php script that will add the name and score to a MySQL DB.
// Supply it with a string representing the players name and the players score.
var hash=Md5.Md5Sum(name + score + secretKey);
var highscore_url = addScoreUrl + "name=" + WWW.EscapeURL(name) + "&score=" + score + "&hash=" + hash;
What does it mean supply it with a string? I’m just overall very confused. I’ve done the parts in the tutorial where it talks about the server. I just don’t understand part 3. Can anyone help?
http://www.unifycommunity.com/wiki/index.php?title=Server_Side_Highscores
The “string” it wants you to supply it with is the combination of the player name, player score and secret key. Something like this:
name = "Bob";
score = 400;
secretKey = "Cow45";
var hash = Md5.Md5Sum(name + score + secretKey);
Md5 is going to encrypt those values, and give you a completely scrambled string in return. The value of hash is going to look like “5edfds67f235dc6fed632rb84”.
Why is this done? It’s kind of confusing at first, but it’ll make sense in a moment.
If your High Score submission system was simply a WWW call with player name and player score, then someone could easily forge a fake high score entry to be submitted.
So, we encrypt those values and we send that encrypted value as well.
On our server, we then encrypt the name and score received. If those encryptions match, then the name and score are coming from your game (and not from someone forging it) and are authentic.
The purpose of the secretKey is just to add one more element. If you told me that your md5 string was ONLY the score and player name, I could figure out what the hash would be, and I could forge a fake entry. With the addition of a secretKey, it makes it just a little harder for someone to fake a high score entry.
Oh okay thanks for explaining that.
So do i actually have to include
name = “Bob”;
score = “playerScore”;
in the script?
I understand the rest of what your saying. Thanks for clearing that up. 
Here’s my step 3…if anyone can find anything wrong with it…
private var secretKey="5gEhu8,mh^hcdh*0^5451ygIG54GC^2"; // Edit this value and make sure it's the same as the one stored on the server
varaddScoreUrl="http://viktorlekic.co.cc/addscore.php?"; //be sure to add a ? to your url
varhighscoreUrl="http://viktorlekic.co.cc/display.php";
function Start() {
getScores();
}
function postScore(name, score) {
//This connects to a server side php script that will add the name and score to a MySQL DB.
// Supply it with a string representing the players name and the players score.
var hash=Md5.Md5Sum(name + score + secretKey);
var highscore_url = addScoreUrl + "name=" + WWW.EscapeURL(name) + "&score=" + score + "&hash=" + hash;
// Post the URL to the site and create a download object to get the result.
hs_post = WWW(highscore_url);
yield hs_post; // Wait until the download is done
if(hs_post.error) {
print("There was an error posting the high score: " + hs_post.error);
}
}
// Get the scores from the MySQL DB to display in a GUIText.
function getScores() {
gameObject.guiText.text = "Loading Scores";
hs_get = WWW(highscoreUrl);
yield hs_get;
if(hs_get.error) {
print("There was an error getting the high score: " + hs_get.error);
} else {
gameObject.guiText.text = hs_get.data; // this is a GUIText that will display the scores in game.
}
}
Only error thats popping up is this: MissingComponentException: There is no ‘GUIText’ attached to the “player” game object, but a script is trying to access it.
You probably need to add a GUIText to the game object “player”. Or your script needs to check if the component is attached before using it.
No, you don’t include those example values I used. I was just trying to demonstrate how the parameter for the md5 was created.
The secretKey is at the top of the string, and the name and score are the parameters of the function. When you call postScore, it’ll be like. Keep that in mind, that you pass in the name and score into the function when you call it:
function GameOver()
{
postScore( playerName, playerScore );
}
The error your getting is telling you what you have to do to fix it. You need to add a GUIText component to the GameObject to which this script is already attached.
okay but to fix the error I have to attach the GUI text to the game Object… right? How would I do that? I tried finding it in the GUI Text in the support part of unity 3d but couldn’t find out how to connect them?
Tried putting the GUI text as a child of the gameObject but the error still popped up.
Would I have to include a script?
btw thanks for all your help so far. 
Back to the GUI thing… Does it need the gui to find the score out?
I do have the score printed on the screen already but it’s labeled like this:
GUI.Label(Rect(10,10,200,50), "Score: " + playerScore);
would I still need to attach a gui text onto my gameObject?
Oh and still haven’t figured out how to attach the GUI text.
GUIText and the GUI class are not dependent on each other. If you are using GUI.Label to create the score display then there’s no need to use a GUIText anywhere.
You can remove that entire line about the GUIText, yes.