- Home /
Trying to make a highscore screen, hitting lots of errors.
Hey guys, I'm really new to unity and I'm trying to make a local scoreboard for my game, using time (so 1st place=lowest time). I based my code off of the first answer over here http://answers.unity3d.com/questions/20773/how-do-i-make-a-highscores-board.html
It's working really well, but I'm not quite there. This is what I have so far; function AddScore (name : String, score : int) {
var newScore : int;
var newName : String;
var oldScore : int;
var oldName : String;
newScore = PlayerPrefs.GetInt("Score");
newName = PlayerPrefs.GetString("Name");
for(i=0;i<10;i++){
if(PlayerPrefs.HasKey(i+"HScore1")){
if(PlayerPrefs.GetInt(i+"HScore1")>newScore){
oldScore = PlayerPrefs.GetInt(i+"HScore1");
oldName = PlayerPrefs.GetString(i+"HScoreName1");
PlayerPrefs.SetInt(i+"HScore1",newScore);
PlayerPrefs.SetString(i+"HScoreName1",newName);
newScore = oldScore;
newName = oldName;
}
else{
PlayerPrefs.SetInt(i+"HScore1",newScore);
PlayerPrefs.SetString(i+"HScoreName1",newName);
newScore = 99999999;
newName = "";
}
}
}
}
It's almost working, but on every single line that has an 'i' on it, Im getting the error "BCE0005: Unknown identifier: 'i'."
I really need to get this sorted out, and any help would be greatly appreciated. Thanks.
Answer by Eric5h5 · Feb 14, 2013 at 12:53 AM
You need to declare the "i" variable. So "`for (var i = 0...`", not "`for (i = 0...`".
Your answer
Follow this Question
Related Questions
Highscore with points and time 1 Answer
Implementing a leader board / high score (File read / write) 7 Answers
how to save and retreive high score.... 4 Answers
Unity - iOS Game Center - *Reliable* Highscore Submission 0 Answers
Save User Score On Cloud, And Showing LeaderBoard According To These Scores 3 Answers