Hi, I have been playing around with the Anet plug in recently and I have run into a little problem. I'm making a little racing game for learning purposes, and player 1 works, but player 2 only works half the time. The problem with player 2 is that when loaded, 1 out of every 2 times the wheels and the chassis don't line up right(one wheel is usually off the ground completely!)
If anyone could take a look at my code and tell me why it doesn't work correctly that would be great(If not that's cool too).
Its kinda long so sorry if I should have just taken the most important bits, it's just it all seemed kinda important.
So again if your not interested in helping a newbie...don't.
Thanks,Cactus

code:
Code:
/////////////////////////////////////
main.c//////////////////////////////
///////////////////////////////////


#include <acknex.h>
#include "anet.h" // ANet header - NEEDED
#include "default_anet.c" // same as default.c but with ANet multiplayer statistics
#include "main.h"
#include "move_player.c"



////////////////
//Mainfunction//
////////////////

function main()
{
	var i; //counter variable
	
	fps_max = 60;
	fps_lock = ON;
	video_mode = 7;
	video_depth = 32;
	video_screen = 2;
	video_switch(0,0,8); //4:3
	//randomize();
	
	enet_init(); //initializes ANet - must be here!
	
	//sets systemevents: they must be here
	enet_svset_event(EVENT_CONNECTED,_str("client_disconnected"));
	enet_clset_event(EVENT_CONNECTED,_str("connected_with_server"));
	enet_clset_event(EVENT_SYNCHRONIZED,_str("synchronizing_complete"));
	enet_clset_event(EVENT_DISCONNECTED,_str("disconnected_from_server"));
	//for(i=0;i<max_players;i++) {players[i] = 0;} //initializes the players array with null
	
	level_load(""); //loads an empty level
	wait(3); //wait until the level is loaded
	
	menu_1_pan.flags |= VISIBLE; //makes the first menu panel visible
	
	//shows the mouse
	mouse_mode = 1; mouse_map = arrow_bmap;
	
	while(1)
	{
		//controls the mouse:
		vec_set(mouse_pos,mouse_cursor);
		wait(1);
	}
	
	
	
	
}





/////////////////////
//character control//
/////////////////////

