Colors
Functions for easy chat color management
About:
This include file allows developers to easy control chat coloring in different mods, use color tags, use tags in the translations and automatically replace colors in mods that don't support them (any color that isn't supported will be replaced with green color).
Functions:- CPrintToChat
- CPrintToChatAll
- CPrintToChatEx
- CPrintToChatAllEx
- CRemoveTags
- CSkipNextClient
Regular functions:
PHP Code:
/**
* Prints a message to a specific client in the chat area.
* Supports color tags.
*
* @param client Client index.
* @param szMessage Message (formatting rules).
* @return No return
*
* On error/Errors: If the client is not connected an error will be thrown.
*/
stock CPrintToChat(client, const String:szMessage[], any:...)
/**
* Prints a message to all clients in the chat area.
* Supports color tags.
*
* @param client Client index.
* @param szMessage Message (formatting rules)
* @return No return
*/
stock CPrintToChatAll(const String:szMessage[], any:...)
Tags: {default}, {green}, {lightgreen}, {red}, {blue}, {olive}.
Regular colors: default, green (yellow in L4D), olive.
Team colors: lightgreen, red, blue.
Colors table:
[IMG]http://img219.**************/img219/2408/colorstable3.png[/IMG]
Notes: - You can use only one team color (like lightgreen, red or blue) in the message.
- In hl2dm colors are different for classic deathmatch and team deathmatch.
- If some color is not supported by the mod it will be automatically replaced with green
- You can use these functions instead of default SM function, they are support formatting (%d, %s, %t, etc.)
- Green color is yellow in L4D and L4D2.
- There must be at least one player in each team for proper red and blue colors working. Otherwise these tags will be replaced with green.
Team color based functions:
PHP Code:
/**
* Prints a message to a specific client in the chat area.
* Supports color tags and teamcolor tag.
*
* @param client Client index.
* @param author Author index whose color will be used for teamcolor tag.
* @param szMessage Message (formatting rules).
* @return No return
*
* On error/Errors: If the client or author are not connected an error will
* be thrown.
*/
stock CPrintToChatEx(client, author, const String:szMessage[], any:...)
/**
* Prints a message to all clients in the chat area.
* Supports color tags and teamcolor tag.
*
* @param author Author index whose color will be used for teamcolor tag.
* @param szMessage Message (formatting rules).
* @return No return
*
* On error/Errors: If the author is not connected an error will
* be thrown.
*/
stock CPrintToChatAllEx(author, const String:szMessage[], any:...)
Tags: {default}, {green}, {olive}, {teamcolor}.
Regular colors: default, green (yellow in L4D), olive.
Team colors: based on author's team color.
Notes:- Author index is any client index whose team color you want to be used for {teamcolor} tag
- Tag {teamcolor} replaces {red}, {blue} and {lightgreen} tags
- All notes for regular functions are used for these function too.
Other:
PHP Code:
/**
* Removes color tags from the string.
*
* @param szMessage String.
* @param maxlength Maximum length of the string buffer.
* @return No return
*/
stock CRemoveTags(String:szMessage[], maxlength)
/**
* This function should only be used right in front of
* CPrintToChatAll or CPrintToChatAllEx and it tells
* to those funcions to skip specified client when printing
* message to all clients. After message is printed client will
* no more be skipped.
*
* @param client Client index
* @return No return
*/
stock CSkipNextClient(client)
Changelog:- 1.0.5
- Added support for olive color in HL2:DM
- 1.0.4
- Added support for olive color in CS:S
- 1.0.3
- Added protection from double inclusion (credits to Greyscale and naris)
- Added CSkipNextClient function
- Small optimization in CPrintToChatAll and CPrintToChatAllEx functions
- 1.0.2
- Left 4 Dead 2 support
- Removed {yellow} tag. Use {green} in L4D for yellow color.
- 1.0.1
- Fixed incorrect formatting in CPrintToChatEx function