View Single Post
oussama90
Junior Member
Join Date: Mar 2018
Old 03-31-2018 , 08:59   Re: [INC] CromChat - a better ColorChat!
Reply With Quote #22

Quote:
Originally Posted by OciXCrom View Post

---------- [ Description ] ----------


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, ^x03 & ^x01, 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, &x06, &x05, &x03. 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:

Code:
#define CC_COLORS_TYPE CC_COLORS_SHORT
#include <cromchat>

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 like this:

Code:
#define CC_COLORS_TYPE CC_COLORS_CUSTOM
new const CC_REPLACE_COLORS[][] = { "&x04", "^x04", "&x03", "^x03", "&x01", "^x01" }
new const CC_PLUS_COLORS[][] = { "&x07", "TERRORIST", "&x06", "CT", "&x05", "SPECTATOR" }
new const CC_COLORS_LIST[][] = { "&x07", "&x06", "&x05", "&x04", "&x03", "&x01", "&x00" }
new const CC_NO_PREFIX[] = "&x00"
#include <cromchat>

In the code you replace the &x0 with whatever you want.

---------- [ Sending Messages ] ----------


Messages are sent using the function CC_SendMessage or CromChat:

Code:
CC_SendMessage(id, szMessage[], any:...)

With the function CC_LogMessage you can send a chat message and log it at the same time:

Code:
// 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 or client_print_color:

Code:
CC_SendMatched(const id, const iPlayer, const szInput[], any:...)

Where iPlayer 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_COLOR_GREY, CC_COLOR_BLUE, CC_COLOR_RED.

Code:
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.

Code:
CC_GroupMessage("ae", "TERRORIST", "message")
---------- [ 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).

Code:
public plugin_init()
    CC_SetPrefix("&x04[X-Servers]")

---------- [ Removing Colors ] ----------


To remove the color codes from a message:

Code:
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.

---------- [ View the API ] ----------

---------- [ Download ] ----------




wher is sma and amxx ??
oussama90 is offline