function create_player()
{
VECTOR creating_pos_chassis;
	if(enet_get_clientid() == 0){creating_pos_chassis.x = -75;creating_pos_chassis.y = 0;} 
	if(enet_get_clientid() == 1){creating_pos_chassis.x = -275;creating_pos_chassis.y = 0;}
   if(enet_get_clientid() == 2){creating_pos_chassis.x = -475;creating_pos_chassis.y = 0;}
	if(enet_get_clientid() == 3){creating_pos_chassis.x = -675;creating_pos_chassis.y = 0;}
	creating_pos_chassis.z = 15;
	
	VECTOR creating_pos_fr;
	if(enet_get_clientid() == 0){creating_pos_fr.x =  0;creating_pos_fr.y = 30; creating_pos_fr.z = 0;}
   if(enet_get_clientid() == 1){creating_pos_fr.x = -200;creating_pos_fr.y = 30;creating_pos_fr.z = 0;}
	if(enet_get_clientid() == 2){creating_pos_fr.x = -400;creating_pos_fr.y = 30; creating_pos_fr.z = 0;}
	if(enet_get_clientid() == 3){creating_pos_fr.x = -600;creating_pos_fr.y = 30; creating_pos_fr.z = 0;}

	
	
	VECTOR creating_pos_fl;
	if(enet_get_clientid() == 0){creating_pos_fl.x =  0;creating_pos_fl.y = -30; creating_pos_fl.z = 0;}
	if(enet_get_clientid() == 1){creating_pos_fl.x = -200;creating_pos_fl.y = -30; creating_pos_fl.z = 0;}
	if(enet_get_clientid() == 2){creating_pos_fl.x = -400;creating_pos_fl.y = -30; creating_pos_fl.z = 0;}
	if(enet_get_clientid() == 3){creating_pos_fl.x = -600;creating_pos_fl.y = -30; creating_pos_fl.z = 0;}
	
	
	

	VECTOR creating_pos_rr;
	if(enet_get_clientid() == 0){creating_pos_rr.x = -120;creating_pos_rr.y = 30; 	creating_pos_rr.z = 0;}
	if(enet_get_clientid() == 1){creating_pos_rr.x = -320;creating_pos_rr.y = 30; 	creating_pos_rr.z = 0;}
	if(enet_get_clientid() == 2){creating_pos_rr.x = -520;creating_pos_rr.y = 30;creating_pos_rr.z = 0;}
	if(enet_get_clientid() == 3){creating_pos_rr.x = -720;creating_pos_rr.y = 30; creating_pos_rr.z = 0;}
	
	
	

	VECTOR creating_pos_rl;
	if(enet_get_clientid() == 0){creating_pos_rl.x = -120;creating_pos_rl.y = -30;creating_pos_rl.z = 0;}
	if(enet_get_clientid() == 1){creating_pos_rl.x = -320;creating_pos_rl.y = -30;creating_pos_rl.z = 0;}
	if(enet_get_clientid() == 2){creating_pos_rl.x = -520;creating_pos_rl.y = -30; creating_pos_rl.z = 0;}
	if(enet_get_clientid() == 3){creating_pos_rl.x = -720;creating_pos_rl.y = -30; creating_pos_rl.z = 0;}
	
	
	if(enet_get_clientid() == 0)
	{
	chassis = enet_ent_create(_str("bmw5001.mdl"),creating_pos_chassis,_str("move_player"));
	}
	
	
	if(enet_get_clientid() == 1)
	{
		chassis2 = enet_ent_create(_str("bmw5001.mdl"),creating_pos_chassis,_str("move_player2"));
	}

	if(enet_get_clientid() == 2)
   {
   	chassis3 = enet_ent_create(_str("bmw5001.mdl"),creating_pos_chassis,_str("move_player3"));
	}
	
	if(enet_get_clientid() == 3)
   {
   	chassis4 = enet_ent_create(_str("bmw5001.mdl"),creating_pos_chassis,_str("move_player4"));
	}
	

	
	
	if(enet_get_clientid() == 0)
	{
	 wheel_front_r =	enet_ent_create(_str("wheel.mdl"),creating_pos_fr,_str("wheel_fr"));
	 wheel_front_l =	enet_ent_create(_str("wheel.mdl"),creating_pos_fl,_str("wheel_fl"));
	 wheel_back_r =	enet_ent_create(_str("wheel.mdl"),creating_pos_rr,_str("wheel_rr"));
	 wheel_back_l =	enet_ent_create(_str("wheel.mdl"),creating_pos_rl,_str("wheel_rl"));
	}

	
	if(enet_get_clientid() == 1)
	{
		
		wheel_front_r2 = enet_ent_create(_str("wheel.mdl"),creating_pos_fr,_str("wheel_fr2"));
		wheel_front_l2 = enet_ent_create(_str("wheel.mdl"),creating_pos_fl,_str("wheel_fl2"));
		wheel_back_r2 =  enet_ent_create(_str("wheel.mdl"),creating_pos_rr,_str("wheel_rr2"));
		wheel_back_l2 =  enet_ent_create(_str("wheel.mdl"),creating_pos_rl,_str("wheel_rl2"));
	
}
	
	
	
   

	if(enet_get_clientid() == 2)
	{
	wheel_front_r3 = enet_ent_create(_str("wheel.mdl"),creating_pos_fr,_str("wheel_fr3"));
	wheel_front_l3 = enet_ent_create(_str("wheel.mdl"),creating_pos_fl,_str("wheel_fl3"));
	wheel_back_r3 = enet_ent_create(_str("wheel.mdl"),creating_pos_rr,_str("wheel_rr3"));
	wheel_back_l3 = enet_ent_create(_str("wheel.mdl"),creating_pos_rl,_str("wheel_rl3"));
	
}
	if(enet_get_clientid() == 3)
		{
	wheel_front_r4 = enet_ent_create(_str("wheel.mdl"),creating_pos_fr,_str("wheel_fr4"));
	wheel_front_l4 = enet_ent_create(_str("wheel.mdl"),creating_pos_fl,_str("wheel_fl4"));
	wheel_back_r4 = enet_ent_create(_str("wheel.mdl"),creating_pos_rr,_str("wheel_rr4"));
	wheel_back_l4 = enet_ent_create(_str("wheel.mdl"),creating_pos_rl,_str("wheel_rl4"));
	
	}
	

}

// just add those functions there and you dont need to worry about them or change them if you're new to ANet

//////////////////
//host functions//
//////////////////

function start_server()
{	
	level_load("motor_bike.wmb"); //Loads the first Level
	wait(3); //wait until the level is loaded
	enet_init_server(used_port,max_players,_str("")); //initializes a server
	enet_set_level(_str("motor_bike.wmb")); //sets the level
}

function start_client(STRING* ip)
{
	enet_init_client(ip,used_port,_str("")); //initializes a client
}

/////////////////////
//ANet systemevents//
/////////////////////


//server events:




//client events:

// when a client connects with a server it needs 
// to do a synchronization with server and other clients
function connected_with_server(var sender, STRING* msg)
{
	if(enet_get_connection() == 2) //if started as client
	{
		level_load(msg); //loads the level which is loaded on the server
		wait(3); //wait until the level is loaded
		enet_ent_synchronize();
	 //sends a synchronizing request
	}
	else //started as server or server/client
	{
		create_player(); //creates the correct character
		
	}
}

function disconnected_from_server(var sender, STRING* msg)
{
	
		 
	error("Lost connection to server!"); //shows a warning on the screen
	sys_exit(NULL);
}


// after client gets synchronized he creates a player character
function synchronizing_complete(var sender, STRING* msg)
{
	create_player(); //creates the correct character
	
}

function client_disconnected(var sender,STRING* msg)
{
	
	
	/*
	if(players[sender] != NULL)
	{
		ptr_remove(ptr_for_handle(players[sender].skill[40]));
		enet_ent_remove(enet_ent_globpointer(players[sender]));
		players[sender] = 0;
	}
	*/
}
/////////////////
//Menufunctions//
/////////////////

// just a menu function for easier picking of server or client or even maybe dedicated server modes
function menu_1_button(var button_num)
{
	menu_1_pan.flags &= ~VISIBLE; //makes the first menu panel invisible
	starting_mode = button_num; //saves the mode how the host should be initialized (Server,Client,...)
	
	//Server mode:
	if(button_num == 1) {start_server();} //Starts a server
	//Client mode:
	if(button_num == 2)
	{
		//Opens the IP-input-menu:
		inkey_ip_text.flags |= VISIBLE;
		inkey(ip_input); //starts the input of the IP
		inkey_ip_text.flags &= ~VISIBLE; //makes the IP-input-menu invisible when the input is finished
		
		//Opens the player-input-menu:
		inkey_playername_text.flags |= VISIBLE;
		inkey(playername_input); //starts the input of the playername
		inkey_playername_text.flags &= ~VISIBLE; //makes the player-input-menu invisible when the input is finished
		
		//Client mode:
		if(starting_mode == 2)
		{
			start_client(ip_input); //starts a client
		}
	}
	//Server/Client mode:
	if(button_num == 3)
	{
		//Opens the player-input-menu:
		inkey_playername_text.flags |= VISIBLE;
		inkey(playername_input); //starts the input of the playername
		inkey_playername_text.flags &= ~VISIBLE; //makes the player-input-menu invisible when the input is finished
		
		//Server/Client mode:
		if(starting_mode == 3)
		{
			start_server(); //starts a server
			wait(4); //wait until the level is loaded
			start_client(_str("localhost")); //starts the client
		}
	}
}


//////////////////////////////////////////////////////
main.h////////////////////////////////////////////////
/////////////////////////////////////////////////////
///////////
//Defines//
///////////
#define used_port 2300
#define max_players 4

/////////////
//Variables//
/////////////

var starting_mode = 0; //1: starting a server, 2: client, 3: server/client
var character = 0; //1: cbabe.mdl, 2: warlock.mdl, 3: alien.mdl

//////////////////
//Entitypointers//
//////////////////

//ENTITY* players[max_players]; //saves the pointers of all characters lokal on each host (index = clientid)
ENTITY* wheels[max_players];

