Pfap
Member
I'm dealing with a pretty frustrating issue because I've debugged thoroughly and I'm still stuck.
First off the show_debug_message(async_load[? "http_status"]);
Is returning 200.
I'm setting some global variable from a server and then using what that server returns to post and get from a database. When I set the variable from inside gamemaker it makes the request and everything work fine.
From gamemaker I post to the key: "piece" the value: "1" and then have a different gamemaker client request the key "piece" expecting a "1" back, but the async_load status returns -1. When I get the "piece" key from the server's command line it returns the expected "1" and in all my tests the server is responding fine.
Gamemaker also works fine if I hardcode the global.key variable. But when I get it from the server
show_debug_message(global.key); outputs "piece" which is what I expect, but then the status remains -1.
When I'm playing around with all this stuff I create a windows executable get that running and then go back to the ide and press play. Would that have something to do with it??
In the create event I make a request to my server
In the async event I set global.key with the result
In the above the global.key debug message outputs "piece", but the below request doesn't work unless I manual provide the key.
I'm trying to make a multiplayer connect four or tic tac toe game where a string gets passed back and forth with game data. Like 9 pieces for tic tac toe, but if I have to switch it for every match it's going to get tiring. I was maybe going to try just having an array with a bunch of keys available. But I think my current way should work and all the debugging I've done shows it should also.
But am I missing some main reason for a -1 status?
First off the show_debug_message(async_load[? "http_status"]);
Is returning 200.
I'm setting some global variable from a server and then using what that server returns to post and get from a database. When I set the variable from inside gamemaker it makes the request and everything work fine.
From gamemaker I post to the key: "piece" the value: "1" and then have a different gamemaker client request the key "piece" expecting a "1" back, but the async_load status returns -1. When I get the "piece" key from the server's command line it returns the expected "1" and in all my tests the server is responding fine.
Gamemaker also works fine if I hardcode the global.key variable. But when I get it from the server
show_debug_message(global.key); outputs "piece" which is what I expect, but then the status remains -1.
When I'm playing around with all this stuff I create a windows executable get that running and then go back to the ide and press play. Would that have something to do with it??
In the create event I make a request to my server
Code:
var state, str;
state = ds_map_create();
//I may add a unique id to the username stored below
my_variable = "1" + which_key;
show_debug_message(my_variable);
{
ds_map_add(state, "key", my_variable);//i'm pretty sure im not using this order doesnt matter
}
str = json_encode(state);
key_get = http_post_string("http://url", + str );
//key_get = http_post_string("http://url", + str );
ds_map_destroy(state);
In the async event I set global.key with the result
Code:
if ds_map_find_value(async_load, "id") == key_get{
show_debug_message("key get");
show_debug_message(async_load[? "status"]);
show_debug_message(async_load[? "http_status"]);
var status = ds_map_find_value(async_load, "status");
if status == 0
{
path = ds_map_find_value(async_load, "result");
}
else{
alarm[0] = 60;
exit;
}
show_debug_message(path);
global.key = path; //if the user happens to get their own key just send them back to the main menu??
show_debug_message(global.key);
}
Code:
[/COLOR][/FONT][/LEFT]
[FONT=arial][COLOR=rgb(222, 222, 222)]
[LEFT]
var state, str;
state = ds_map_create();
//I may add a unique id to the username stored below
show_debug_message(my_variable);
{
ds_map_add(state, "key", global.key);
}
str = json_encode(state);
key_get = http_post_string("http://url", + str );
//key_get = http_post_string("http://url", + str );
ds_map_destroy(state);
I'm trying to make a multiplayer connect four or tic tac toe game where a string gets passed back and forth with game data. Like 9 pieces for tic tac toe, but if I have to switch it for every match it's going to get tiring. I was maybe going to try just having an array with a bunch of keys available. But I think my current way should work and all the debugging I've done shows it should also.
But am I missing some main reason for a -1 status?
Last edited: