TextDraw
#1

Hello, I wanna change TextDrawColor if vehicle health ....
Код:
		 // code in OnGameModeInit callback
		new Float:vehHealth;
		GetVehicleHealth(maskesID, vehHealth);
		Textdraw18 = TextDrawCreate(373.000000, 412.000000, "100%");
                TextDrawBackgroundColor(Textdraw18, 255);
                TextDrawFont(Textdraw18, 3);
                TextDrawLetterSize(Textdraw18, 0.259999, 0.899999);
                TextDrawSetOutline(Textdraw18, 0);
                TextDrawSetProportional(Textdraw18, 1);
                if(vehHealth >= 500) TextDrawColor(Textdraw18, 0x00FF00FF);
		if(vehHealth < 500) TextDrawColor(Textdraw18, 0xFF0000FF);
                TextDrawSetShadow(Textdraw18, 1);
I create global variable:
Код:
new maskesID;
and :
Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
	maskesID = vehicleid;
	return 1;
}
And why text always be red? [0xFF0000FF]

P.S. Sorry for bad english
Reply
#2

No one knows?
Reply
#3

It's always red because there's no code telling it to change its colour. The solution would be some kind of timer looking after vehicle health changes.

pawn Код:
// Inside OnGameModeInit()

    SetTimer("Check4Change", 500, 1);

// OUTSIDE

Check4Change()
{
    if (makesID)
    {
        new Float:current_health = -1.0;
       
        GetVehicleHealth(makesID, current_health);
       
        if (health >= 500.0)
            TextDrawColor(Textdraw18, 0x00FF00FF);
        else
            TextDrawColor(Textdraw18, 0xFF0000FF);
    }  
    return 1;
}
By the way, makesID is holding just one vehicle ID. That means it will work just for one vehicle; if you want it to work for more vehicles (occupied vehicles) you have to use arrays to store more vehicles ID, you're better off reading a tutorial to achieve this.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)