ENTITY* chassis;
ENTITY* chassis3;
ENTITY* chassis4;
ENTITY* wheel_front_r;
ENTITY* wheel_front_l;
ENTITY* wheel_back_r;
ENTITY* wheel_back_l;

ENTITY* wheel_front_r2;
ENTITY* wheel_front_l2;
ENTITY* wheel_back_r2;
ENTITY* wheel_back_l2;

ENTITY* wheel_front_r3;
ENTITY* wheel_front_l3;
ENTITY* wheel_back_r3;
ENTITY* wheel_back_l3;

ENTITY* wheel_front_r4;
ENTITY* wheel_front_l4;
ENTITY* wheel_back_r4;
ENTITY* wheel_back_l4;

ENTITY* chassis2;

///////////
//Strings//
///////////

//Inputstrings for inkey()
STRING* ip_input = "#15";
STRING* playername_input = "#15";
//STRING* svip = "#12";

///////////
//Bitmaps//
///////////

BMAP* server_bmap = "server.bmp";
BMAP* client_bmap = "client.bmp";
BMAP* server_client_bmap = "server_client.bmp";
BMAP* arrow_bmap = "arrow.bmp";

FONT* arial_font = "Arial#18b";
FONT* arial_font2 = "Arial#16";

//////////
//Panels//
//////////

PANEL* menu_1_pan =
{
	pos_x = 245;
	pos_y = 180;
	layer = 1;
	digits = 0,-20,"Select a mode:",arial_font,0,0;
	buttons = 0,0,server_bmap,server_bmap,server_bmap,menu_1_button,null,null;
	buttons = 0,40,client_bmap,client_bmap,client_bmap,menu_1_button,null,null;
	buttons = 0,80,server_client_bmap,server_client_bmap,server_client_bmap,menu_1_button,null,null;
}


////////
//Text//
////////

TEXT* inkey_ip_text =
{
	pos_x = 245;
	pos_y = 180;
	layer = 1;
	font = arial_font;
	strings = 2;
	string = "IP:",ip_input;
}

TEXT* inkey_playername_text =
{
	pos_x = 245;
	pos_y = 180;
	layer = 1;
	font = arial_font;
	strings = 2;
	string = "Playername:",playername_input;
}


//////////////
//Prototypes//
//////////////

function menu_1_button(var button_num);
function start_server();
function start_client(STRING* ip);

function connected_with_server(var sender, STRING* msg);

function synchronizing_complete(var sender, STRING* msg);
function create_player();
function move_player();



function move_player2();


function move_player3();


function move_player4();


	function wheel_fr();
	function wheel_fl();
	function wheel_rr();
	function wheel_rl();



	
	function wheel_fr2();
	function wheel_fl2();
	function wheel_rr2();
	function wheel_rl2();



	function wheel_fr3();
	function wheel_fl3();
	function wheel_rr3();
	function wheel_rl3();



	function wheel_fr4();
	function wheel_fl4();
	function wheel_rr4();
	function wheel_rl4();

function client_disconnected(var sender,STRING* msg);




function disconnected_from_server(var sender, STRING* msg);


///////////////////////////////////////
move_player.c/////////////////////////
//////////////////////////////////////

#include "move_player.h"




function wheel_fr()
 {
 	
 	while(!wheel_front_r){wait(1);}
 	var counter;
 	if(enet_get_clientid() == 0)
	{
	while(enet_ent_globpointer(chassis) == -1){wait(1);} 
	while(enet_ent_globpointer(wheel_front_r) == -1) {wait(1);} //wait until the entity gets a global pointer
	//wheels[enet_ent_creator(enet_ent_globpointer(me))] = me;
 	phent_settype (me, PH_RIGID, PH_SPHERE); // set the physics entity type
	phent_setmass (me, 3, PH_SPHERE); // and its mass
	phent_setfriction (me,50); // set the friction
	phent_setdamping (me, 40, 40); // set the damping
	phent_setelasticity (me, 50, 20); // set the elasticity
	
	
	//wheel_front physics
	wheel_front2 = phcon_add( PH_WHEEL, chassis,me);
	phcon_setparams1(wheel_front2,me.x,vector(0,0,1),vector(0,1,0));
	phcon_setparams2(wheel_front2,vector(-40,40,0),nullvector,vector(90000,100,0));
	phent_setgroup(me,4);

		while(1)
	{
		
			enet_set_unreliable(1);
			
			if(counter > 2){
				enet_send_pos(enet_ent_globpointer(wheel_front_r),-1); 
				enet_send_angle(enet_ent_globpointer(wheel_front_r),-1); 
				
				counter = 0;
			}else{
				counter ++;
			}
			enet_set_unreliable(0);
			
			wait(1);
		
	}
 	}
	}
	//*********************************************************************
 	
 	


