Followed networking tutorial, getting same issue

buffer_read argument 1 incorrect type (undefined) expecting a Number (YYGI32)
at gml_Object_Server_NetworkingEvent_1 (line 47) - buffer_read(buff, buffer_string)

Happens, when I try to read from a buffer, called buff. How to resolve it?
 

chamaeleon

Member
buffer_read argument 1 incorrect type (undefined) expecting a Number (YYGI32)
at gml_Object_Server_NetworkingEvent_1 (line 47) - buffer_read(buff, buffer_string)

Happens, when I try to read from a buffer, called buff. How to resolve it?
Initialize buff to something sensible like, say, async_load[? "buffer"].
 
Initialize buff to something sensible like, say, async_load[? "buffer"].
if(global.serverRole = "server") {
var n_id = ds_map_find_value(async_load, "id");
if server_socket == n_id {
var t_buffer = ds_map_find_value(async_load, "buffer");
var cmd_type = buffer_read(t_buffer, buffer_u16 );
var inst = ds_map_find_value(socket_list, sock );
switch (cmd_type) {
case KEY:
//A key has been pressed so read the keypress data from the buffer
break;
case HEALTH:
//The player has taken a hit so remove health from them
break;
//etc...
}
show_debug_message("Message got from client");
}
}



My code looks like this. What should I do? :(
 

chamaeleon

Member
if(global.serverRole = "server") {
var n_id = ds_map_find_value(async_load, "id");
if server_socket == n_id {
var t_buffer = ds_map_find_value(async_load, "buffer");
var cmd_type = buffer_read(t_buffer, buffer_u16 );
var inst = ds_map_find_value(socket_list, sock );
switch (cmd_type) {
case KEY:
//A key has been pressed so read the keypress data from the buffer
break;
case HEALTH:
//The player has taken a hit so remove health from them
break;
//etc...
}
show_debug_message("Message got from client");
}
}



My code looks like this. What should I do? :(
I don't know what you should do.. Post error messages indicating a problem? Examine the content of the async_load map in the debugger or show_debug_message(json_encode(async_data))?
 

FrostyCat

Member
You put the buffer in t_buffer. Your error cites an attempt to read from buff. The problem is self-evident.

Please, don't do multiplayer games when you can't even diagnose code discrepancies this simple. Learn your basics and stop skipping steps.
 
Top