N
nicoltoons
Guest
Hi!,
I'm pretty new to http requests. Please I need help understanding what goes into the http asynchronous event when I went to retrieve the information from a JSON file and show players when they click on the leaderboard button. I am using dreamloo for my leaderboards
I check if the player's score is higher than the last one he got and call this
leaderboard = http_get("http://dreamlo.com/lb/(my code)/add/"+string(global.name)+ "/"+string(global.highscore))
}
That changes the highscore to the lastest one
then I call this in the leaderboard left pressed event
theData = http_get("http://dreamlo.com/lb/(my code)/json")
This is a player's data from the json file
"name": "Tom","score": "304","seconds": "0","text": "","date": "9/12/2018 5:04:49 PM"
HTTP EVENT
if ds_map_find_value(async_load, "id") == theData
{
map = json_decode(async_load[? "result"]);
if(map == -1)
{
show_message("invalid result")
}
else
{
if(ds_map_exists(map, "dreamlo"))
{
dreamlo = map[? "dreamlo"];
show_message("Dreamlo: " + string(dreamlo))
if (dreamlo==-1)
{
show_message("invalid result")
}
else
{
if (ds_map_exists(dreamlo,"leaderboard"))
{
leaderboard = dreamlo[? "leaderboard"]
show_message("Leaderboard: " +string(leaderboard))
}
if (leaderboard==-1)
{
show_message("invalid result")
}
else
{
if (ds_map_exists(leaderboard,"entry"))
{
entry = leaderboard[? "entry"]
show_message("Event: " +string(entry))
}
if entry ==-1
{
show_message("invalid result")
}
else
{
size = ds_list_size(entry)
for (var i= 0; i< size; i++)
{
name = ds_list_find_value(entry,i) //got stuck here
draw = true
}
}
}
}
}
}
}
ds_map_destroy(map)
ds_map_destroy(dreamlo)
ds_map_destroy(leaderboard)
ds_list_destroy(entry)
}
At the moment, this is what I am drawing to the screen
draw_text(500,16+(cell_size*i), string(name))
and it's drawing no 1 and 3 instead of the names contained in entry
I'm pretty new to http requests. Please I need help understanding what goes into the http asynchronous event when I went to retrieve the information from a JSON file and show players when they click on the leaderboard button. I am using dreamloo for my leaderboards
I check if the player's score is higher than the last one he got and call this
leaderboard = http_get("http://dreamlo.com/lb/(my code)/add/"+string(global.name)+ "/"+string(global.highscore))
}
That changes the highscore to the lastest one
then I call this in the leaderboard left pressed event
theData = http_get("http://dreamlo.com/lb/(my code)/json")
This is a player's data from the json file
"name": "Tom","score": "304","seconds": "0","text": "","date": "9/12/2018 5:04:49 PM"
HTTP EVENT
if ds_map_find_value(async_load, "id") == theData
{
map = json_decode(async_load[? "result"]);
if(map == -1)
{
show_message("invalid result")
}
else
{
if(ds_map_exists(map, "dreamlo"))
{
dreamlo = map[? "dreamlo"];
show_message("Dreamlo: " + string(dreamlo))
if (dreamlo==-1)
{
show_message("invalid result")
}
else
{
if (ds_map_exists(dreamlo,"leaderboard"))
{
leaderboard = dreamlo[? "leaderboard"]
show_message("Leaderboard: " +string(leaderboard))
}
if (leaderboard==-1)
{
show_message("invalid result")
}
else
{
if (ds_map_exists(leaderboard,"entry"))
{
entry = leaderboard[? "entry"]
show_message("Event: " +string(entry))
}
if entry ==-1
{
show_message("invalid result")
}
else
{
size = ds_list_size(entry)
for (var i= 0; i< size; i++)
{
name = ds_list_find_value(entry,i) //got stuck here
draw = true
}
}
}
}
}
}
}
ds_map_destroy(map)
ds_map_destroy(dreamlo)
ds_map_destroy(leaderboard)
ds_list_destroy(entry)
}
At the moment, this is what I am drawing to the screen
draw_text(500,16+(cell_size*i), string(name))
and it's drawing no 1 and 3 instead of the names contained in entry
Last edited by a moderator: