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

Need help with http_get

D

Doooooli

Guest
Hi! So i have a server that works connecting to, but i would like to add a text that shows if the server is on or not! the server is written in Python 3.5 (IDLE) and the code to check if the server is on in Python is:

Code:
import client
conn = client.HTTPSConnection("http://myip")
conn.request("HEAD", "/")
r1 = conn.getresponse()
print (r1.status, r1.reason)
So basically that checks if "myip" is reachable!

And this is the code i have in game maker:
Create event:
Code:
get_url = http_get("http://myip");
return_http_status = "null";
HTTP event:
Code:
if ds_map_find_value(async_load, "id") == get_url
   {
   if ds_map_find_value(async_load, "status") == 0
      {
return_http_status = ds_map_find_value(async_load, "http_status")
    }
}
and the draw event:
Code:
draw_set_color(c_orange);
draw_set_font(fnt_changelog);
draw_text(960,672,"HTTP Status:"+string(return_http_status))
But the problem is it only writes null, so i can't tell if it's on or not :/ do anyone know what i should change to make it say like HTTP STATUS: Server Online or Server Offline :) thx
 
T

ThunkGames

Guest
Hi! So i have a server that works connecting to, but i would like to add a text that shows if the server is on or not! the server is written in Python 3.5 (IDLE) and the code to check if the server is on in Python is:

Code:
import client
conn = client.HTTPSConnection("http://myip")
conn.request("HEAD", "/")
r1 = conn.getresponse()
print (r1.status, r1.reason)
So basically that checks if "myip" is reachable!

And this is the code i have in game maker:
Create event:
Code:
get_url = http_get("http://myip");
return_http_status = "null";
HTTP event:
Code:
if ds_map_find_value(async_load, "id") == get_url
   {
   if ds_map_find_value(async_load, "status") == 0
      {
return_http_status = ds_map_find_value(async_load, "http_status")
    }
}
and the draw event:
Code:
draw_set_color(c_orange);
draw_set_font(fnt_changelog);
draw_text(960,672,"HTTP Status:"+string(return_http_status))
But the problem is it only writes null, so i can't tell if it's on or not :/ do anyone know what i should change to make it say like HTTP STATUS: Server Online or Server Offline :) thx
I would do 'if ds_map_find_value(async_load, "status") >= 0'. Also, does the code inside the 'if ds_map_find_value(async_load, "id") == get_url' block get called?
 

FrostyCat

Redemption Seeker
I would do 'if ds_map_find_value(async_load, "status") >= 0'. Also, does the code inside the 'if ds_map_find_value(async_load, "id") == get_url' block get called?
You are at least 18 months behind the latest updates on HTTP functions.

For a condition that controls access to async_load[? 'http_status'], the correct condition to check is async_load[? 'status'] == 0. If you check async_load[? 'status'] >= 0 instead, it only takes an in-progress-type HTTP event to derail the logic.
 
Top