13.01.2013, 08:26
I dont know why, but my speedometer is show only for one player, who first sits in the vehicle. Others do not see it, or sometimes they see, but it shows only one speed. Here is a code(public speedometer is a function called by a timer to update player speed in speedometer):
pawn Код:
public speedometer()
{
for(new i; i<MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i) && !IsPlayerNPC(i))
{
new vehiclestate[MAX_PLAYERS];
vehiclestate[i] = GetPlayerState(i);
if(vehiclestate[i] == PLAYER_STATE_DRIVER)
{
new vehicleid[MAX_PLAYERS],Float:speed_x[MAX_PLAYERS],Float:speed_y[MAX_PLAYERS],Float:speed_z[MAX_PLAYERS],Float:final_speed[MAX_PLAYERS],speed_string[256],final_speed_int[MAX_PLAYERS];
vehicleid[i] = GetPlayerVehicleID(i);
GetVehicleVelocity(vehicleid[i],speed_x[i],speed_y[i],speed_z[i]);
final_speed[i] = floatsqroot(((speed_x[i]*speed_x[i])+(speed_y[i]*speed_y[i]))+(speed_z[i]*speed_z[i]))*136.666667;
final_speed_int[i] = floatround(final_speed[i],floatround_round);
format(speed_string,256,"Speed: %i",final_speed_int[i]);
PlayerTextDrawSetString(i,speedom2[i], speed_string);
PlayerTextDrawSetString(i,speedom3[i], "km/h");
}
else
{
PlayerTextDrawSetString(i,speedom2[i], " ");
PlayerTextDrawSetString(i,speedom3[i], " ");
PlayerTextDrawSetString(i,speedom4[i], " ");
}
}
}
return 1;
}