Raised This Month: $124 Target: $400
 31% 

[INC] CromChat - a better ColorChat!


Post New Thread Reply   
 
Thread Tools Display Modes
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 03-01-2018 , 09:24   Re: [INC] CromChat - a better ColorChat!
Reply With Quote #21


  • Added the function CC_GroupMessage which allows you to send a message to a specific group of players using the same flags as the function get_players.
__________________

Last edited by OciXCrom; 03-01-2018 at 09:25.
OciXCrom is offline
Send a message via Skype™ to OciXCrom
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
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 03-31-2018 , 09:32   Re: [INC] CromChat - a better ColorChat!
Reply With Quote #23

Was it really necessary to quote the entire first post?!
Also, what are you talking about? This is not a plugin.
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
EFFx
Veteran Member
Join Date: Feb 2016
Location: [<o>]
Old 04-14-2018 , 16:13   Re: [INC] CromChat - a better ColorChat!
Reply With Quote #24

Can you explain how can I remove the prefix on some messages with the &x00?
__________________
EFFx is offline
Send a message via Skype™ to EFFx
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 04-14-2018 , 17:14   Re: [INC] CromChat - a better ColorChat!
Reply With Quote #25

By putting it in the beginning of the message:

PHP Code:
CC_SetPrefix("[Test]")

CC_SendMessage(id"Your message.")
// Result: [Test] Your message.

CC_SendMessage(id"&x00Your message.")
// Result: Your message. 
__________________

Last edited by OciXCrom; 04-14-2018 at 17:15.
OciXCrom is offline
Send a message via Skype™ to OciXCrom
EFFx
Veteran Member
Join Date: Feb 2016
Location: [<o>]
Old 04-14-2018 , 18:14   Re: [INC] CromChat - a better ColorChat!
Reply With Quote #26

I'm using CC_SendMatched:

PHP Code:
CC_SendMatched(idCC_COLOR_RED"&x00%L"LANG_PLAYER"SERVER_DAMAGE_SHOW"
And it prints with the prefix and the &x00 in the chat.
__________________

Last edited by EFFx; 04-14-2018 at 18:15.
EFFx is offline
Send a message via Skype™ to EFFx
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 04-15-2018 , 07:58   Re: [INC] CromChat - a better ColorChat!
Reply With Quote #27

Hm, indeed it doesn't work with CC_SendMatched. I'll have a look. For now you can create a custom function that will send a message without a prefix.

PHP Code:
CC_SendMatchedNoPrefix(const id, const iPlayer, const szInput[], any:...)
{
    static 
szMessage[CC_MAX_MESSAGE_SIZE]
    
vformat(szMessagecharsmax(szMessage), szInput4)
    
    if(
CC_PREFIX[0])
    {
        static 
szPrefix[CC_MAX_PREFIX_SIZE]
        
copy(szPrefixcharsmax(szPrefix), CC_PREFIX)
        
CC_SetPrefix("")
        
CC_SendMatched(idiPlayerszMessage)
        
CC_SetPrefix(szPrefix)
    }
    else 
CC_SendMatched(idiPlayerszMessage)

__________________

Last edited by OciXCrom; 04-15-2018 at 08:04.
OciXCrom is offline
Send a message via Skype™ to OciXCrom
EFFx
Veteran Member
Join Date: Feb 2016
Location: [<o>]
Old 04-15-2018 , 08:55   Re: [INC] CromChat - a better ColorChat!
Reply With Quote #28

That's what I thinked to do before, remove the prefix, send the message and then set the prefix again, so I don't need to use this stock. However, i'll wait the update, maybe you'll think in a better way.
__________________
EFFx is offline
Send a message via Skype™ to EFFx
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 06-12-2018 , 14:24   Re: [INC] CromChat - a better ColorChat!
Reply With Quote #29


  • Added the function CC_SendAdminMessage which allows you to send a message to players with specified admin flag(s).
  • Added the function CC_RemovePrefix that can remove the prefix set with CC_SetPrefix.
  • Changed the main style of the file and made it easier to change the color symbols or define your own color group.
__________________

Last edited by OciXCrom; 06-12-2018 at 14:25.
OciXCrom is offline
Send a message via Skype™ to OciXCrom
iceeedr
Senior Member
Join Date: Apr 2017
Location: Brazil
Old 06-13-2018 , 23:34   Re: [INC] CromChat - a better ColorChat!
Reply With Quote #30

I added & x00 before the message in CC_SendMatched (blablabla), however did not remove the prefix ...
iceeedr is offline
Send a message via Skype™ to iceeedr
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 08:14.


Powered by vBulletin®
Copyright ©2000 - 2018, vBulletin Solutions, Inc.
Theme made by Freecode