send_string problem.

Posted By: Sieg

send_string problem. - 06/10/10 12:37

Hi everyone,I'm pretty new here and I'm having a problem with the send_string command.I'm trying to send a string input from the client to the server so it can store it in a file:

CIENT SIDE:
STRING* temp1_str = "#8";
STRING* temp2_str = "#8";

function acc_sett_send() //activated when button pressed
{

if ((str_cmpni(temp1_str, " ") == 0) && (str_cmpni (temp2_str, " ") == 0))
{
send_string(temp1_str);
send_string(temp2_str);
}
else
{
error("You must fill both slots"); //temporary msg
}

SERVER SIDE:

STRING* temp1_str = "default";
STRING* temp2_str = "default";

function on_server_event(void* str,var id)
{
while(event_type == EVENT_STRING)
{
var acchandle = file_open_write("somefolder//new.txt");
file_str_write(acchandle,temp1_str);// writes the files to a new folder
file_str_write(acchandle,temp2_str);
file_close (acchandle);
wait(1);
}
}

I'd appreciate some help and some clarifiement.
edit:the string is sent but it's not updated on the server side.Is there something i haven't already pinpointed or what?

Sieg.

Posted By: tD_Datura_v

Re: send_string problem. - 06/10/10 13:08

potential main error point = while(condition) { wait(1); } loop in event function, on_server_event.
Some guesswork:
Code:
function on_server_event(void* str,var id) {
	if (event_type == EVENT_STRING)  {
		// temp2_str indicates a terminating sequence?
		if (str == temp2_str	
		&& (str_cmpni(temp1_str, "default") == 0)) {	
			var acchandle = file_open_write("new.txt");
			file_str_write(acchandle,temp1_str);
			file_str_write(acchandle,temp2_str);
			file_close (acchandle);
		}
	}
}


Posted By: Sieg

Re: send_string problem. - 06/10/10 13:33

Originally Posted By: tD_Datura_v
potential main error point = while(condition) { wait(1); } loop in event function, on_server_event.
Some guesswork:
Code:
function on_server_event(void* str,var id) {
	if (event_type == EVENT_STRING)  {
		// temp2_str indicates a terminating sequence?
		if (str == temp2_str	
		&& (str_cmpni(temp1_str, "default") == 0)) {	
			var acchandle = file_open_write("new.txt");
			file_str_write(acchandle,temp1_str);
			file_str_write(acchandle,temp2_str);
			file_close (acchandle);
		}
	}
}



Still nothing,now the file isn't even created because the string isn't updated.So your if condition returns to false.I guess that's not the problem ...

Sieg.
Posted By: tD_Datura_v

Re: send_string problem. - 06/10/10 13:40

Are there supposed to be differences between the client and server scripts?
temp1_str and temp2_str are defined differently in client and server.


Posted By: Sieg

Re: send_string problem. - 06/10/10 13:51

I've thought of that too,when i tried to send the strings the first time i defined them the same way.Anyway I think that the strings must only exist at both sides and not to be defined the same way too since the result was the same.Is this really so hard and so impossible to happen?Seems like no one can figure it out.

edit:I'm using 7.8.0 if comes handy to know.

Sieg.
Posted By: Sieg

Re: send_string problem. - 06/10/10 15:55

I'm sorry about the double post but on this depends my whole project since the whole multiplayer system works by sending strings vars and datas.No one has a clue on how to make the string change?if it's not a code problem someone notice me please.

Edit:I managed to do it myself thnx for the 'great help'.
Sieg.
© 2024 lite-C Forums