SA-MP Forums Archive
[HELP]GetVehicleHealth - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: [HELP]GetVehicleHealth (/showthread.php?tid=268586)



[HELP]GetVehicleHealth - PCheriyan007 - 13.07.2011

Right now I am trying to make a speedometer which shows health, speed and the name of the vehicle. So far I am working on health and I'm trying to make it so each color corresponds to the health of the car.
Код:
GREEN - 750 - 1000
YELLOW - 500 - 749
RED - 250 - 499
RED - Totaled (0 - 249)
What's happening is, instead of the vehicle health showing with it's color it's showing only TOTALED. Does anybody have an idea of what I am doing wrong. Here's the code...
pawn Код:
forward VehicleTimer(playerid);
public VehicleTimer(playerid)
{
    if(IsPlayerInAnyVehicle(playerid))
    {
        new healthstring[128];
        new Float:health;
        new vehicleid = GetPlayerVehicleID(playerid);
        new vehhealth = GetVehicleHealth(vehicleid, health);
        if(vehhealth >= 750 && vehhealth <= 1000) format(healthstring, sizeof(healthstring), "~w~Heatlh: ~g~h~%d", vehhealth);
        else if(vehhealth >= 749 && vehhealth <= 500) format(healthstring, sizeof(healthstring), "~w~Health: ~y~~h~%d", vehhealth);
        else if(vehhealth >= 250 && vehhealth <= 499) format(healthstring, sizeof(healthstring), "~w~Health: ~r~~h~%d", vehhealth);
        else if(vehhealth >= 0 && vehhealth <= 249) format(healthstring, sizeof(healthstring), "~w~Health: ~r~~h~TOTALED");
        TextDrawSetString(HealthText[playerid], healthstring);
        new speedstring[128];
        new kmh = GetPlayerSpeed(playerid, true);
        if(kmh >= 0 && kmh <= 80) format(speedstring, sizeof(speedstring), "~w~Speed: ~g~~h~%d ~w~KM/h.", kmh);
        else if(kmh >= 81 && kmh <= 120) format(speedstring, sizeof(speedstring), "~w~Speed: ~y~~h~%d ~w~KM/h.", kmh);
        else if(kmh >= 121) format(speedstring, sizeof(speedstring), "~w~Speed: ~r~~h~%d ~w~KM/h.", kmh);
        TextDrawSetString(SpeedoText[playerid], speedstring);
    }
    return 1;
}



Re: [HELP]GetVehicleHealth - PrawkC - 13.07.2011

change
new vehhealth = GetVehicleHealth(vehicleid, health);
to
GetVehicleHealth(vehicleid, health);


https://sampwiki.blast.hk/wiki/GetVehicleHealth


Re: [HELP]GetVehicleHealth - Shadoww5 - 13.07.2011

Sorry .. I made a mistake.

#EDIT

Code fixed:
PHP код:
forward VehicleTimer(playerid);
public 
VehicleTimer(playerid)
{
    if(
IsPlayerInAnyVehicle(playerid))
    {
        new 
healthstring[128];
        new 
Float:health;
        new 
vehicleid GetPlayerVehicleID(playerid);
        
GetVehicleHealth(vehicleidhealth);
        if(
health >= 750 && health <= 1000format(healthstringsizeof(healthstring), "~w~Heatlh: ~g~h~%d"vehhealth);
        else if(
health >= 749 && health <= 500format(healthstringsizeof(healthstring), "~w~Health: ~y~~h~%d"vehhealth);
        else if(
health >= 250 && health <= 499format(healthstringsizeof(healthstring), "~w~Health: ~r~~h~%d"vehhealth);
        else if(
health >= && health <= 249format(healthstringsizeof(healthstring), "~w~Health: ~r~~h~TOTALED");
        
TextDrawSetString(HealthText[playerid], healthstring);
        new 
speedstring[128];
           new 
kmh GetPlayerSpeed(playeridtrue);
        if(
kmh >= && kmh <= 80format(speedstringsizeof(speedstring), "~w~Speed: ~g~~h~%d ~w~KM/h."kmh);
        else if(
kmh >= 81 && kmh <= 120format(speedstringsizeof(speedstring), "~w~Speed: ~y~~h~%d ~w~KM/h."kmh);
        else if(
kmh >= 121format(speedstringsizeof(speedstring), "~w~Speed: ~r~~h~%d ~w~KM/h."kmh);
        
TextDrawSetString(SpeedoText[playerid], speedstring);
     }
    return 
1;




Re: [HELP]GetVehicleHealth - Daren_Jacobson - 13.07.2011

Quote:
Originally Posted by PrawkC
Посмотреть сообщение
change
new vehhealth = GetVehicleHealth(vehicleid, health);
to
GetVehicleHealth(vehicleid, health);


https://sampwiki.blast.hk/wiki/GetVehicleHealth
Do that and change all references to "vehhealth" to just "health"