High score on the wiki:

I am trying to get the high score here- http://wiki.unity3d.com/index.php?title=Server_Side_Highscores set up.

I ahve the DB set up the php files uploaded and all set. But I am getting errors on the md5 file.

#pragma strict
 
static function Md5Sum(strToEncrypt : String)
{
	var encoding = System.Text.UTF8Encoding();
	var bytes = encoding.GetBytes(strToEncrypt);
 
	// encrypt bytes
	var md5 = System.Security.Cryptography.MD5CryptoServiceProvider();
	var hashBytes:byte[] = md5.ComputeHash(bytes);
 
	// Convert the encrypted bytes back to a string (base 16)
	var hashString = "";
 
	for (var i = 0; i < hashBytes.Length; i++)
	{
		hashString += System.Convert.ToString(hashBytes[i], 16).PadLeft(2, "0"[0]);
	}
 
	return hashString.PadLeft(32, "0"[0]);
}

And here is the JS code on the gameobject.

private var secretKey="blah"; // Edit this value and make sure it's the same as the one stored on the server
var addScoreUrl="http://www.blah.com/Splitting8s_HS/addscore.php?"; //be sure to add a ? to your url
var highscoreUrl="http://www.blah.com/Splitting8s_HS/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 = md5functions.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.text; // this is a GUIText that will display the scores in game.
    }
}

Errors…

1377240--69801--$error.jpg

1377240--69802--$error2.jpg

Those single slashes on line 1,2,3 have to be double slashes, same at end.

Those are not in the file…I put those in here…

Why? Get rid of them. Also, use the script that was posted on the wiki as-is, since your modification is a syntax error.

–Eric

I did EricI didn’t modify anything except what I was suppose to…what is wrong???

Pretty sure a comment would be “//”, not “/”

“static function md5functions.Md5Sum(strToEncrypt : String)” isn’t something that would compile; use the exact code on the wiki instead.

–Eric

I have the exact code …I am getting a lot of errors ont he hs controller code…

Do I need to put that line of code on the server side for the md5 check…the lines under the md5 code???

I tried the c# version as well and full of errors…I used the exact code…

Use this instead, I think I had problems with the wiki script so I used this, its almost exactly the same but better explained:

Also its free.