hey i want to save leaderboards in my game i first made them with ds grids but got told that they cant be saved so good and i sould redo it so it can be saved as a JSON for that arrays would work i got told so i remade my grids in arrays thats good and all and works but before i used the ds_grid_sort i know there is also a array_sort but i dont know how to use it like a grid sort i dont want to only sort single values i have to sort 4 valus (name,time,hp,kills) to sort i want to use the time value
old code for adding a score
the new arrays i made
after we got a solution for that problem i will probably still need help with saving and loading it but letz solve this first
old code for adding a score
GML:
function add_to_leaderboard(lb_Room, lb_Name, lb_Time, lb_hp, lb_kills ){
for(i=0;i<ds_grid_width(global.grid_levels);i++;)
{
if(ds_grid_get(global.grid_levels,i,1) = lb_Room)
{
global.grid_levels[# i, 0][# 0,10] = lb_Name;
global.grid_levels[# i, 0][# 1,10] = lb_Time;
global.grid_levels[# i, 0][# 2,10] = lb_hp;
global.grid_levels[# i, 0][# 3,10] = lb_kills;
ds_grid_sort(global.grid_levels[# i, 0],1,true)
}
}
}
GML:
global.array_levels = array_create(100)//levels
for(i=0;i<100;i++;)
{
global.array_levels[i] = array_create(3)//additional information
for(j=0;j<3;j++;)
{
global.array_levels[i][j] = array_create(4)//name,time,hp,kills
for(k=0;k<4;k++;)
{
global.array_levels[i][j][k] = array_create(11)//rank 1-11
}
}
}
Last edited: