void tire()
{
set(my,SHADOW | CAST);
my.id = wheel_i++ - 1;
wheels[my.id] = my;
while(enet_ent_globpointer(my) == -1) {wait(1);} //wait until the entity gets a global pointer
while(go ==0){wait(1);}
//if(enet_ent_creator(enet_ent_globpointer(my)) == enet_get_clientid()) //if this function runs on the client which created the entity
//{
set_physics(
PH_SPHERE,
PH_SPHERE,
2 + (my.id > 3) * 2,
30,
80,
50,
10,
20,
20
);
printf("");
wheel_ids[my.id] = phcon_add(PH_WHEEL, vehicles[my.id > 3], my);
phcon_setparams1(wheel_ids[my.id], my.x, vector(0, 0, 1), vector(1, 0, 0));
phcon_setparams2(wheel_ids[my.id], vector(
-30 * (my.id == 0 || my.id == 1 || my.id == 4 || my.id == 5),
30 * (my.id == 0 || my.id == 1 || my.id == 4 || my.id == 5),
0), nullvector, vector(spring, damper, 0));
while(enet_get_clientid() > -1)
{
// suspension
ent_animate(vehicles[my.id > 3], (suspensions.pstring)[my.id % 4],
clamp((100.0 / (suspension_max - suspension_min)) * (
(vec_rotate_inverse(vec_diff(my.t1_x, my.x, vehicles[my.id > 3].x), vehicles[my.id > 3].pan)).z
- suspension_min) - 30, 0, 100), ANM_ADD);
phent_getvelocity(my, my.t2_x, nullvector);
vehicles[my.id > 3].speed = (vec_length(my.t2_x) / 32.0) * 60 * 60 / 1000.0;
enet_set_unreliable(1); //send in unreliable mode
enet_send_pos(enet_ent_globpointer(my),-1); //send the new position to all clients
enet_send_angle(enet_ent_globpointer(my),-1);
enet_set_unreliable(0);
wait(1);
}
//}
}