Thanks for answer.So I made my little research.Now I know what is arrays and I loops.I am familiar with global variables. but I don't really know to figure it out with that loops and arrays and ini files and how player can write into that high score tab .
You can have a global array highscore_entry_score, a global array highscore_entry_name and a global variable highscore_entry_amount.
Ini files are usually not the best idea to store highscores, as players can relatively easily interprete them and cheat.
However, they are the easiest to use in GameMaker (only by a little, but still) and they'll probably suffice for your purposes, so I'll use these.
You can then load highscores from the ini file as follows:
Code:
ini_open("highscores");
global.highscore_entry_amount = 10; // highscore table contains 10 scores
for(var i = global.highscore_entry_amount - 1; i >= 0; --i) {
global.highscore_entry_name[i] = ini_read_string(string(i + 1), "name", "Not available");
global.highscore_entry_score[i] = ini_read_real(string(i + 1), "score", 0);
}
ini_close();
and you can save the highscores to the ini file as follows:
Code:
ini_open("highscores");
for(var i = global.highscore_entry_amount - 1; i >= 0; --i) {
ini_write_string(string(i + 1), "name", global.highscore_entry_name[i]);
ini_write_real(string(i + 1), "score", global.highscore_entry_score[i]);
}
ini_close();
When you've got a new score S from a player with the name N, you can add this score to the highscore table as follows:
Code:
for(var i = 0; i < global.highscore_entry_amount; ++i) {
if global.highscore_entry_score[i] < S {
for(var j = global.highscore_entry_amount - 2; j >= i; --j) {
global.highscore_entry_name[j + 1] = global.highscore_entry_name[j];
global.highscore_entry_score[j + 1] = global.highscore_entry_score[j];
}
global.highscore_entry_name[i] = N;
global.highscore_entry_score[i] = S;
break;
}
}
As for drawing the highcore table to the screen and getting a name input from the player, there are tons of ways to do that, depending on which UI looks better to you.
For getting a name from the player, you can use the get_string for debugging, as it is the easiest to implement.
You'll want to either use keyboard_string or get_string_async in your final product though.