• 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!

SOLVED http_get looping?

mmuziek

Member
Hello
Im programming a App that allows me to show news and maps and such to my servers players.
The Http_Get works flawlessly on create event based objects.
However since i try to make dynamic news headers it gets them from my api using http_get.
sadly it loops and there is no way to stop it

GML:
28 00:12:38.838 28767 28819 I yoyo    : HttpGet("MYAPIURL", 402)
03-28 00:12:38.870 28767 28819 I yoyo    : HttpGet("MYAPIURL", 403)
03-28 00:12:38.871 28767 28819 I yoyo    : HttpGet("MYAPIURL", 404)
03-28 00:12:38.904 28767 28819 I yoyo    : HttpGet("MYAPIURL", 405)
03-28 00:12:38.904 28767 28819 I yoyo    : HttpGet("MYAPIURL", 406)
03-28 00:12:38.940 28767 28819 I yoyo    : HttpGet("MYAPIURL", 407)
03-28 00:12:38.941 28767 28819 I yoyo    : HttpGet("MYAPIURL", 408)
It keeps going on unless i stop the app
The code i use is User event 0 (thats the only way to make the instance and give it variables directly to load up in the HTTP_GET
GML:
if (canrun){
get_url = http_get("myapiurl/getnews.php?n=" +string(newsnumber) + "&action=gettitle&catid=" + string(catid));
canrun = false;
}
sadly that is causing the endless loop even when canrun is set to false it keeps going. i tried different methods of stopping it but it seems that it just keeps going.
my app definetly doesnt like it (phone is lagging hard when running) and my api page blocks the requests after like 500 in 10 seconds. so thats not what i intend to do.
Does anyone have any idea how to make it only run once.
the object is created like so :

Code:
with (instance_create_layer(240,160 + additionylevel,"Instances",Obj_newsitemparent)){
                newsnumber = Obj_GenerateNewsButtons.itemcounter;
                catid = global.selcat;
                event_user(0);
                
 }
the async http of the same object as the user event :
Code:
if ds_map_find_value(async_load, "id") == get_url
   {
   if ds_map_find_value(async_load, "status") == 0
      {
        return_result = ds_map_find_value(async_load, "result")
        canrun = false; << extra set for certaincy but fails aswell
      }
   else
      {
      r_str = "null";
      }
   }
 

FrostyCat

Redemption Seeker
Make sure that your instance_create_layer() part gets to run only once. There is no point trying to stop the repetitions from the Obj_newsitemparent side if the problem is multiple instances of it being streamed in.
 

mmuziek

Member
Make sure that your instance_create_layer() part gets to run only once. There is no point trying to stop the repetitions from the Obj_newsitemparent side if the problem is multiple instances of it being streamed in.
My current code makes 1 with a delay of 3 seconds using timers with a max of 10
 

mmuziek

Member
Today is a big day.
after another search and because of the answer of frosty i started working my way up the Object tree.
What i found was a open step event. I had forgotten to add a instance_destroy so it was creating thousands of Buttoncreators. Which on theirpart generated 10 buttons each.
Causing the mass problem.

its solved. and i really thank you guys for pointing me to the right direction again.
 
Top