GAMEMAKER Save Highscore to INI

OBJ_SCOREHIGHSCORE

CREATE EVENT

ini_open("scores.ini");//open file
global.highscore=ini_read_real("scores","high",0);//load scores high if present, otherwise set as 0
ini_close();//close ini


DRAW EVENT

draw_text(100,100,"Highest Score:="+string(global.highscore));//draw value of global.highscore


OBJ_BUTTON

score= get_integer("Enter A Score:", 0);//get an integer
if score>global.highscore//do this if bigger than current score
{
ini_open("scores.ini");//open ini
ini_write_real("scores","high",score);//write a value
ini_close();//close value
global.highscore=score;//update highscore
show_message("High Score Updated");//message

}
else//do this if not bigger than current score
{
show_message("Score Is Not Bigger Than Current Highscore");//message
}



No comments:

The Win Machine

The Road to Hell is Paved with Intervention ͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏    ...

Contact Form

Name

Email *

Message *