function wheel_fl()
{
	
	while(!wheel_front_l){wait(1);}
	var counter1;
	if(enet_get_clientid() == 0)
	{
	while(enet_ent_globpointer(chassis) == -1){wait(1);} 
	while(enet_ent_globpointer(wheel_front_l) == -1) {wait(1);} //wait until the entity gets a global pointer
	//wheels[enet_ent_creator(enet_ent_globpointer(me))] = me;
	me.pan = 180;
	phent_settype (me, PH_RIGID, PH_SPHERE); // set the physics entity type
	phent_setmass (me, 3, PH_SPHERE); // and its mass
	phent_setfriction (me, 50); // set the friction
	phent_setdamping (me, 40, 40); // set the damping
	phent_setelasticity (me, 50, 20); // set the elasticity
	
	
	
	wheel_frontl2 = phcon_add( PH_WHEEL, chassis,me);
	phcon_setparams1(wheel_frontl2,me.x,vector(0,0,1),vector(0,1,0));
	phcon_setparams2(wheel_frontl2,vector(-40,40,0),nullvector,vector(90000,100,0));
	
	phent_setgroup(me,4);
	while(1)
	{
		
			enet_set_unreliable(1);
			
			if(counter1 > 2){
				enet_send_pos(enet_ent_globpointer(wheel_front_l),-1); 
				enet_send_angle(enet_ent_globpointer(wheel_front_l),-1); 
				
				counter1 = 0;
			}else{
				counter1 ++;
			}
			enet_set_unreliable(0);
			
			wait(1);
		
	}
}
}

	

	


function wheel_rr()
{
	
	while(!wheel_back_r){wait(1);}
	var counter2;
	if(enet_get_clientid() == 0)
	{
	while(enet_ent_globpointer(chassis) == -1){wait(1);} 
	while(enet_ent_globpointer(wheel_back_r) == -1) {wait(1);} //wait until the entity gets a global pointer
	//wheels[enet_ent_creator(enet_ent_globpointer(me))] = me;
	phent_settype (me, PH_RIGID, PH_SPHERE); // set the physics entity type
	phent_setmass (me, 3, PH_SPHERE); // and its mass
	phent_setfriction (me, 80); // set the friction
	phent_setdamping (me, 40, 40); // set the damping
	phent_setelasticity (me, 50, 20); // set the elasticity
	
	
	wheel2= phcon_add( PH_WHEEL, chassis,me);
	phcon_setparams1(wheel2,me.x,up,right);
	phcon_setparams2(wheel2,angle,nullvector,vector(90000,100,0));
	phent_setgroup ( me, 4 );
	
		while(1)
	{
		
			enet_set_unreliable(1);
			
			if(counter2 > 2){
				enet_send_pos(enet_ent_globpointer(wheel_back_r),-1); 
				enet_send_angle(enet_ent_globpointer(wheel_back_r),-1); 
				
				counter2 = 0;
			}else{
				counter2 ++;
			}
			enet_set_unreliable(0);
			
			wait(1);
		
	}
}
}

