• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

[AUTOSOLVED] Problem with online scoreboard

M

MarcosP

Guest
Im trying to implement it with GM Scoreboard but something is going wrong.
I have this scoreboard:


And im using this code to get it to a ds_map:

Code:
var gmsb_map = json_decode(r_str);
var gmsb_status = ds_map_find_value(gmsb_map , "status");

var current_key = ds_map_find_first(gmsb_map);
var size = ds_map_size(gmsb_map);
global.names = ds_list_create();
global.points = ds_list_create();

for (var i = 0; i < size; i++){

    global.names[i] = ds_map_find_value(gmsb_map,current_key);
    current_key = ds_map_find_next(gmsb_map, current_key);
   
    global.points[i] = ds_map_find_value(gmsb_map,current_key);
    current_key = ds_map_find_next(gmsb_map,current_key);

}
And then this to draw it:

Code:
draw_set_font(fnt_font);
draw_set_color(c_white);

for(var i=0;i<10;i++){
     draw_text(room_width/5, (room_height/11)*i+50, string(i+1));
     draw_text(3*room_width/5,(room_height/11)*i+50, global.names[i]);
     draw_text(5*room_width/6, (room_height/11)*i+50, string(global.points[i]));
}
But what i get it this:



I have tried some things but i dont know with its not in order. Any help is appreciated.
 
M

MarcosP

Guest
Allright so apparently ds_maps don't have any order.
I just changed this part of the code and now it works, in case someone is interested
Code:
for (var i = 0; i < size; i++){

    global.names[i] = ds_map_find_value(gmsb_map,"p"+string(i+1));
    
    global.points[i] = ds_map_find_value(gmsb_map,"s"+string(i+1));

}
The keys of the names are p1,p2,p3... and the keys of the scores are s1,s2,s3...
 
Top