Vehicle health meter does'nt work...
#1

pawn Код:
//Define colors, the textdraws and forwards
//OnGameModeInit --> Timer of one second, true
public PlayerStats(playerid)
{
    new Float:Health;
    new Float:Armour
    GetPlayerHealth(playerid, Health);
    GetPlayerArmour(playerid, Armour);
   
    //HealthBar --> works perfectly
    if(Health == 100){TextDrawSetString(HealthBar[playerid],"...................................................................................................");}
    else if(Health == 99){TextDrawSetString(HealthBar[playerid],"...................................................................................................");}
//Bla bla..
    else if(Health == 2){TextDrawSetString(HealthBar[playerid],"..");}
    else if(Health == 1){TextDrawSetString(HealthBar[playerid],".");}
    else if(Health == 0){TextDrawHideForPlayer(playerid,HealthBar[playerid]);}
   
    //ArmourBar --> Works perfectly
    if(Armour == 100){TextDrawSetString(ArmourBar[playerid],"...................................................................................................");}
    else if(Armour == 99){TextDrawSetString(ArmourBar[playerid],"...................................................................................................");}
// Bla bla...
    else if(Armour == 2){TextDrawSetString(ArmourBar[playerid],"..");}
    else if(Armour == 1){TextDrawSetString(ArmourBar[playerid],".");}
    else if(Armour == 0)
    {
        TextDrawHideForPlayer(playerid,ArmourBarBG); //Works
        TextDrawHideForPlayer(playerid,ArmourBar[playerid]); //Works
    }
   
    //Health adding --> Works
    if(Health < 100.0)
    {
        SetPlayerHealth(playerid,Health+1.0);
    }
   
    //Vehiclehealth
    if (IsPlayerInAnyVehicle(playerid))
    {
        new Float:CarHealth;
        GetVehicleHealth(GetPlayerVehicleID(playerid), CarHealth);
       
        //CarHealthBar --> DONT WORKS AT ALL!
        if(CarHealth == 1000.0){TextDrawSetString(CarBar[playerid],"...................................................................................................");}
        else if(CarHealth == 990.0){TextDrawSetString(CarBar[playerid],"...................................................................................................");}
//Bla bla
        else if(CarHealth == 20.0){TextDrawSetString(CarBar[playerid],"~r~..");}
        else if(CarHealth == 10.0){TextDrawSetString(CarBar[playerid],"~r~.");}
       
        //SetHealth -->
        if(InArea[playerid] == false)
        {
            if (CarHealth < 1000.0)
            {
                SetVehicleHealth(GetPlayerVehicleID(playerid), 1000.0);
            }
        }
    }
    return 1;
}
What do i want?

I made a textdraw, between the armor and healthbar. If i'm in a vehicle, the bar will display(onplayerupdate). But, if i'm driving to anything, until my car smokes and blow up, there happens nothing with the car-healthbar. What can the problem be?
Reply
#2

do like:
pawn Код:
if(!IsPlayerInAnyCar(playerid){
// first textdraws
} else {
// car textdraws
}
Reply
#3

Quote:
Originally Posted by RKS_
do like:
pawn Код:
if(!IsPlayerInAnyCar(playerid){
// first textdraws
} else {
// car textdraws
}
Does'n work
Reply
#4

It cannot be exactly 990.0, so try

Код:
if(CarHealth > 990.0 && CarHealth < 990.9)
Reply
#5

Quote:
Originally Posted by Andom
It cannot be exactly 990.0, so try

Код:
if(CarHealth > 990.0 && CarHealth < 990.9)
Ok, i can try. Or can i use also CarHealth >= 990.0? That's a bit shorter.
EDIT: >= works, but you tanks because you brought me that idea
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)