- Home /
postScore Server Side Highscores tutorial
Hello, I got this Sever Side Highscores working, but only for getting the scores. I mean, the function getScores() works well, but not the postScore(name, score);
What am I doing wrong ?
function Start() {
postScore("test","634");
//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); }}
Looks like the problem is then i call "postScore("test","352")" but what is wrong? The error i've got is: InvalidProgramException: Invalid IL code in HSController/$postScore$2/$:MoveNext (): IL_0029: add
UnityEngine.MonoBehaviour:StartCoroutine_Auto(IEnumerator) HSController:Start() (at Assets/Scripts/HSController.js:6)
This line (6) indicated by the error is the first line of start function (postscore("test", "634";)
Thanks!
Answer by Henrique · Jan 24, 2011 at 11:56 PM
Solved:
function postScore(name:String, score:int) {
And
function Start() {
postScore("Henry",3210);
}
Now it works fine!