[Help]Textdraw for car's health
#1

I made my speedometer and a part for health but i cant seem to get any of the health codes i found to work.

Could someone plz show me one. And i will learn from it.

And a tut for how to show car healths in textdraws would be nice too.
Reply
#2

Код:
new Text3D:CarLabel[MAX_VEHICLES];
Top of script.

Код:
    
    for(new i = 0; i < MAX_VEHICLES; i++)
    {
        new str[30];
        new vehhealth = GetVehicleHealth(i, health);
        format(str, sizeof(str), "%d", vehhealth);
        CarLabel[i] = Create3DTextLabel(str, 0x00AE00FF, 0,0, 0, 20.0, 0, 1);
        Attach3DTextLabelToVehicle( CarLabel[i],i, 0.0, 0.0, 2.0);
    }
OnGameModeInit
Reply
#3

Well that is a 3d label and i can type /dl in game to see it, i want to be able to show my cars health in a text draw.

Ok here is an example:

NOTE: THIS IS NOT MY PICTURE IT IS JUST AN EXAMPLE


I made my speedo but i want to know just like how i can put the speed on, how can i put the health on.
Reply
#4

Anyone please help me.
Reply
#5

Use a timer and OnPlayerStateChange:
pawn Код:
public OnGameModeInit()
{
    SetTimer("UpdateTextDraws", 250, true);
    return 1;
}

forward UpdateTextDraws();
public UpdateTextDraws()
{
    new
        i,
        string[50],
        Float:health,
        Float:x,
        Float:y,
        Float:z,
        Float:total;
       
    for(i = 0; i < MAX_PLAYERS; i ++)
    {
        if(!IsPlayerConnected(i)) return 1;
        if(IsPlayerInAnyVehicle(i))
        {
            GetVehicleHealth(GetPlayerVehicleID(i), health);
            format(string, sizeof(string), "Health: %.2f", health);
            TextDrawSetString(/*put here the variable of the health textdraw*/, string);
            GetVehicleVelocity(GetPlayerVehicleID(i), x, y, z);
            total = floatdiv(floatsqroot(x * x + y * y + z * z) * 200000, 3600);
            total = floatdiv(total, 1.6);
            format(string, sizeof(string), "%d m/h", floatround(total));
            TextDrawSetString(/*put here the variable of the velocity textdraw*/, string);
            return 1;
        }
    }
    return 1;
}

public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == PLAYER_STATE_DRIVER)
    {
        new string[50];
       
        format(string, sizeof(string), "Vehicle: %s", VehicleNames[GetVehicleModel(GetPlayerVehicleID(playerid)) - 400]);
        TextDrawSetString(/*put here the variable of the vehicle textdraw*/, string);
    }
    return 1;
}
Reply
#6

Thanks it worked perfectly. Heave a "cookie"
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)