entity cannot move after joining session

Posted By: MPQ

entity cannot move after joining session - 12/14/12 19:18

Hi everybody,

I am totally new to multiplayer but I'm trying to get into it and got the following problem:
after creating a server on my main pc I've tried to join the server session via my notebook. Its a local network. The client's found the session but I couldn't move my entity via w,s,a,d on my client.

- My command line input is: -cl -ip [ip adress],
-cl -ip localhost didn't run (no server found)

- firewalls are turned off
- my code:

- when I start server an client on the same pc, the code works fine!


Code:
#include <acknex.h>
#include <default.c>



///////////////////////////////////////////////////////////////////////////////////
STRING *messages_str = "#50";
FONT *arial_font = "Arial#14";

TEXT *messages_txt = // displays the messages on the screen
{
	pos_x = 10;
	pos_y = 10;
	layer = 10;
	font (arial_font);
	string (messages_str);
	flags = SHOW;
}
///////////////////////////////////////////////////////////////////////////////////

//player movement
function move_players()
{ 
	while (1) 
	{
		my.x += my.skill1;
		my.y += my.skill2;
		ent_sendnow(my);
		wait (1);
	}
}


//main funktion
void main() {
	fps_max = 60;
	level_load ("level1.wmb");
	camera.z = 1000;
	camera.tilt = -90;

	wait(3); 

	//no server or client --> exit game
	if (!connection) {
		str_cpy(messages_str, "Can't find any server. Please try again later.");
		wait (-4);
		sys_exit(NULL);
	}

	//connected as a client
	if (connection == 2) { 
		//client information
		str_cpy(messages_str, "Running as a client");
		str_cat(messages_str, "\nServer IP address: ");
		str_cat(messages_str, server_ip);
		str_cat(messages_str, "\nServer name: ");
		str_cat(messages_str, server_name);
	
		//init level
		

		//create player
		my = ent_create ("player.mdl", vector (100, 50, 40), move_players);
		while (1) {
			my.skill1 = 8 * (key_w - key_s) * time_step;
			my.skill2 = 6 * (key_a - key_d) * time_step;
			send_skill (my.skill1, SEND_VEC);
			wait (1);
		}
	}

	//connected as a srever
	if (connection == 3) {
		//server information
		str_cpy(messages_str, "Running as a server");
		str_cat(messages_str, "\nServer IP address: ");
		str_cat(messages_str, server_ip);
		str_cat(messages_str, "\nServer name: ");
		str_cat(messages_str, server_name);

		//init player
		my = ent_create ("player.mdl", vector (-100, -50, 40), move_players);
		while (1) {
			my.skill1 = 8 * (key_w - key_s) * time_step;
			my.skill2 = 6 * (key_a - key_d) * time_step;
			wait (1);
		}
	}
}

Posted By: Superku

Re: entity cannot move after joining session - 12/14/12 20:33

I don't know if you have seen this already but I suggest you take a look at the following wiki article:
http://opserver.de/wiki/index.php?title=Multiplayer
Posted By: MPQ

Re: entity cannot move after joining session - 12/15/12 02:06

thanks superku, I started to read through the article and it really seems to help me out, theres one question left:

is the "server_connect"-funktion for Pro Version only or does it run on com too?
Posted By: Uhrwerk

Re: entity cannot move after joining session - 12/15/12 02:28

AFAIK there is no server_connect command.

If you mean session_connect, it's available in the commercial edition and above.

http://www.conitec.net/beta/asend-session_connect.htm
Posted By: MPQ

Re: entity cannot move after joining session - 12/15/12 12:20

ye meant session_connect, thank ya
Posted By: Ch40zzC0d3r

Re: entity cannot move after joining session - 12/15/12 13:56

Originally Posted By: MPQ
ye meant session_connect, thank ya


You should use ANet it has much more tutorials, and unl players laugh
Com only has 8...
Posted By: MPQ

Re: entity cannot move after joining session - 12/15/12 14:34

Yop I've already taken a look at anet, maybe I'm gonna switch in near future.

@Superku, I tried your multiplayer code, it works quite well so far, and btw really understandable written! Thank you for that! But the connection problem keeps annoying me. I cannot join the server session with an onther pc. Using the same pc for client and server works fine.
Posted By: MasterQ32

Re: entity cannot move after joining session - 12/15/12 14:36

Originally Posted By: MPQ
I cannot join the server session with an onther pc.

This is a common problem with networking (not only gaming).
Just take a look at your firewall settings and if the computer connects with your computer over internet (not lan)
you need to setup your router correctly to use port forwarding to your computer.
Posted By: MPQ

Re: entity cannot move after joining session - 12/15/12 14:46

hmm makes sense that it is a router problem. As I already said my firewalls are turned off.

what do you mean by "connects with your computer over internet"? How can I adjust that? The server uses my internet connection with a specific local ip-address (192.168.2.116) automaticly assigned by my router. Then I execute the session_connect-function on my client pc (session_connect ("test", "192.168.2.116)"). But the client cannot find a server using this ip-adress.
Posted By: Uhrwerk

Re: entity cannot move after joining session - 12/15/12 16:40

Can you reach the server machine with a ping when the problem occurs?
Posted By: MasterQ32

Re: entity cannot move after joining session - 12/15/12 16:43

if you connect over the internet, your local ip address isn't valid for the other part
he has to use the ip address standing here: http://checkip.dyndns.org/
Posted By: Uhrwerk

Re: entity cannot move after joining session - 12/15/12 16:48

To me it looks as if he is testing with two computers in the same private subnet.
Posted By: MPQ

Re: entity cannot move after joining session - 12/15/12 18:16

yes I can ping the pc with the internal ip adress (192.168.2.116). The session_connect-funtction seems to work, when I use this ip address because connection is set to a value != 0. Using an other (random) ip the engine crushes because the connection-var = 0. But dplay_status doesnt change so there may be sth that prevent the client to join!

@MasterQ32: Unfortunatly, this ip doesnt work at all

edit: ye, I am in the same network!
Posted By: Superku

Re: entity cannot move after joining session - 12/16/12 04:43

I think your router has to support NAT loopback or something like that if you want to connect your two game sessions via IP. Just enter an empty string in the session_connect IP argument to test it locally as a LAN game and enable the IP input for other clients to connect to your server over the internet.
© 2024 lite-C Forums