Colors can work slightly different based on the game but here are two functions that are useful for printing colored messages
PHP Code:
/**
* Used to print messages to all players and allows special colors without annoying hexadecimal spam in console
*/
stock void PrintColorTextAll(const String:msg[], any:...)
{
decl String:buffer[300];
VFormat(buffer, sizeof(buffer), msg, 2);
new Handle:hMessage = StartMessageAll("SayText2");
if (hMessage != INVALID_HANDLE)
{
if(GetFeatureStatus(FeatureType_Native, "GetUserMessageType") == FeatureStatus_Available && GetUserMessageType() == UM_Protobuf)
{
PbSetInt(hMessage, "ent_idx", 0);
PbSetBool(hMessage, "chat", true);
PbSetString(hMessage, "msg_name", buffer);
PbAddString(hMessage, "params", "");
PbAddString(hMessage, "params", "");
PbAddString(hMessage, "params", "");
PbAddString(hMessage, "params", "");
}
else
{
BfWriteByte(hMessage, 0);
BfWriteByte(hMessage, true);
BfWriteString(hMessage, buffer);
}
EndMessage();
}
}
/**
* Used to print messages to a single player and allows special colors without annoying hexadecimal spam in console
*/
stock void PrintColorText(client, const String:msg[], any:...)
{
if(IsClientInGame(client))
{
new String:buffer[300];
VFormat(buffer, sizeof(buffer), msg, 3);
new Handle:hMessage = StartMessageOne("SayText2", client);
if (hMessage != INVALID_HANDLE)
{
if(GetFeatureStatus(FeatureType_Native, "GetUserMessageType") == FeatureStatus_Available && GetUserMessageType() == UM_Protobuf)
{
PbSetInt(hMessage, "ent_idx", client);
PbSetBool(hMessage, "chat", true);
PbSetString(hMessage, "msg_name", buffer);
PbAddString(hMessage, "params", "");
PbAddString(hMessage, "params", "");
PbAddString(hMessage, "params", "");
PbAddString(hMessage, "params", "");
}
else
{
BfWriteByte(hMessage, client);
BfWriteByte(hMessage, true);
BfWriteString(hMessage, buffer);
}
EndMessage();
}
}
}
Examples
PrintColorText(client, "\x07FF00FFHello world"); // Hex code (doesn't work in all games)
PrintColorTextAll("\x02Hello world"); // Can usually do \x01, \x02, \x03, etc depends on the game to know how many there are
PrintColorTexAll("\x08FFFF0099Hello world!"); // Alpha channel (doesn't work in all games)