Assets/Scripts/HSController.js(16,32): BCE0051: Operator ‘+’ cannot be used with a left hand side of type ‘Object’ and a right hand side of type ‘Object’.
at var hash = Md5.Md5Sum(name + score + secretKey);
in HSController.js
I don’t get why I’m getting this error when its a string…
Thx Martin that fix the error but no scores show up… The GUI show “Loading Score” then nothing appears. This is what I have.
function Start() {
postScore(iPhoneSettings.name , 100);
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.
var hs_post : WWW = new WWW (highscoreUrl);
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() {
guiGameObj.text = "Loading Scores";
var hs_get : WWW = new WWW (highscoreUrl);
yield hs_get;
if(hs_get.error) {
print("There was an error getting the high score: " + hs_get.error);
} else {
guiGameObj.text = hs_get.data; // this is a GUIText that will display the scores in game.
}
}