Post by popeye on Jan 1, 2015 8:25:37 GMT
Method
Step 2 :
After you add this code to your plugin you just have to replace all the client_print code.
I'll give an example, use your brain and do the rest with all the code.
Change this -
to
You can use these codes for color chats -
!g = Green
!n = Normal
!t = Team
These codes can also be used in the language file. No extra changes necessary.
AM Stock Include Method (Intermediate)
Step 1 :
For this method you have to download the stock colorchat.inc from here. You have to copy this file to your compiler's includes folder.
Step 2 :
Open your plugin's source and add the include code first
Step 3 :
After this you have to look for all instances of client_print code and replace them as below
to
In this code you have to change the second part to either id, Red, Blue or Grey. This is the base color which will be used when you use team color (^3).
If your plugin uses a language file, i.e it has register_dictionary and you wish to use color chat in that too then you need to change
Eg -
to
In this method you have to use the following color codes -
If adding to source code then
^4 = Green
^3 = Team
^1 = Normal
If adding in Lang file then -
!g = Green
!t = Team
!n = Normal
In this method you just add some code to the end of your existing or new plugin and you just replace all the print methods.
Step 1 : Copy the code below and add it to the last of your plugin's source.
Step 1 : Copy the code below and add it to the last of your plugin's source.
stock client_print_color(id, type, const text[], any:...)
{
if(type == print_chat)
{
new g_iMsgidSayText;
g_iMsgidSayText = get_user_msgid("SayText");
new szMsg[191], iPlayers[32], iCount = 1;
vformat(szMsg, charsmax(szMsg), text, 3);
replace_all(szMsg, charsmax(szMsg), "!g","^x04");
replace_all(szMsg, charsmax(szMsg), "!n","^x01");
replace_all(szMsg, charsmax(szMsg), "!t","^x03");
if(id)
iPlayers[0] = id;
else
get_players(iPlayers, iCount, "ch");
for(new i = 0 ; i < iCount ; i++)
{
if(!is_user_connected(iPlayers[i]))
continue;
message_begin(MSG_ONE_UNRELIABLE, g_iMsgidSayText, _, iPlayers[i]);
write_byte(iPlayers[i]);
write_string(szMsg);
message_end();
}
}
}
Step 2 :
After you add this code to your plugin you just have to replace all the client_print code.
I'll give an example, use your brain and do the rest with all the code.
Change this -
client_print(id,print_chat,"This is a normal chat message in your plugin")
to
client_print_color(id,print_chat,"!gThis is a !tcolored chat!n message which you edited!")
You can use these codes for color chats -
!g = Green
!n = Normal
!t = Team
These codes can also be used in the language file. No extra changes necessary.
AM Stock Include Method (Intermediate)
Step 1 :
For this method you have to download the stock colorchat.inc from here. You have to copy this file to your compiler's includes folder.
Step 2 :
Open your plugin's source and add the include code first
#include <colorchat>
Step 3 :
After this you have to look for all instances of client_print code and replace them as below
client_print(id,print_chat,"This is a normal chat message in your plugin")
to
client_print_color(id,id/RED/BLUE/GREY,"^4This is a ^3colored chat^1 message in your plugin")
In this code you have to change the second part to either id, Red, Blue or Grey. This is the base color which will be used when you use team color (^3).
If your plugin uses a language file, i.e it has register_dictionary and you wish to use color chat in that too then you need to change
Eg -
register_dictionary("common.txt")
to
register_dictionary_colored("common.txt")
In this method you have to use the following color codes -
If adding to source code then
^4 = Green
^3 = Team
^1 = Normal
If adding in Lang file then -
!g = Green
!t = Team
!n = Normal