TextDraw - 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)
+--- Thread: TextDraw (
/showthread.php?tid=470991)
TextDraw -
MrMou6 - 20.10.2013
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:
and :
Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
maskesID = vehicleid;
return 1;
}
And why text always be red? [0xFF0000FF]
P.S. Sorry for bad english
Re: TextDraw -
MrMou6 - 20.10.2013
No one knows?
Re: TextDraw -
Miguel - 20.10.2013
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.