20.09.2010, 21:55
thanks
okay, so maybe a possible abuse part of this
when your driving and your car explodes, the textdraw doesnt disappear so i quickly thought of a really easy fix such as onplayerexitvehicle { textdrawhideforplayer lalalala lalala and then onplayerdeath textdrawhidefor player lalalala even if you die in foot, hiding the textdraw thats already hidden wont make you crash or whatever p.s if someones already said this, my bad, i just couldnt be bothered to flick through about 11 pages |
new i = 0;
while (i < (sizeof (SPEEDOS) + 1) && (sizeof (HEALTH) +1))
{
SPEEDOS[i] = TextDrawCreate(208.000000, 434.000000, " "), TextDrawBackgroundColor(SPEEDOS[i], 255), TextDrawFont(SPEEDOS[i], 1), TextDrawLetterSize(SPEEDOS[i], 0.500000, 1.000000), TextDrawColor(SPEEDOS[i], -1), TextDrawSetOutline(SPEEDOS[i], 0), TextDrawSetProportional(SPEEDOS[i], 1), TextDrawSetShadow(SPEEDOS[i], 1);
HEALTH[i] = TextDrawCreate(347.000000, 434.000000, " "), TextDrawBackgroundColor(HEALTH[i], 255), TextDrawFont(HEALTH[i], 1), TextDrawLetterSize(HEALTH[i], 0.500000, 1.000000), TextDrawColor(HEALTH[i], -1), TextDrawSetOutline(HEALTH[i], 0), TextDrawSetProportional(HEALTH[i], 1), TextDrawSetShadow(HEALTH[i], 1);
i++;
if(i == sizeof (SPEEDOS) && sizeof (HEALTH)) {
printf("[SERVER] [CONSOLE]: Created: %d Speedo/Health meters.", i);
}
}
TextDrawShowForPlayer(playerid,HEALTH[playerid]);
TextDrawShowForPlayer(playerid,SPEEDOS[playerid]);
public Speedometer(playerid)
{
new vehicleid,Float:speed_x,Float:speed_y,Float:speed_z,Float:final_speed,speed_string[256],final_speed_int;
vehicleid = GetPlayerVehicleID(playerid);
new Float:vehicle_health,final_vehicle_health,health_string[256];
if(vehicleid != 0)
{
GetVehicleVelocity(vehicleid,speed_x,speed_y,speed_z);
final_speed = floatsqroot(((speed_x*speed_x)+(speed_y*speed_y))+(speed_z*speed_z))*250.666667; // 250.666667 = kmph // 199,4166672= mph
final_speed_int = floatround(final_speed,floatround_round);
format(speed_string,256,"Speed: %i",final_speed_int);
TextDrawSetString(SPEEDOS[playerid], 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.
if(final_vehicle_health < 1) {
format(health_string,256,"Health: 0");
} else {
format(health_string,256,"Health: %i", final_vehicle_health);
}
TextDrawSetString(HEALTH[playerid], health_string);
}
else
{
TextDrawSetString(SPEEDOS[playerid], " ");
TextDrawSetString(HEALTH[playerid], " ");
}
return 1;
}