2 registered members (AndrewAMD, alibaba),
1,184
guests, and 3
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
entity cannot move after joining session
#413504
12/14/12 19:18
12/14/12 19:18
|
Joined: Nov 2008
Posts: 354 saeculum II
MPQ
OP
Senior Member
|
OP
Senior Member
Joined: Nov 2008
Posts: 354
saeculum II
|
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!
#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);
}
}
}
new project in early stage...
Intel Xeon X3450 2,66GHz | Mushkin 8 Gib | Zotac GTS250 + 7300LE | A8.3 com
|
|
|
Re: entity cannot move after joining session
[Re: Superku]
#413532
12/15/12 02:06
12/15/12 02:06
|
Joined: Nov 2008
Posts: 354 saeculum II
MPQ
OP
Senior Member
|
OP
Senior Member
Joined: Nov 2008
Posts: 354
saeculum II
|
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?
new project in early stage...
Intel Xeon X3450 2,66GHz | Mushkin 8 Gib | Zotac GTS250 + 7300LE | A8.3 com
|
|
|
Re: entity cannot move after joining session
[Re: Uhrwerk]
#413560
12/15/12 12:20
12/15/12 12:20
|
Joined: Nov 2008
Posts: 354 saeculum II
MPQ
OP
Senior Member
|
OP
Senior Member
Joined: Nov 2008
Posts: 354
saeculum II
|
ye meant session_connect, thank ya
new project in early stage...
Intel Xeon X3450 2,66GHz | Mushkin 8 Gib | Zotac GTS250 + 7300LE | A8.3 com
|
|
|
Re: entity cannot move after joining session
[Re: MPQ]
#413571
12/15/12 13:56
12/15/12 13:56
|
Joined: Oct 2011
Posts: 1,082 Germany
Ch40zzC0d3r
Serious User
|
Serious User
Joined: Oct 2011
Posts: 1,082
Germany
|
ye meant session_connect, thank ya You should use ANet it has much more tutorials, and unl players Com only has 8...
|
|
|
Re: entity cannot move after joining session
[Re: Ch40zzC0d3r]
#413574
12/15/12 14:34
12/15/12 14:34
|
Joined: Nov 2008
Posts: 354 saeculum II
MPQ
OP
Senior Member
|
OP
Senior Member
Joined: Nov 2008
Posts: 354
saeculum II
|
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.
new project in early stage...
Intel Xeon X3450 2,66GHz | Mushkin 8 Gib | Zotac GTS250 + 7300LE | A8.3 com
|
|
|
Re: entity cannot move after joining session
[Re: MPQ]
#413575
12/15/12 14:36
12/15/12 14:36
|
Joined: Nov 2007
Posts: 2,568 Germany, BW, Stuttgart
MasterQ32
Expert
|
Expert
Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
|
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.
|
|
|
Re: entity cannot move after joining session
[Re: MasterQ32]
#413577
12/15/12 14:46
12/15/12 14:46
|
Joined: Nov 2008
Posts: 354 saeculum II
MPQ
OP
Senior Member
|
OP
Senior Member
Joined: Nov 2008
Posts: 354
saeculum II
|
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.
new project in early stage...
Intel Xeon X3450 2,66GHz | Mushkin 8 Gib | Zotac GTS250 + 7300LE | A8.3 com
|
|
|
Re: entity cannot move after joining session
[Re: MPQ]
#413590
12/15/12 16:40
12/15/12 16:40
|
Joined: Jan 2002
Posts: 4,225 Germany / Essen
Uhrwerk
Expert
|
Expert
Joined: Jan 2002
Posts: 4,225
Germany / Essen
|
Can you reach the server machine with a ping when the problem occurs?
Always learn from history, to be sure you make the same mistakes again...
|
|
|
|