27.03.2013, 20:07
(
Последний раз редактировалось TehSprit; 18.05.2013 в 11:58.
)
DELETE
new Float:SPD, Float:vx, Float:vy, Float:vz;
GetVehicleVelocity(GetPlayerVehicleID(playerid), vx,vy,vz);
SPD = floatsqroot(((vx*vx)+(vy*vy))+(vz*vz))*100;
new Str[4];format(Str,4,"%f",SPD*SPEED_MULTIPLIER);
TextDrawSetString(SpeedTxt[playerid], Str);
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--//
}
}
public Speedometer_Update(playerid)
{
new vid, Float:speed_x, Float:speed_y, Float:speed_z, Float:final_speed, speed_string[50], final_speed_int, Float:vehiclehealth; //--Local Variables--//
vid = GetPlayerVehicleID(playerid); //--Id Of Player Vehicle--//
if(vid != 0) //--If The Player Is Inside A Vehicle--//
{
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;
final_speed_int = floatround(final_speed, floatround_round);
APlayerData[playerid][PlayerSpeed] = final_speed_int;
format(speed_string, 50, "~w~Speed: ~y~%i~w~ kph", final_speed_int);
TextDrawSetString(APlayerData[playerid][SpeedometerText], speed_string);
GetVehicleHealth(vid, vehiclehealth);
SetPlayerHealth(vid, vehiclehealth / 10.0);
new str[50];
new vid = GetPlayerVehicleID(playerid);
format(str, sizeof(str), "Vehicle: ~g~%s", VehicleNames[GetVehicleModel(vid)-400]);
TextDrawSetString(APlayerData[playerid][VehicleName], str);
}
else
{
TextDrawSetString(APlayerData[playerid][SpeedometerText], " "); //--Remove Speedo If Player Not Is Inside A Vehicle--//
TextDrawHideForPlayer(playerid, APlayerData[playerid][VehicleName]);
APlayerData[playerid][PlayerSpeed] = 0; //--Sets Speed To 0--//
}
}