SOLVED Draw score from online

Morkinas

Member
Hello, Is there a way i could draw score instead of getting a pop up.
current code:
GML:
var score = 5;

gmsb_post = http_post_string(WEBSITE+string(tagid)+"&getscore="+string(score),"");
HTTP code:
GML:
var r_str = "null";
if ds_map_find_value(async_load, "id") == gmsb_post
   {
   if ds_map_find_value(async_load, "status") == 0
      {
      r_str = ds_map_find_value(async_load, "result");
      }
   }


show_message(r_str);



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

Morkinas

Member
Hello, look up Draw Events.
I guess draw_text should work but Im not really familiar with HTTP stuff if i try to draw something it doesn't do anything or it starts drawing numbers (i++) With i guess is connection. Adding +1 every step from 0
It happens when i put this code in draw event:
GML:
getscore = 5;
draw_text(x,y,http_post_string(WEBSITE+string(tagid)+"&getscore="+string(getscore),""));
 

Nidoking

Member
Well, you're telling it to draw http_post_string(WEBSITE+string(tagid)+"&getscore="+string(getscore), ""). Maybe you should just put string(r_str) in there. You know, exactly the same thing that was in your message box when you put it in a show_message?
 

FrostyCat

Redemption Seeker
Read up on variable scope and how http_post_string() actually works. Variables declared with var are discarded at the end of an event or script, and http_post_string() returns an ID to check in the HTTP event, not the response's content.

Create:
GML:
var scoreNumber = 5;
response = "...";
gmsb_post = http_post_string(WEBSITE+string(tagid)+"&getscore="+string(scoreNumber), "");
HTTP:
GML:
if (async_load[? "id"] == gmsb_post) {
    if (async_load[? "status"] == 0) {
        response = async_load[? "result"];
        gmsb_post = -1;
    }
}
Draw:
GML:
draw_text(x, y, response);
 

Morkinas

Member
Read up on variable scope and how http_post_string() actually works. Variables declared with var are discarded at the end of an event or script, and http_post_string() returns an ID to check in the HTTP event, not the response's content.

Create:
GML:
var scoreNumber = 5;
response = "...";
gmsb_post = http_post_string(WEBSITE+string(tagid)+"&getscore="+string(scoreNumber), "");
HTTP:
GML:
if (async_load[? "id"] == gmsb_post) {
    if (async_load[? "status"] == 0) {
        response = async_load[? "result"];
        gmsb_post = -1;
    }
}
Draw:
GML:
draw_text(x, y, response);
Thank you
 
Top