AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Code Snippets/Tutorials (https://forums.alliedmods.net/forumdisplay.php?f=83)
-   -   [INC] CromChat - a better ColorChat! (https://forums.alliedmods.net/showthread.php?t=295046)

OciXCrom 03-14-2017 16:27

[INC] CromChat - a better ColorChat!
 
5 Attachment(s)

---------- [ 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, ^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.

https://raw.githubusercontent.com/Oc...ter/colors.png

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:

PHP 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:

PHP Code:

#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"
#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:

PHP Code:

CC_SendMessage(idszMessage[], any:...) 

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

PHP 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:

PHP 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.

PHP Code:

CC_SendMatched(idiTarget"message")
CC_SendMatched(0CC_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.

PHP Code:

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.

PHP Code:

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.

PHP Code:

CC_SetColor(CC_COLOR_GREY)
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:

PHP Code:

CC_SetColor(CC_COLOR_GREYtrue

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).

PHP Code:

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

If you want to remove the prefix, you can use the function CC_RemovePrefix.

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


To remove the color codes from a message:

PHP Code:

CC_RemoveColors(szMessage[], iLenbool:bChat truebool: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.

PHP Code:

CC_RemoveExploits(messagelen

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

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

HamletEagle 03-14-2017 16:59

Re: [INC] CromChat
 
If we are on this let's break that horrible design which is present in almost every colorchat. Have a custom function to send the message and separat the single-player case from the array so you don't have to call is_user_connected for nothing.

PHP Code:

if(id)
{
    
SendMessage()
}
else
{
    
get_players(iPlayersiCount"ch")
    
    if(!
iCount)
        return

    
loop
    
{
        
SendMessage
    
}




PRoSToTeM@ 03-14-2017 20:57

Re: [INC] CromChat
 
With this you can't write just "!g" (without coloring), so you can replace "!!" with "!", but this would break phrases with "!!!", better to use something that is rarely used, like {}, so you can use it as "{g}", "{r}", etc. Or with full color naming "{green}", "{red}", etc.
static szMessage[192] this can lead server crash, if string would have 191 length. You should use 192 - 1 (for write_byte) = 191.
You can reserve TeamInfos for TR, CT and SPECTATOR on high-slots like 33-35 or 61-63 or 49-51, etc.
PHP Code:

            message_begin(MSG_ONE_UNRELIABLECC_MSG_SAYTEXT_iPlayer)
            
write_byte(iPlayer)
            
write_string(szMessage)
            
message_end() 

This is unsafe, if message contains something like "#Spec_Help_Text" it would show localized string, if message contains percents or something like "%s" it can show something strange and "%s0" can crash client. So, the correct way is:
PHP Code:

            message_begin(MSG_ONE_UNRELIABLECC_MSG_SAYTEXT_iPlayer)
            
write_byte(iPlayer)
            
write_string("%s")
            
write_string(szMessage)
            
message_end() 

And szMessage size now should be 192 - 1 (for write_byte) - 3 (for write_string("%s")) = 188.
Also why is it unreliable? And also it doesn't support ML for sending to all players.

See my ChatPrint

EFFx 03-14-2017 21:17

Re: [INC] CromChat
 
I agree with {green} and {red}, will be much better.

OciXCrom 03-15-2017 15:18

Re: [INC] CromChat
 
Sorry for the late answer, I was a little busy today.

So, here's what I did so far:
  • I made a sepparate function to send the message. Another issue that was present in the other includes, when sending a message to all players at once, the team color sometimes wasn't correct. What's happening is - when I send a message with some color, it keeps that color until the player receives the TeamInfo message again. For that problem I added a function that will reset the TeamInfo message for all players when sending it to everyone, but this includes two sepparate loops - should I keep it this way or should I not use MSG_ALL and use a loop for everyone?
  • Another thing that bugged me was having to add the prefix manually every time. I added a stock which can be used to add a prefix to the messages with one single line in plugin_init() (or anywhere else).
  • I changed szMessage to have 191 characters.
  • I prevented the localized strings and %s bugs.


About the color symbols - they are not that much used in normal messages, but when I think about it, a player's nickname can easily contain them on purpose or not. Is it possible to use symbols such as ^7, ^6, etc? I tried doing it, but it showed a blank space in the chat. Any way to make them replaceable inside the code? I know they can't be manually added in chat, so this would be the most safe way to do it.

{green} style is way too long.

By the way, is it possible to add a parameter after "any:..."?
By the way 2 - what's the difference between MSG_ONE and MSG_ONE_UNRELIABLE? Which one should I use?

PHP Code:

#if defined _cromchat_included
    #endinput
#endif

#define _cromchat_included

#if !defined ColorChat
    #define ColorChat CromChat
#endif

#if !defined client_print_color
    #define client_print_color CromChat
#endif

#define MAX_PREFIX_SIZE 64

new CC_PREFIX[MAX_PREFIX_SIZE], bool:CC_FIRST_TIME trueCC_MSG_SAYTEXTCC_MSG_TEAMINFO
new const CC_REPLACE_COLORS[][] = { "!g""^x04""!t""^x03""!n""^x01" }
new const 
CC_PLUS_COLORS[][] = { "!r""TERRORIST""!b""CT""!w""SPECTATOR" }
new const 
CC_PLUS_COLORS_LIST[][] = { "!r""!b""!w" }

stock CromChat(const id, const szInput[], any:...)
{
    static 
iPlayers[32], iPnum
    
    
if(!id)
    {
        
get_players(iPlayersiPnum"ch")
        
        if(!
iPnum)
            return 
0
            
        CC_RefreshColors
()
    }
    
    static 
szMessage[191], szTeam[10], i
    vformat
(szMessage[1], charsmax(szMessage), szInput3)
    
szMessage[0] = 0x01
    szTeam
[0] = EOS
    
    
if(CC_PREFIX[0])
        
format(szMessagecharsmax(szMessage), "^x01%s %s"CC_PREFIXszMessage)
    
    for(
0sizeof(CC_REPLACE_COLORS) - 1+= 2)
        
replace_all(szMessagecharsmax(szMessage), CC_REPLACE_COLORS[i], CC_REPLACE_COLORS[1])
        
    for(
0sizeof(CC_PLUS_COLORS) - 1+= 2)
    {
        if(
contain(szMessageCC_PLUS_COLORS[i]) != -1)
        {
            
copy(szTeamcharsmax(szTeam), CC_PLUS_COLORS[1])
            break
        }
    }
    
    if(
szTeam[0])
    {
        for(
0sizeof(CC_PLUS_COLORS_LIST); i++)
            
replace_all(szMessagecharsmax(szMessage), CC_PLUS_COLORS_LIST[i], "^x03")
    }
    else if(
id)
        
get_user_team(idszTeamcharsmax(szTeam))
    
    if(
CC_FIRST_TIME)
    {
        
CC_FIRST_TIME false
        CC_MSG_SAYTEXT 
get_user_msgid("SayText")
        
CC_MSG_TEAMINFO get_user_msgid("TeamInfo")
    }
    
    if(
id)
        
CC_SendMessage(idszMessageszTeam)
    else
    {
        for(
0iPnumi++)
            
CC_SendMessage(iPlayers[i], szMessageszTeam)
    }
    
    return 
strlen(szMessage)
}

stock CC_SendMessage(const id, const szMessage[], const szTeam[])
{
    static 
iType
    iType 
= !id MSG_ALL MSG_ONE_UNRELIABLE
    
    
if(szTeam[0])
    {
        
message_begin(iTypeCC_MSG_TEAMINFO_id)
        
write_byte(id)
        
write_string(szTeam)
        
message_end()
    }

    
message_begin(iTypeCC_MSG_SAYTEXT_id)
    
write_byte(id)
    
write_string("%s")
    
write_string(szMessage)
    
message_end()
}

stock CC_RefreshColors()
{
    static 
iPlayers[32], szTeam[10], iPnumiPlayeri
    get_players
(iPlayersiPnum"ch")
    
    for(
0iPnumi++)
    {
        
iPlayer iPlayers[i]
        
        
get_user_team(iPlayerszTeamcharsmax(szTeam))
        
message_begin(MSG_ONE_UNRELIABLECC_MSG_TEAMINFO_iPlayer)
        
write_byte(iPlayer)
        
write_string(szTeam)
        
message_end()
    }
}

stock CC_SetPrefix(const szPrefix[MAX_PREFIX_SIZE])
    
copy(CC_PREFIXcharsmax(CC_PREFIX), szPrefix


PRoSToTeM@ 03-15-2017 16:36

Re: [INC] CromChat
 
Quote:

Originally Posted by OciXCrom (Post 2503896)
I changed szMessage to have 191 characters.
I prevented the localized strings and %s bugs.

Quote:

Originally Posted by PRoSToTeM@ (Post 2503720)
And szMessage size now should be 192 - 1 (for write_byte) - 3 (for write_string("%s")) = 188.

Quote:

Originally Posted by OciXCrom (Post 2503896)
Another thing that bugged me was having to add the prefix manually every time. I added a stock which can be used to add a prefix to the messages with one single line in plugin_init() (or anywhere else).

It can be done via macro:
PHP Code:

#defined PrefixedCromChat(%0,%1,%2) CromChat(%0, fmt("%s %s", YourPrefix, %1), %2) 

Quote:

Originally Posted by OciXCrom (Post 2503896)
I made a sepparate function to send the message. Another issue that was present in the other includes, when sending a message to all players at once, the team color sometimes wasn't correct. What's happening is - when I send a message with some color, it keeps that color until the player receives the TeamInfo message again. For that problem I added a function that will reset the TeamInfo message for all players when sending it to everyone, but this includes two sepparate loops - should I keep it this way or should I not use MSG_ALL and use a loop for everyone?

There is a problem with your TeamInfo sending: you should restore it, but it isn't always trivial, because some plugins can change TeamInfo without changing actual team. You can't use MSG_ALL for SayText here, it would break ML support at all. You also can't use MSG_ALL for TeamInfo here, because MSG_ALL messages are sent after all MSG_ONE messages. (MSG_BROADCAST after MSG_ONE_UNRELIABLE too, order of MSG_ONE and MSG_ONE_UNRELIABLE messages is unstable)
Quote:

Originally Posted by OciXCrom (Post 2503896)
About the color symbols - they are not that much used in normal messages, but when I think about it, a player's nickname can easily contain them on purpose or not.

You can create escape function for this as I created for my ChatPrint - ChatPrint_EscapeString. But I think better and simpler (for user of your API) to read colors only from format string (including ML formats too), but this requires some untrivial workaround. 01, 02, 03, ... codes are also safe, because name can't contain it, but chat messages which are sent via "say" can contain them, so...
Quote:

Originally Posted by OciXCrom (Post 2503896)
{green} style is way too long.

You can make code that would support both {g} and {green}.
Quote:

Originally Posted by OciXCrom (Post 2503896)
By the way 2 - what's the difference between MSG_ONE and MSG_ONE_UNRELIABLE? Which one should I use?

In most cases you should use reliable channel - MSG_ONE and MSG_ALL, but in most temp entity messages you should use unreliable channel.

shehzad1234 03-16-2017 06:25

Re: [INC] CromChat
 
w0w @OciXCrom

shehzad1234 03-16-2017 06:28

Re: [INC] CromChat
 
@OciXCrom bro can u add ^4 for Green ^3 for TeamColor ^1 for Normal ^5Red ^6Blue ^2 for White :P ??

what u think??

edon1337 03-16-2017 08:30

Re: [INC] CromChat
 
Quote:

Originally Posted by shehzad1234 (Post 2504051)
@OciXCrom bro can u add ^4 for Green ^3 for TeamColor ^1 for Normal ^5Red ^6Blue ^2 for White :P ??

what u think??

:bee:

OciXCrom 03-16-2017 08:40

Re: [INC] CromChat
 
@shehzad1234 - I think you should read all previous comments before suggesting it. :bee:

I updated the file in the first post and I think it's ready now. I changed the color symbols from !g to &x04. I don't want to use ^x04 style because this one can't be used inside ML/cfg/ini files. So I think the current one is the best solution.

&x07 = red
&x06 = blue
&x05 = white
&x04 = green
&x03 = team color
&x01 = normal


I also improved one more thing that bugged me - when I want to send a chat message and log it at the same time, I had to replace all color symbols in order to do it. So, I added CC_LogMessage, which will simultaneously send a chat message and log it.

shehzad1234 03-17-2017 10:29

Re: [INC] CromChat
 
Quote:

Originally Posted by OciXCrom (Post 2504085)
@shehzad1234 - I think you should read all previous comments before suggesting it. :bee:

I updated the file in the first post and I think it's ready now. I changed the color symbols from !g to &x04. I don't want to use ^x04 style because this one can't be used inside ML/cfg/ini files. So I think the current one is the best solution.

&x07 = red
&x06 = blue
&x05 = white
&x04 = green
&x03 = team color
&x01 = normal


I also improved one more thing that bugged me - when I want to send a chat message and log it at the same time, I had to replace all color symbols in order to do it. So, I added CC_LogMessage, which will simultaneously send a chat message and log it.

oh i m verry sorry @OciXCrom :(

shehzad1234 03-17-2017 10:31

Re: [INC] CromChat
 
@OciXCrom can u replace

&x06 with ^6 only its easy

OciXCrom 03-17-2017 19:54

Re: [INC] CromChat
 
It's not easy at all and if you read the comments (again), you will see why.

shehzad1234 03-18-2017 05:33

Re: [INC] CromChat
 
ok bro :D

OciXCrom 03-18-2017 11:36

Re: [INC] CromChat
 
I added CC_RemoveColors function whicih will remove all chat and (or) menu colors from a message.
I also added a way to send a message without the prefix. Simply add &x00 in the beginning.

shehzad1234 03-18-2017 14:11

Re: [INC] CromChat
 
hmm bro :)

OciXCrom 05-26-2017 17:52

Re: [INC] CromChat
 
Added CC_SendMatched(id, iPlayer, szMessage[], any:...)
With this you can send a message that matches iPlayer's team color or use one of thee color arguments instead of a player id - CC_COLOR_[RED|BLUE|GREY|DEFAULT]. If a different color code is found in the message itself, it will switch to that color.

OciXCrom 10-16-2017 13:49

Re: [INC] CromChat
 
https://img.shields.io/badge/update-v1.3-green.svg
  • Added different combinations of color codes that can be activated with adding a single line of code in the .sma file. You can use codes like &x04, !g, {green}, {g}, ^4, or even create your custom ones. Read the first post for more information.

OciXCrom 11-30-2017 13:30

Re: [INC] CromChat
 
https://img.shields.io/badge/update-v1.4-green.svg
  • Added support for the ColorChat function. What this means? If a plugin is made using the standard ColorChat library and you want to change it to use CromChat, you can do that by simply changing the file in the #include line and everything else is automated.
  • In case someone wants to use both libraries at the same time (which I don't suggest), you can disable the support by adding #define CC_DONT_OVERWRITE_COLORCHAT before #include <cromchat>.
  • The same type of support is added for client_print_color. If you want to disable it, use CC_DONT_OVERWRITE_183_PRINT.
  • Added API documentation.

indraraj striker 12-16-2017 12:08

Re: [INC] CromChat
 
OciXCrom Thanks a lot for adding support to ColorChat, Now we don't need to replace each and every print chat with CromChat

OciXCrom 03-01-2018 09:24

Re: [INC] CromChat - a better ColorChat!
 
https://img.shields.io/badge/update-...2018-green.svg
  • 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.

oussama90 03-31-2018 08:59

Re: [INC] CromChat - a better ColorChat!
 
Quote:

Originally Posted by OciXCrom (Post 2503655)

---------- [ 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.

https://raw.githubusercontent.com/Oc...ter/colors.png

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 ??

OciXCrom 03-31-2018 09:32

Re: [INC] CromChat - a better ColorChat!
 
Was it really necessary to quote the entire first post?!
Also, what are you talking about? This is not a plugin.

EFFx 04-14-2018 16:13

Re: [INC] CromChat - a better ColorChat!
 
Can you explain how can I remove the prefix on some messages with the &x00?

OciXCrom 04-14-2018 17:14

Re: [INC] CromChat - a better ColorChat!
 
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. 


EFFx 04-14-2018 18:14

Re: [INC] CromChat - a better ColorChat!
 
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.

OciXCrom 04-15-2018 07:58

Re: [INC] CromChat - a better ColorChat!
 
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)



EFFx 04-15-2018 08:55

Re: [INC] CromChat - a better ColorChat!
 
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.

OciXCrom 06-12-2018 14:24

Re: [INC] CromChat - a better ColorChat!
 
https://img.shields.io/badge/update-...2018-green.svg
  • 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.

iceeedr 06-13-2018 23:34

Re: [INC] CromChat - a better ColorChat!
 
I added & x00 before the message in CC_SendMatched (blablabla), however did not remove the prefix ...

OciXCrom 06-14-2018 12:30

Re: [INC] CromChat - a better ColorChat!
 
Ah, yeah, I forgot about that problem. It won't work with CC_SendMatched for some reason. You can remove the prefix with CC_RemovePrefix and set it again if you're going to use CC_SendMatched. The &x00 was originally designed for CC_SendMessage.

iceeedr 06-14-2018 14:04

Re: [INC] CromChat - a better ColorChat!
 
Quote:

Originally Posted by OciXCrom (Post 2596960)
Ah, yeah, I forgot about that problem. It won't work with CC_SendMatched for some reason. You can remove the prefix with CC_RemovePrefix and set it again if you're going to use CC_SendMatched. The &x00 was originally designed for CC_SendMessage.

Oh .. thanks for the return .. I'll do it this way.

OciXCrom 07-22-2018 16:26

Re: [INC] CromChat - a better ColorChat!
 
https://img.shields.io/badge/update-...2018-green.svg
  • 3 new functions have been added - CC_ShowActivity, CC_ShowActivityId and CC_ShowActivityKey.
  • With these functions you can easily add colors to the messages in the default AMXX plugins that use the show_activity() functions to send chat messages.
  • By adding cromchat in your plugin, all show_activity(id/key) functions in the code will automatically get replaced with CC_ShowActivity(Id/Key) and all you have to do is add the color codes in the plugin'a lang file, e.g. admincmd.txt.

EFFx 07-22-2018 21:05

Re: [INC] CromChat - a better ColorChat!
 
When will you add &x00 format to CC_SendMatched?

OciXCrom 07-23-2018 08:38

Re: [INC] CromChat - a better ColorChat!
 
Quote:

Originally Posted by EFFx (Post 2605504)
When will you add &x00 format to CC_SendMatched?

Fixed.

EFFx 07-23-2018 13:56

Re: [INC] CromChat - a better ColorChat!
 
Ty

Nutu_ 11-18-2018 15:29

Re: [INC] CromChat - a better ColorChat!
 
that's great, helpful

allame61 01-06-2019 15:39

Re: [INC] CromChat - a better ColorChat!
 
tags not working

OciXCrom 01-07-2019 09:19

Re: [INC] CromChat - a better ColorChat!
 
Quote:

Originally Posted by allame61 (Post 2633307)
tags not working

What do you mean?

RojedaFeik 07-08-2019 23:30

Re: [INC] CromChat - a better ColorChat!
 
Is possible add another color, like purple?


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

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.