D
dboholst
Guest
Hello,
I'm making a real time Ranking System that is drawn in screen during gameplay, but for the life of me I could not find anything.
I want to change the score but my script just constantly add a new entry in the list with the same player with different score.
Please help
I'm making a real time Ranking System that is drawn in screen during gameplay, but for the life of me I could not find anything.
I want to change the score but my script just constantly add a new entry in the list with the same player with different score.
Please help
Code:
//DRAW
for (var i=0;i<ds_list_size(score_list)-1;i++)
{
ds_list_sort(score_list,false);
var txt = string(ds_list_find_value(score_list,i));
var xx = 20;
var yy = 13 * (i*1.5);
if (i=0) //LEADING PLAYER
{
DrawSetText(c_yellow,1,Ort_small,fa_left,fa_top);
draw_text(xx,yy+35,string_upper(txt));
}
else //OTHER PLAYERS
{
DrawSetText(c_white,1,f_score,fa_left,fa_top);
draw_text(xx,yy+40,string_upper(txt));
}
}
GML:
function AddScore(_score,_name){
var str = ds_list_find_index(score_list,_name);
if (!is_string(str))
{
var item = string(_score)+" - "+_name;
if (ds_list_size(score_list) < 10)
{
ds_list_add(score_list,item);
}
else
{
ds_list_delete(score_list,10);
ds_list_add(score_list,item);
}
}
}