View Single Post
Nicolous
Junior Member
Join Date: May 2005
Location: Reims (France)
Old 08-27-2007 , 08:49   Re: No Coloured Playernames since update
Reply With Quote #6

This method does not make possible to place other colors than the colour of the team in the message.
I found an other method which make possible to place multi-colours in the message :

Code:
// void sayMsg(char * mess, int playerIndex = 0);
void sayMsg(char * mess, int playerIndex)
{
	MRecipientFilter filter; 
	filter.AddAllPlayers();
	bf_write * pBitBuf = engine->UserMessageBegin( &filter, SAYTEXT ); // SAYTEXT == 3
	pBitBuf->WriteByte(playerIndex); // playerIndex is the index of the player whose name is quoted in the message
	pBitBuf->WriteString(mess);
	pBitBuf->WriteByte(1);  // or 0, I don't know the difference
	engine->MessageEnd();
}
Example :
Code:
char buf[64];
Q_snprintf(buf,sizeof(buf),"\004Player \003%s\001 is dead\n",player->GetName());
sayMsg(buf,engine->IndexOfEdict(pEntity));
can display :
Quote:
Player Nicolous is dead
if Nicolous is CT
When "indexPlayer" is 0, the text is lightgreen.

If I use this function :
Code:
void sayMsg(const char * mess) // No index provided
{
	MRecipientFilter filter; 
	filter.AddAllPlayers();
	bf_write * pBitBuf = engine->UserMessageBegin( &filter, MESSAGE_SAYTEXT );
	// pBitBuf->WriteByte(index); // NO index provided
	pBitBuf->WriteByte(0x02);
	pBitBuf->WriteString(buf);
	pBitBuf->WriteByte(0x01);
	pBitBuf->WriteByte(1);
	engine->MessageEnd();
}
when I write
Code:
sayMsg("This text is \003red or blue\001\n");
the text "red or blue" is randomly red or blue. However "red or blue” is not the name of a player
__________________

Last edited by Nicolous; 08-27-2007 at 10:03.
Nicolous is offline