1. Hey! Guest! The 36th GMC Jam will take place between February 27th, 12:00 UTC - March 2nd, 12:00 UTC. Why not join in! Click here to find out more!
    Dismiss Notice

Followed networking tutorial, getting same issue

Discussion in 'Programming' started by Marci Nyírő, Feb 11, 2020.

  1. Marci Nyírő

    Marci Nyírő Member

    Joined:
    Aug 5, 2017
    Posts:
    2
    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?
     
  2. chamaeleon

    chamaeleon Member

    Joined:
    Jun 21, 2016
    Posts:
    1,104
    Initialize buff to something sensible like, say, async_load[? "buffer"].
     
    johnwo likes this.
  3. Marci Nyírő

    Marci Nyírő Member

    Joined:
    Aug 5, 2017
    Posts:
    2
    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? :(
     
  4. chamaeleon

    chamaeleon Member

    Joined:
    Jun 21, 2016
    Posts:
    1,104
    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))?
     
  5. FrostyCat

    FrostyCat Member

    Joined:
    Jun 26, 2016
    Posts:
    4,865
    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.
     

Share This Page