TD Colors
#1

Hi,

So, I have an HP Textdraw

It's always green but I was wondering how do I change the colors by detecting the HP value? For example I'd say... If the TD is HP: 50 then the colour of the TD will change to orange?

Keep in mind that I already have a TD, I was wondering if you can give me an detailed explanation on how to do so?

If you need the code I'll gladly show it if you need something to show it on.
Reply
#2

is it PlayerTextDraw? if not just change it to PlayerTextDraw.

you have to change this textdraw's color with PlayerTextDrawColor and must hide and re-show when player Takes damages (OnPlayerTakeDamage)
Reply
#3

It's that

Код:
	HPP[playerid] = TextDrawCreate(20.000000, 431.000000, "HP: 100");
	TextDrawBackgroundColor(HPP[playerid], 16711935);
	TextDrawFont(HPP[playerid], 3);
	TextDrawLetterSize(HPP[playerid], 0.449999, 1.800000);
	TextDrawColor(HPP[playerid], 255);
	TextDrawSetOutline(HPP[playerid], 1);
	TextDrawSetProportional(HPP[playerid], 1);
Reply
#4

change the whole code to PlayerTextDraws
Reply
#5

Uh, Mugala got the first step for you. You need Player Textdraw because each player will have their own unique float value of HP. Secondly, you can either check for the HP under OnPlayerUpdate or make a timer and start it off when a player spawns, then depending on the HP of player you can set the color.
Reply
#6

Quote:
Originally Posted by Ritzy
Посмотреть сообщение
Uh, Mugala got the first step for you. You need Player Textdraw because each player will have their own unique float value of HP. Secondly, you can either check for the HP under OnPlayerUpdate or make a timer and start it off when a player spawns, then depending on the HP of player you can set the color.
yeah I know, I have made system like it, tell it to him
by the way, you can make this function without timer, if u define SetPlayerHealth by yourself.
Reply
#7

I've done that and I got tag mismatch on all of the lines

Код:
   	HPP[playerid] = CreatePlayerTextDraw(playerid,20.000000, 431.000000, "HP: 100");
	PlayerTextDrawBackgroundColor(playerid,HPP[playerid], 16711935);
	PlayerTextDrawFont(playerid,HPP[playerid], 3);
	PlayerTextDrawLetterSize(playerid,HPP[playerid], 0.449999, 1.800000);
	PlayerTextDrawColor(playerid,HPP[playerid], 255);
	PlayerTextDrawSetOutline(playerid,HPP[playerid], 1);
	PlayerTextDrawSetProportional(playerid,HPP[playerid], 1);
Reply
#8

Quote:
Originally Posted by ivndosos
Посмотреть сообщение
I've done that and I got tag mismatch on all of the lines
Because you now have
PHP код:
new Text:Bladebla[MAX_PLAYERS
instead of
PHP код:
new PlayerText:Bladebla[MAX_PLAYERS
This is usually what tag mismatches refer to... When you use a string in an integer value, or a float in an integer.
Reply
#9

Okay, I've done that, no errors whatsoever.

How do I continue now? OnPlayerUpdate? OnPlayerDamage? Mind showing me a quick example with a code so I just know how? with explanations please
Reply
#10

There will be tutorials on things 'close' to this. (More on injury systems that watch for the health changes)

You can choose to either do the 'update' through OnPlayerGive/TakeDamage, or through a timer.

OnPlayerUpdate is very easily overloaded, and will end up causing trouble with the script being bogged down.

I myself prefer timers, as they are simple.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)