07.12.2014, 01:01
Evening, I created a speedmeter, but the issue is, when a player enters the passenger seat he can also see the speed meter and i don't want that..
I don't know the problem, BTW when i place the show/hide textdraw on the OnPlayerStateChange it doesn't show up
pawn Код:
public Speedo(playerid)
{
new vehicleid,
Float:speed_x,
Float:speed_y,
Float:speed_z,
Float:final_speed,
speed_string[256],
final_speed_int;
new Float:vehicle_health,final_vehicle_health,health_string[256];
foreach(Player, i)
{
vehicleid = GetPlayerVehicleID(i);
if(vehicleid != 0) {
if(GetPlayerState(i) == PLAYER_STATE_DRIVER)
GetVehicleVelocity(vehicleid, speed_x, speed_y, speed_z);
final_speed = floatsqroot(((speed_x*speed_x)+(speed_y*speed_y))+(speed_z*speed_z))*125;
final_speed_int = floatround(final_speed,floatround_round);
format(speed_string,256,"Speed: %i Km/H",final_speed_int);
PlayerTextDrawSetString(i,Speedoo[i], speed_string);
GetVehicleHealth(vehicleid,vehicle_health);
final_vehicle_health = floatround(floatround(vehicle_health - 250)/ 7.5); //This will make the health show at 100 when the vehicle is not damaged and at 0 when it is in fire.
format(health_string,256,"Health: %i", final_vehicle_health);
PlayerTextDrawSetString(i,carhealth[i], health_string);
PlayerTextDrawShow(i, Speedoo [i] );
PlayerTextDrawShow(i, carhealth [i] );
PlayerTextDrawShow(i, dashboard [i] );
} else {
PlayerTextDrawSetString(i,Speedoo[i], "Speed: 0 Km/H ");
PlayerTextDrawSetString(i,carhealth[i], "Health: 100");
PlayerTextDrawHide(i,Speedoo[i]);
PlayerTextDrawHide(i, carhealth [i] );
PlayerTextDrawHide(i, dashboard [i] );
}
}
return 1;
}