SA-MP Forums Archive
Player color - 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: Player color (/showthread.php?tid=418049)



Player color - Aarab - 23.02.2013

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?


Re: Player color - Misiur - 23.02.2013

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);



Re: Player color - Aarab - 23.02.2013

Does not work, the color is red all the time.


Re: Player color - Misiur - 23.02.2013

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