Having some trouble with my game’s highscores. When playing the game in-editor (Unity 3 iPhone), I can submit highscores just fine, or from the webplayer, etc.
However, the score’s I submit from my iPod touch only go into the “local scores”, they never make it online…I’ve even waited a full day and checked the MySQL database…no sign of the entries.
Is there a special catch/bit of code/check-box-enabled on an iOS device to allow it to send scores? It seems perfectly capable of viewing the online highscores table, just can’t get it to output to online.
I am using this setup:
http://www.unifycommunity.com/wiki/index.php?title=Server_Side_Highscores
With this code for submitting:
//submit sccore button- only show if score hasn't been submitted, otherwise only show "Main Menu" button
wd = 200;
ht = 40;
if (!scoreSubmitted)
{
if (GUI.Button(Rect(125 - wd/2, titleOffset + 4*voffset + 4*ht, wd, ht), "Submit Score!"))
{
//play button pressed noise
GUIControlScript.GUISoundsScript.GUISounds[1].audio.Play();
//convert string to all caps
inputName = inputName.ToUpper();
//Check if name is dirty...
// Old method
for (var x = 0; x < dirtyNames.length; x++)
{
dirtyName = false;
if (inputName == dirtyNames[x])
{
inputName = "ERR";
dirtyName = true;
break;
}
}
//submit the score if name is clean
if(!dirtyName)
{
//tell the game we have submitted the score (no spamming)
scoreSubmitted = true;
//Update local score with the inputs above
scoreKeeperLocal.postScore(inputName, gameInfoScript.currentScore);
scoreKeeperLocal.getScores();
//update global score same
scoreKeeper.postScore(inputName, gameInfoScript.currentScore);
scoreKeeper.getScores();
}
}
}
…and here is the “scoreKeeper.postScore” bit, on another 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 theName : String = name;
var hash=Md5.Md5Sum(theName + 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);
}
}
Like I said, guessing I’m just missing a compatibility/syntax issue. I DO remember I had to change “data” to “text” when upgrading to Unity 3…but even after that, it still submits fine from the editor, yet not from device.
Thanks for any input