function wheel_rl()
{
	
	while(!wheel_back_l){wait(1);}
	var counter3;
	if(enet_get_clientid() == 0)
	{
	while(enet_ent_globpointer(chassis) == -1){wait(1);} 
	while(enet_ent_globpointer(wheel_back_l) == -1) {wait(1);} //wait until the entity gets a global pointer
	//wheels[enet_ent_creator(enet_ent_globpointer(me))] = me;
	me.pan = 180;
	phent_settype (me, PH_RIGID, PH_SPHERE); // set the physics entity type
	phent_setmass (me, 3, PH_SPHERE); // and its mass
	phent_setfriction (me, 80); // set the friction
	phent_setdamping (me, 40, 40); // set the damping
	phent_setelasticity (me, 50, 20); // set the elasticity
	
	
	//wheel rear physics
	wheel_back2 = phcon_add( PH_WHEEL, chassis,me);
	phcon_setparams1(wheel_back2,wheel_back_l.x,up,right);
	phcon_setparams2(wheel_back2,angle,nullvector,vector(90000,100,0));
	phent_setgroup(me,4);

		while(1)
	{
		
			enet_set_unreliable(1);
			
			if(counter3 > 2){
				enet_send_pos(enet_ent_globpointer(wheel_back_l),-1); 
				enet_send_angle(enet_ent_globpointer(wheel_back_l),-1); 
				
				counter3 = 0;
			}else{
				counter3 ++;
			}
			enet_set_unreliable(0);
			
			wait(1);
		
	}

}
}






function wheel_fr2()
 {
 
 	while(!wheel_front_r2){wait(1);}
 	while(enet_ent_globpointer(wheel_front_r2) == -1) {wait(1);} //wait until the entity gets a global pointer
 	var counter;
 	if(enet_get_clientid() == 1)
	{

	
	//wheels[enet_ent_creator(enet_ent_globpointer(me))] = me;
 	phent_settype (me, PH_RIGID, PH_SPHERE); // set the physics entity type
	phent_setmass (me, 3, PH_SPHERE); // and its mass
	phent_setfriction (me,50); // set the friction
	phent_setdamping (me, 40, 40); // set the damping
	phent_setelasticity (me, 50, 20); // set the elasticity
	
	
	//wheel_front physics
	wheel_front22 = phcon_add( PH_WHEEL, chassis2,me);
	phcon_setparams1(wheel_front22,wheel_front_r2.x,vector(0,0,1),vector(0,1,0));
	phcon_setparams2(wheel_front22,vector(-40,40,0),nullvector,vector(90000,100,0));
	phent_setgroup(me,5);

		while(1)
	{
		
			enet_set_unreliable(1);
			
			if(counter > 2){
				enet_send_pos(enet_ent_globpointer(wheel_front_r2),-1); 
				enet_send_angle(enet_ent_globpointer(wheel_front_r2),-1); 
				
				counter = 0;
			}else{
				counter ++;
			}
			enet_set_unreliable(0);
			
			wait(1);
		
	}
 	}
	}
	//*********************************************************************
 	
 	


function wheel_fl2()
{
	
	while(!wheel_front_l2){wait(1);}
		while(enet_ent_globpointer(wheel_front_l2) == -1) {wait(1);} //wait until the entity gets a global pointer
	var counter1;
	if(enet_get_clientid() == 1)
	{
	

	//wheels[enet_ent_creator(enet_ent_globpointer(me))] = me;
	me.pan = 180;
	phent_settype (me, PH_RIGID, PH_SPHERE); // set the physics entity type
	phent_setmass (me, 3, PH_SPHERE); // and its mass
	phent_setfriction (me, 50); // set the friction
	phent_setdamping (me, 40, 40); // set the damping
	phent_setelasticity (me, 50, 20); // set the elasticity
	
	
	
	wheel_frontl22 = phcon_add( PH_WHEEL, chassis2,me);
	phcon_setparams1(wheel_frontl22,wheel_front_l2.x,vector(0,0,1),vector(0,1,0));
	phcon_setparams2(wheel_frontl22,vector(-40,40,0),nullvector,vector(90000,100,0));
	
	phent_setgroup(me,5);
	while(1)
	{
		
			enet_set_unreliable(1);
			
			if(counter1 > 2){
				enet_send_pos(enet_ent_globpointer(wheel_front_l2),-1); 
				enet_send_angle(enet_ent_globpointer(wheel_front_l2),-1); 
				
				counter1 = 0;
			}else{
				counter1 ++;
			}
			enet_set_unreliable(0);
			
			wait(1);
		
	}
}
}

	

	


