function move_player()
{
var save_pan = 0; //stores the entity.pan (needed to find out if the pan has changed)
VECTOR save_pos; //stores the entity.pos (needed to find out if the position has changed)
while(enet_ent_globpointer(my) == -1) {wait(1);} //wait until the entity gets a global pointer
if(enet_ent_creator(enet_ent_globpointer(my)) == enet_get_clientid())
{ //Every client controls his own player
control_player();
}
if(enet_get_connection() == SERVER_MODE || enet_get_connection() == CLIENT_SERVER_MODE)
{
//set up the physic stuff
phent_settype(my, PH_RIGID, PH_BOX);//physik entity definieren & kollision = sphere
phent_setmass(my, 75, PH_SPHERE);//masse definieren & rotation = sphere
while(1)
{
//use skill1 for the controls of the entity
//sends the position if changed
if(save_pos.x != my.x || save_pos.y != my.y || save_pos.z != my.z) {enet_send_pos(enet_ent_globpointer(my),-1);vec_set(save_pos,my.x);}
//sends the angles if they changed
if(save_pan != my.pan) {enet_send_angle(enet_ent_globpointer(my),-1);save_pan = my.pan;}
wait(1);
}
}
}
function control_player()
{
if(enet_get_connection() == CLIENT_SERVER_MODE) proc_mode = PROC_LATE;
while(1)
{
vec_set(camera.x,my.x);
//store the keys as bits in a skill1
// if(my.skill1 != oldskill1 && enet_get_connection() != CLIENT_SERVER_MODE) enet_send_skill(enet_ent_globpointer(my),1,1,SERVER);
wait(1);
}
}