AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   ColorChat (https://forums.alliedmods.net/showthread.php?t=246253)

Eviatar Mor 08-14-2014 09:56

ColorChat
 
Hey,
Someone Can Please Tell me how to use colorchat in code ?

skz 08-14-2014 10:03

Re: ColorChat
 
ColorChat (index, COLOR, "Text")

COLOR can be: GREY, RED, BLUE, NORMAL

To use different colors you this to add ^01, ^03 or ^04 before the word you want to collor

^01 - Normal Chat Color
^03 - Color that you choose in COLOR* (if you choose NORMAL, it will appear team collor, like CT = Blue, T = red and Spec = Grey)
^04 - Green

popeye10 08-14-2014 10:07

Re: ColorChat
 
Step 1 : Copy the code below and add it to the last of your plugin's source.
PHP Code:

stock client_print_color(idtype, const text[], any:...)
{
 if(
type == print_chat)
 {
  new 
g_iMsgidSayText;
  
g_iMsgidSayText get_user_msgid("SayText");

  new 
szMsg[191], iPlayers[32], iCount 1;
  
vformat(szMsgcharsmax(szMsg), text3);

  
replace_all(szMsgcharsmax(szMsg), "!g","^x04");
  
replace_all(szMsgcharsmax(szMsg), "!n","^x01");
  
replace_all(szMsgcharsmax(szMsg), "!t","^x03");

  if(
id)
   
iPlayers[0] = id;
  else
   
get_players(iPlayersiCount"ch");

  for(new 
iCount i++)
  {
   if(!
is_user_connected(iPlayers[i]))
    continue;
   
   
message_begin(MSG_ONE_UNRELIABLEg_iMsgidSayText_iPlayers[i]);
   
write_byte(iPlayers[i]);
   
write_string(szMsg);
   
message_end();
  }
 }



popeye10 08-14-2014 10:07

Re: ColorChat
 
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

PreDominance 08-14-2014 10:24

Re: ColorChat
 
??? You don't have to add anything. Download the latest dev build of AMXMODX which has client_print_color already included...

Eviatar Mor 08-14-2014 10:29

Re: ColorChat
 
Quote:

Originally Posted by popeye10 (Post 2183919)
Step 1 : Copy the code below and add it to the last of your plugin's source.
PHP Code:

stock client_print_color(idtype, const text[], any:...)
{
 if(
type == print_chat)
 {
  new 
g_iMsgidSayText;
  
g_iMsgidSayText get_user_msgid("SayText");

  new 
szMsg[191], iPlayers[32], iCount 1;
  
vformat(szMsgcharsmax(szMsg), text3);

  
replace_all(szMsgcharsmax(szMsg), "!g","^x04");
  
replace_all(szMsgcharsmax(szMsg), "!n","^x01");
  
replace_all(szMsgcharsmax(szMsg), "!t","^x03");

  if(
id)
   
iPlayers[0] = id;
  else
   
get_players(iPlayersiCount"ch");

  for(new 
iCount i++)
  {
   if(!
is_user_connected(iPlayers[i]))
    continue;
   
   
message_begin(MSG_ONE_UNRELIABLEg_iMsgidSayText_iPlayers[i]);
   
write_byte(iPlayers[i]);
   
write_string(szMsg);
   
message_end();
  }
 }



Thanks U your mod work...

Eviatar Mor 08-14-2014 10:30

Re: ColorChat
 
Quote:

Originally Posted by skz (Post 2183917)
ColorChat (index, COLOR, "Text")

COLOR can be: GREY, RED, BLUE, NORMAL

To use different colors you this to add ^01, ^03 or ^04 before the word you want to collor

^01 - Normal Chat Color
^03 - Color that you choose in COLOR* (if you choose NORMAL, it will appear team collor, like CT = Blue, T = red and Spec = Grey)
^04 - Green

i do what u say and look i have errors:
PHP Code:

ColorChat (idRED"^03 %s ^04 U Enabled ^03 Bhop"szName

(I Add The szName)

popeye10 08-14-2014 10:31

Re: ColorChat
 
ur welcome :)

Eviatar Mor 08-14-2014 10:35

Re: ColorChat
 
Quote:

Originally Posted by popeye10 (Post 2183928)
ur welcome :)

But I Dont Know why i see two times same text here:
PHP Code:

client_print_color(id,print_chat,"!t%s !nU Disabled !gBhop"szName

or maybe its problem in my server program

skz 08-14-2014 10:55

Re: ColorChat
 
Quote:

Originally Posted by Eviatar Mor (Post 2183926)
i do what u say and look i have errors:
PHP Code:

ColorChat (idRED"^03 %s ^04 U Enabled ^03 Bhop"szName

(I Add The szName)

Copy the error that appears on your compiler


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

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