TD Colors -
ivndosos - 15.02.2018
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.
Re: TD Colors -
Mugala - 15.02.2018
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)
Re: TD Colors -
ivndosos - 15.02.2018
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);
Re: TD Colors -
Mugala - 15.02.2018
change the whole code to PlayerTextDraws
Re: TD Colors -
Ritzy2K - 15.02.2018
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.
Re: TD Colors -
Mugala - 15.02.2018
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.
Re: TD Colors -
ivndosos - 16.02.2018
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);
Re: TD Colors -
Sew_Sumi - 16.02.2018
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.
Re: TD Colors -
ivndosos - 16.02.2018
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
Re: TD Colors -
Sew_Sumi - 16.02.2018
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.