cannot send string

Posted By: Reconnoiter

cannot send string - 10/17/14 11:19

Hi all,

For my multiplayer game, I want to send a string and var (array) from the server to the client to show hit indicator numbers on the client. The var array is sent correctly, but for some reason I cannot send the string properly crazy .

Code:
var sendindicator_colors[3] = { 0, 0, 0 };
STRING* sendindicator_str = "";
STRING* hitindicator_line1_str = "";
....

function calculate_hitindicator()
{
....
  //send string and array to client
  send_string (sendindicator_str); 
  send_var (sendindicator_colors);
}

function on_client_event(void* buffer) 
{
 if (event_type == EVENT_STRING)
 {
  ...
   //hit indicators
   if (buffer == sendindicator_str) 
   {
    hitindicator_showlines(); 
    str_cpy(hitindicator_line1_str, sendindicator_str);		
    vec_set(hitindicator_line1_txt.blue, vector(sendindicator_colors[0], sendindicator_colors[1], sendindicator_colors[2]));
   }	 
 } 
}



I have debug_vars on both the server and client so I can precisely see what goes well and what goes wrong. The debug_vars show e.g. sendindicator_colors[0] correctly, but e.g. draw_text(sendindicator_str,50,460,vector(100,100,255)); is only shown correctly on the server, and empty on the client. So something goes wrong with sending of the string?

I have checked my code with find text (ctrl+f) and nothing else messes with sendindicator_str.
Posted By: Tele

Re: cannot send string - 10/17/14 20:53

Hi Reconnoiter
Go to sehe site
http://www.coniserver.net/coni_users/web_users/pirvu/aum/aumonline_e/
and search to "send string server"
all info you need is in "Multiplayer"
Tele.
Posted By: Reconnoiter

Re: cannot send string - 10/18/14 10:12

@Tele,

I appreciate your time to comment, but I have read that tutorial many times. I also have already a fully working chat system and other send_strings for my multiplayer game. The problem lies somewhere else. It does seem to send the string cause the line "if (buffer == sendindicator_str)" in function on_client_event is triggered. Also I send this string the same as other strings.

However the data send within the string (e.g. "test 15 damage" ) is not received on the client. The data or string pointer seems to be damaged for some reason.

I will try sending it as a struct, see if that helps.
Posted By: Reconnoiter

Re: cannot send string - 10/18/14 12:11

I got it working! laugh

Using a struct does the trick, saves some overhead bandwidth and now less is calculated on the server and more on the client (non cheatable stuff). Since the server does not create the string now, but the client does with the variables it gets from server.
© 2024 lite-C Forums