Hey Guys,

as everyone is doing online games I took a look in the system. It works so far, but I've got a lag in my local system. I start it as server/client, no lag. Than as client, when I am moving (the player or the camera) it is kinda like jumping around. I thought dplay_smooth could be my fault, but even with 0 it isn't working properly. I post you my code here, but everything should work.

Client has Latency of 9-15 and bps (not moving: 15, moving 70-80), fps are 60 (fps_max is used, otherwise up to 200).

Code:
Code:
#define speed_y skill1
#define speed_x skill2
#define health skill50

#include <acknex.h>
#include <default.c>
#include <mtlFx.c>
#include <windows.h>

function on_client_event() // terminate client when server disconnects
{ 
	if (event_type == EVENT_LEAVE) sys_exit("Disconnected!"); 
} 

function player_remove() // remove player when client disconnects
{ 
	if (event_type == EVENT_DISCONNECT) ent_remove(me); 
}
action playeract()
{	
	var speed_x_old;
	var speed_y_old;
	var skill3_old;
	my.event = player_remove;
	my.emask |= ENABLE_DISCONNECT;
	my.smask |= NOSEND_FRAME; // don't send animation
	my.health = 100;
	set(my,LIGHT);
	vec_set(my.blue,vector(0,0,255));
	VECTOR verttemp;
	VECTOR cpos;
	VECTOR shoot_there;
	set(my,NARROW|FAT);
	
	wait(1);
	
	c_setminmax(me);
	
	var vspeed_x,vspeed_y,vpan;
	vspeed_x = 0;
	vspeed_y = 0;
	vpan = my.pan;
	while(1)
	{
		if(my.client_id == dplay_id)
		{			
			vpan -= 4 * mouse_force.x;
			my.tilt += 4 * mouse_force.y;
			
			vec_set(cpos,vector(-150,0,50));
			vec_rotate(cpos,vector(my.pan,my.tilt,0));
			vec_add(cpos,my.x);
			vec_set(camera.x,cpos);
			
			vec_set(cpos,vector(0,0,16));
			vec_add(cpos,my.x);
			
			if(c_trace(cpos,camera.x,IGNORE_ME | USE_POLYGON))
			{
				vec_set(camera.x,target);
				vec_add(camera.x,hit.nx);
				vec_add(camera.x,hit.nx);
			}

			vec_set(cpos,my.x);
			cpos.z += 15;
			vec_sub(cpos,camera.x);
			vec_to_angle(camera.pan,cpos);
			my.pan = my.skill3;
			
			accelerate(vspeed_x,(key_w-key_s) * 25 * time_step,0.75);
			accelerate(vspeed_y,(key_a-key_d) * 25 * time_step,0.75);
			
			my.speed_x = vspeed_x;
			my.speed_y = vspeed_y;
			my.skill3 = vpan;
			if(my.speed_y != speed_y_old)
			{
				send_skill(my.speed_y,SEND_ALL|SEND_UNRELIABLE|SEND_RATE);
				speed_y_old = my.speed_y;
			}
			if(my.speed_x != speed_x_old)
			{
				send_skill(my.speed_x,SEND_ALL|SEND_UNRELIABLE|SEND_RATE);
				speed_x_old = my.speed_x;
			}
			if(my.skill3 != skill3_old)
			{
				send_skill(my.skill3,SEND_ALL|SEND_UNRELIABLE|SEND_RATE);
				skill3_old = my.skill3;
			}
		}
		else
		{
			if(connection & CONNECT_SERVER)
			{
				if(my.speed_y != skill1_old)
				{
					send_skill(my.speed_y,SEND_ALL|SEND_UNRELIABLE|SEND_RATE);
					skill1_old = my.speed_y;
				}
				if(my.speed_x != speed_x_old)
				{
					send_skill(my.speed_x,SEND_ALL|SEND_UNRELIABLE|SEND_RATE);
					speed_x_old = my.speed_x;
				}
				if(my.skill3 != skill3_old)
				{
					send_skill(my.skill3,SEND_ALL|SEND_UNRELIABLE|SEND_RATE);
					skill3_old = my.skill3;
				}
			}
			
			
		}	
		my.pan = my.skill3;
		c_move(me,vector(my.speed_x,my.speed_y,0), nullvector, GLIDE);
		wait(1);
	}
}
function main()
{
	wait(1);
	//sc_setup();
	do { wait(1); }
	while (dplay_status < 2); // wait until the session is opened or joined
	fps_max = 60;
	dplay_entrate = 4;  // 16 ticks/4 = 4 updates per second
	dplay_smooth = 0;
	dplay_localfunction = 2;
	vec_set(sun_pos,nullvector);
	sun_light = 0;
	level_load("teststadium.wmb");
	//sc_hdrRT = 4; 
	// 16/32/64/128 hdr bitdepth
	//sc_hdrBits = 32;
	//turn HDR on/off
	//sc_bHDR = 1;
	if (connection & CONNECT_SERVER) 
	{ // this instance of the game runs on the server
		ent_create ("player.mdl",vector(-256,32,128),playeract); // then create the red guard!
		return;
		
	} 
	else
	{ // Client
		ent_create ("player.mdl",vector(1300,-1296,128),playeract); // create the blue guard
		return;	
	}

}



I deleted not used code, this is all MP code. For better understanding of the "lag" a video from my client:
[video:youtube]http://www.youtube.com/watch?v=2dFvVFGMdcg[/video]

My Internet is very slow but I think that isn't the problem as my test is local.


"Ich weiss nicht genau, was Sie vorhaben, aber Sie können keine Triggerzonen durch Ihr Level kullern lassen."
-JCL, 2011