27.03.2013, 20:47
pawn Код:
public Speedometer_Update(playerid)
{
new vid, Float:speed_x, Float:speed_y, Float:speed_z, Float:final_speed, string[50], Float:vehiclehealth;
vid = GetPlayerVehicleID(playerid);
if(vid != 0)
{
GetVehicleVelocity(vid, speed_x, speed_y, speed_z);
final_speed = floatsqroot(((speed_x * speed_x) + (speed_y * speed_y)) + (speed_z * speed_z)) * 158.179;
APlayerData[playerid][PlayerSpeed] = final_speed*2; //i dont know how its setup
format(string, sizeof , string"~w~Speed: ~y~%f~w~ kph", final_speed*2);
TextDrawSetString(APlayerData[playerid][SpeedometerText], speed_string);//Is this ur textdrawid ?
GetVehicleHealth(vid, vehiclehealth);
SetPlayerHealth(vid, vehiclehealth / 10.0);
new vid = GetPlayerVehicleID(playerid);
format(string, sizeof(string), "Vehicle: ~g~%s", VehicleNames[GetVehicleModel(vid)-400]);//use the same string no need for new one
}
else
{
TextDrawSetString(APlayerData[playerid][SpeedometerText], " ");
TextDrawHideForPlayer(playerid, APlayerData[playerid][VehicleName]);
APlayerData[playerid][PlayerSpeed] = 0; //--Sets Speed To 0--//
}
}