function wheel_rr2()
{
	
	while(!wheel_back_r2){wait(1);}
	while(enet_ent_globpointer(wheel_back_r2) == -1) {wait(1);} //wait until the entity gets a global pointer
	var counter2;
	if(enet_get_clientid() == 1)
	{
	
	
	//wheels[enet_ent_creator(enet_ent_globpointer(me))] = me;
	phent_settype (me, PH_RIGID, PH_SPHERE); // set the physics entity type
	phent_setmass (me, 3, PH_SPHERE); // and its mass
	phent_setfriction (me, 80); // set the friction
	phent_setdamping (me, 40, 40); // set the damping
	phent_setelasticity (me, 50, 20); // set the elasticity
	
	
	wheel22= phcon_add( PH_WHEEL, chassis2,me);
	phcon_setparams1(wheel22,wheel_back_r2.x,up,right);
	phcon_setparams2(wheel22,angle,nullvector,vector(90000,100,0));
	phent_setgroup ( me, 5 );
	
		while(1)
	{
		
			enet_set_unreliable(1);
			
			if(counter2 > 2){
				enet_send_pos(enet_ent_globpointer(wheel_back_r2),-1); 
				enet_send_angle(enet_ent_globpointer(wheel_back_r2),-1); 
				
				counter2 = 0;
			}else{
				counter2 ++;
			}
			enet_set_unreliable(0);
			
			wait(1);
		
	}
}
}

function wheel_rl2()
{

	while(!wheel_back_l2){wait(1);}
	while(enet_ent_globpointer(wheel_back_l2) == -1) {wait(1);} //wait until the entity gets a global pointer
	var counter3;
	if(enet_get_clientid() == 1)
	{
		
	
	//wheels[enet_ent_creator(enet_ent_globpointer(me))] = me;
	me.pan = 180;
	phent_settype (me, PH_RIGID, PH_SPHERE); // set the physics entity type
	phent_setmass (me, 3, PH_SPHERE); // and its mass
	phent_setfriction (me, 80); // set the friction
	phent_setdamping (me, 40, 40); // set the damping
	phent_setelasticity (me, 50, 20); // set the elasticity
	
	
	//wheel rear physics
	wheel_back22 = phcon_add( PH_WHEEL, chassis2,me);
	phcon_setparams1(wheel_back22,wheel_back_l2.x,up,right);
	phcon_setparams2(wheel_back22,angle,nullvector,vector(90000,100,0));
	phent_setgroup(me,5);

		while(1)
	{
		
			enet_set_unreliable(1);
			
			if(counter3 > 2){
				enet_send_pos(enet_ent_globpointer(wheel_back_l2),-1); 
				enet_send_angle(enet_ent_globpointer(wheel_back_l2),-1); 
				
				counter3 = 0;
			}else{
				counter3 ++;
			}
			enet_set_unreliable(0);
			
			wait(1);
		
	}

}
}









