---------- [ Description ] ----------
NOTE: as of March 2021 (version 3.0), CromChat is longer Counter-Strike dependant! You can use it it any mod, but the colors will be active only in CS.
Since every colorchat include that I used so far had something that I don't like, I decided to make one my self and fix the things that annoy me. For example, I didn't like using RED/BLUE/TEAM_COLOR as a parameter in the ColorChat include, another include displayed an error when sending a message in an empty server, and so on. So, here's my version.
---------- [ Color Codes ] ----------
Beside the default symbols - ^x04
, you can also use these ones:
&x07 = red
&x06 = blue
&x05 = white
&x04 = green
&x03 = team color
&x01 = normal
&x00 = removes message prefix (only if put in the beginning of the message)
You can use only one
of the following in a single message: &x07
. If you use more than one in a message, it will automatically select the color that is first in the list and will replace all other colors with that one. Combining more than one team color is not possible in CS 1.6!!!
You can choose from multiple color code groups by adding a single line in the .sma file. You can see all the different groups on the image below. By default, the CROMCHAT
group is used.
To activate a different color group, simply add #define CC_COLORS_TYPE CC_COLORS_<group name>
before #include <cromchat>
. Example: if you want to activate the group SHORT
, the code needs to look like this:
#define CC_COLORS_TYPE CC_COLORS_SHORT
Bear in mind that the codes from the group STANDARD
cannot be used lang, .ini and other files. They are only available in the .sma file, so don't use this group if the plugin uses multiple files.
You can also make your own custom set of codes, by using the group CUSTOM
#define CC_SYM_CHAT_NORMAL "&x01"
#define CC_SYM_CHAT_TEAM "&x03"
#define CC_SYM_CHAT_GREEN "&x04"
#define CC_SYM_CHAT_WHITE "&x05"
#define CC_SYM_CHAT_BLUE "&x06"
#define CC_SYM_CHAT_RED "&x07"
#define CC_SYM_CHAT_NOPREF "&x00"
In the code you replace the &x0
with whatever you want.
---------- [ Sending Messages ] ----------
Messages are sent using the function CC_SendMessage
CC_SendMessage(id, szMessage, any:...)
With the function CC_LogMessage
you can send a chat message and log it at the same time:
// This will send a message to "id" and log it in the default log file.
CC_LogMessage(id, _, "&x04green &x01is not &x07red")
// This will send a message to all players and log it in the file "test.txt".
CC_LogMessage(0, "test.txt", "&x03Cooool story bro!")
You can use CC_SendMatched
to send a message that obeys the targeted player's team color. You can also use ColorChat
CC_SendMatched(const id, const iPlayer, const szInput, any:...)
is the player that will be used as a target for the team color. Instead of a player, you can also add one of the following color codes: CC_COLOR_TEAM
CC_SendMatched(id, iTarget, "message")
CC_SendMatched(0, CC_COLOR_GREY, "message")
It is also possible to send a message to a specific group of players by using the same flags as the get_players
function. To do this, use the function CC_GroupMessage
. The example below shows how to send a message to all alive terrorists.
CC_GroupMessage("ae", "TERRORIST", "message")
The library also contains a function to send a message to all players who have specified admin flags. This is the function CC_SendAdminMessage
CC_SendAdminMessage("abcei", true, "message")
If the second argument is set to true
, the message will be sent to all players who have ALL of the specified admin flags, otherwise, if it's set to false
, it will be sent to players who have ANY of the specified admin flags.
You can also change the color for any other CC_* function by using CC_SetColor
This will force the next CC_* call to use that color.
CC_GroupMessage("a", _, "message")
Bear in mind that if the message contains custom color symbols, it will switch to that color instead.
You can prevent this by setting the second parameter to true:
CromChat also has functions that can replace the show_activity
functions that are used within the default AMXX plugins. By default, when you write #include <cromchat>
in your plugin, all "activity" functions automatically get replaced with the corresponding functions from cromchat, which allows you to easily replace the messages from the default AMXX plugins with colored ones. If you want to disable the automatic transformation of these functions, simply add #define CC_DONT_OVERWRITE_ACTIVITY
before #include <cromchat>
---------- [ Adding A Prefix ] ----------
With the function CC_SetPrefix
you can specify a global prefix that will automatically be added in the beginning of each message. This is much more easier than having to add a prefix manually on each line of code. The function needs to be added in plugin_init()
(or some other forward if necessary).
If you want to remove the prefix, you can use the function CC_RemovePrefix
---------- [ Removing Colors ] ----------
To remove the color codes from a message:
CC_RemoveColors(szMessage, iLen, bool:bChat = true, bool:bMenu = false)
If bChat = true
, it will remove the codes for chat colors.
If bMenu = true
, it will remove the codes for menu colors.
There is also a function for removing chat exploits, e.g. chat color codes and the % sign.