Player color
#1

Hello,

I want if someone's hp is less then 10 it will give a red name.

Код:
	if(PlayerInfo[playerid][pHealth] < 10)
	{
	    ShowNameTags(false);
	    new playername2[24];
		new name[MAX_PLAYER_NAME];
		GetPlayerName(playerid, name, sizeof(name));
		format(playername2, sizeof(playername2), "%s", name);
		new Text3D:attachplayername = Create3DTextLabel(playername2, COLOR_RED, 30.0, 40.0, 50.0, 40.0, 0);
		Attach3DTextLabelToPlayer(attachplayername, playerid, 0.0,0.0,0.2);
	
	}
	else
	{
	 	ShowNameTags(false);
	    new playername2[24];
		new name[MAX_PLAYER_NAME];
		GetPlayerName(playerid, name, sizeof(name));
		format(playername2, sizeof(playername2), "%s", name);
		new Text3D:attachplayername = Create3DTextLabel(playername2, COLOR_WHITE, 30.0, 40.0, 50.0, 40.0, 0);
		Attach3DTextLabelToPlayer(attachplayername, playerid, 0.0,0.0,0.2);
	}
That did I did wrong?
Reply
#2

pawn Код:
ShowNameTags(false);
new name[MAX_PLAYER_NAME + 1];
GetPlayerName(playerid, name, sizeof(name));
new Text3D:attachplayername = Create3DTextLabel(name, (PlayerInfo[playerid][pHealth] < 10 ? COLOR_RED : COLOR_WHITE), 30.0, 40.0, 50.0, 40.0, 0);
Attach3DTextLabelToPlayer(attachplayername, playerid, 0.0,0.0,0.2);
Reply
#3

Does not work, the color is red all the time.
Reply
#4

In what scope are you working? (some callback? command?) I suggest using Update3DTextLabelText instead of recreating the 3d label every time.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)