function move_player()
{
	while(!chassis){wait(1);}
	while(enet_ent_globpointer(chassis) == -1) {wait(1);} //wait until the entity gets a global pointer

	if(enet_get_clientid() == 0)
	{

	var counterj;
	

	
	phent_settype (me, PH_RIGID, PH_BOX); // set the physics entity type
	phent_setmass (me, 25, PH_BOX); // and its mass
	phent_setfriction (me, 0); // set the friction
	phent_setdamping (me, 0, 0); // set the damping
	phent_setelasticity (me, 0, 20); // set the elasticity
	
		
	phent_setgroup ( me, 4 );	
	ph_setgravity (vector(0, 0, -8000)); //set gravity	
	ph_selectgroup(1+4);	
	

	
		mouse_mode = 0;
		wait(3); //my.z += 30; //sets the entity above the ground
	
		while(1) //as long as a connection to the server exists
		{
			
			
			
			
			if(key_cul){steering = -3;}
			if(!key_cul && !key_cur){steering = 0;}
			if(key_cur){steering =3;}
		
			if(key_cuu){speed = -200;}
			if(key_cud){speed = 25;}
			if(!key_cuu && !key_cud){speed = 0;}
			
			
		
			
			
			camera.x = me.x - fcos(chassis.pan,360);
			camera.y = me.y - fsin(chassis.pan,360);
			camera.pan =  me.pan;
      	camera.z = me.z + 45; 
      	
			phcon_setmotor(wheel_front2,vector(steering,2000,0),nullvector ,nullvector);
			phcon_setmotor(wheel_frontl2,vector(steering,2000,0),nullvector ,nullvector);
			phcon_setmotor(wheel2,nullvector , vector(speed,-200,0),nullvector);
			phcon_setmotor(wheel_back2, nullvector , vector(-speed,-200,0),nullvector);
		
		
			enet_set_unreliable(1);
			
			if(counterj > 2){
				enet_send_pos(enet_ent_globpointer(chassis),-1); 
				enet_send_angle(enet_ent_globpointer(chassis),-1); 
				
				counterj = 0;
			}else{
				counterj ++;
			}
			enet_set_unreliable(0);
			
			wait(1);
		
	}//*****************************************************************************//
	//******************************************************************************//
	//******************************************************************************//
	
}
}


			
function move_player2()
{
	
	while(!chassis2){wait(1);}
	while(enet_ent_globpointer(chassis2) == -1) {wait(1);} //wait until the entity gets a global pointer
	if(enet_get_clientid() == 1)
	{
	
	var counterj;
	

	phent_settype (me, PH_RIGID, PH_BOX); // set the physics entity type
	phent_setmass (me, 25, PH_BOX); // and its mass
	phent_setfriction (me, 0); // set the friction
	phent_setdamping (me, 0, 0); // set the damping
	phent_setelasticity (me, 0, 20); // set the elasticity
	
		
	phent_setgroup ( me, 5);	
	ph_setgravity (vector(0, 0, -8000)); //set gravity	
	ph_selectgroup(1+4+5);	

	
		mouse_mode = 0;
		wait(3); //my.z += 30; //sets the entity above the ground
	
		while(1) //as long as a connection to the server exists
		{
			
			
			
			
			if(key_cul){steering2 = -3;}
			if(!key_cul && !key_cur){steering2 = 0;}
			if(key_cur){steering2 =3;}
		
			if(key_cuu){speed2 = -200;}
			if(key_cud){speed2 = 25;}
			if(!key_cuu && !key_cud){speed2 = 0;}
			
		
			
			
			camera.x = me.x - fcos(me.pan,360);
			camera.y = me.y - fsin(me.pan,360);
			camera.pan =  me.pan;
      	camera.z = me.z + 45; 
      	
			phcon_setmotor(wheel_front22,vector(steering2,2000,0),nullvector ,nullvector);
			phcon_setmotor(wheel_frontl22,vector(steering2,2000,0),nullvector ,nullvector);
			phcon_setmotor(wheel22,nullvector , vector(speed2,-200,0),nullvector);
			phcon_setmotor(wheel_back22, nullvector , vector(-speed2,-200,0),nullvector);
		
		
			enet_set_unreliable(1);
			
			if(counterj > 2){
				enet_send_pos(enet_ent_globpointer(chassis2),-1); 
				enet_send_angle(enet_ent_globpointer(chassis2),-1); 
				
				counterj = 0;
			}else{
				counterj ++;
			}
			enet_set_unreliable(0);
			
			wait(1);
		}
	
	
}
}

////////////////////////////////
move_player.h//////////////////
///////////////////////////////

var group1 =4;
var group2 =5;
var group3 = 6;
var group4 = 7;
//var group_id[5];
//var player_distx;
//var player_pan;
var wheel_frontl2;
var wheel2;
var wheel_front2; // add front wheel
var up[3]; 		// up axis, usually +Z
vec_set(up,vector(0,0,1));
var right[3];		// chassis right axis
vec_set(right,vector(0,1,0));
var angle[3];
vec_set(angle,vector(0,0,0));
var attach[3];

var angle_front[3];
vec_set(angle_front,vector(-40,40,0));
var shocks[3];
vec_set(shocks,vector(50000,100,0));
//steering
var steering;
var speed;
var wheel_back2;
//var temp[3];
//var get_angle = 0;
//var get_id;

var wheel_frontl22;
var wheel22;
var wheel_front22; 
var wheel_back22;
var steering2;
var speed2;
var wheel_frontl3;
var wheel3;
var wheel_front3; 
var wheel_back3;
var steering3;
var speed3;

var wheel_frontl4;
var wheel4;
var wheel_front4; 
var wheel_back4;
var steering4;
var speed4;




HI