Raised This Month: $ Target: $400
 0% 

Chat Prefixes


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
GXLZPGX
Veteran Member
Join Date: Sep 2009
Old 08-14-2010 , 07:08   Chat Prefixes
Reply With Quote #1

Alright, I know its possible to add a prefix before a players name, for example:

Normal Chat:
GXLZPGX: Hey guys!

Prefix Chat:
[ADMIN] GXLZPGX: Hey guys!

I think it would be much easier for someone to give me an example than for me to look through 50 plugins just to find that I need to scramble through the code of another plugin to find out how to do this.
__________________
Currently accepting payment US DOLLARS ONLY for custom plugins, contact me through PM.
GXLZPGX is offline
naven
Veteran Member
Join Date: Jun 2008
Location: Poland, Cieszyn
Old 08-14-2010 , 07:10   Re: Chat Prefixes
Reply With Quote #2

in init
PHP Code:
    gmsgSayText=get_user_msgid("SayText")//chattag
    
register_message(gmsgSayText,"messageSayText");//chattag
    
gcvarTag register_cvar("amx_chattag","*VIP*");//chattag
    
gcvarLock register_cvar("amx_chattag_lock","1");//chattag 
then
PHP Code:
public messageSayText(msg_idmsg_destmsg_entity){
new 
id get_msg_arg_int(1
if(
is_user_connected(id)){

new 
szBuffer[128];
get_msg_arg_string(2szBuffer127);

if(
contain(szBuffer"#Cstrike_Chat_")==0){
    
    new 
szName[50], szTag[18];
    
get_user_name(idszName31);
    
get_pcvar_string(gcvarTagszTag17);
    
    if(
get_user_flags(id) & TAG_ACCESS){
        
format(szName49,"%s %s"szTagszName);
        }else{
        if(
containi(szNameszTag)==&& get_pcvar_num(gcvarLock)){
            if(
id==msg_entity)
                
ColorChat(idRED,"Usun z nicku tag^x03 %s^x01, aby korzystac z chatu",szTag);
            return 
PLUGIN_HANDLED;
        }
    }
    
    new 
szBuffer2[192];
    
get_msg_arg_string(4szBuffer2191);
    
    
message_begin(MSG_ONEgmsgSayText,{0,0,0}, msg_entity);
    
write_byte(id);
    
write_string(szBuffer);
    
write_string(szName);
    
write_string(szBuffer2);
    
message_end();
    return 
PLUGIN_HANDLED;
}
}
return 
PLUGIN_CONTINUE;

__________________
naven.com.pl
"At the end of the day, there are always going to be mental disorders and people who cause violence for no other reason than the fact that they're fucked up and lost. And all we can do is try to learn from it." Corey Taylor.
naven is offline
GXLZPGX
Veteran Member
Join Date: Sep 2009
Old 08-14-2010 , 07:30   Re: Chat Prefixes
Reply With Quote #3

Quote:
Originally Posted by N A V E N View Post
in init
PHP Code:
    gmsgSayText=get_user_msgid("SayText")//chattag
    
register_message(gmsgSayText,"messageSayText");//chattag
    
gcvarTag register_cvar("amx_chattag","*VIP*");//chattag
    
gcvarLock register_cvar("amx_chattag_lock","1");//chattag 
then
PHP Code:
public messageSayText(msg_idmsg_destmsg_entity){
new 
id get_msg_arg_int(1
if(
is_user_connected(id)){

new 
szBuffer[128];
get_msg_arg_string(2szBuffer127);

if(
contain(szBuffer"#Cstrike_Chat_")==0){
    
    new 
szName[50], szTag[18];
    
get_user_name(idszName31);
    
get_pcvar_string(gcvarTagszTag17);
    
    if(
get_user_flags(id) & TAG_ACCESS){
        
format(szName49,"%s %s"szTagszName);
        }else{
        if(
containi(szNameszTag)==&& get_pcvar_num(gcvarLock)){
            if(
id==msg_entity)
                
ColorChat(idRED,"Usun z nicku tag^x03 %s^x01, aby korzystac z chatu",szTag);
            return 
PLUGIN_HANDLED;
        }
    }
    
    new 
szBuffer2[192];
    
get_msg_arg_string(4szBuffer2191);
    
    
message_begin(MSG_ONEgmsgSayText,{0,0,0}, msg_entity);
    
write_byte(id);
    
write_string(szBuffer);
    
write_string(szName);
    
write_string(szBuffer2);
    
message_end();
    return 
PLUGIN_HANDLED;
}
}
return 
PLUGIN_CONTINUE;

Thank you for the quick reply but that is too sloppy to organize, I do not need cvars etc, I just want a simple way to change the message.
__________________
Currently accepting payment US DOLLARS ONLY for custom plugins, contact me through PM.
GXLZPGX is offline
naven
Veteran Member
Join Date: Jun 2008
Location: Poland, Cieszyn
Old 08-14-2010 , 08:12   Re: Chat Prefixes
Reply With Quote #4

PHP Code:
new szName[50], szTag[18]; 
    
get_user_name(idszName31); 
    
get_pcvar_string("[Admin]"szTag17); 
     
    if(
get_user_flags(id) & TAG_ACCESS){ 
        
format(szName49,"%s %s"szTagszName); 
        }else{ 
        if(
containi(szNameszTag)==){ 
            if(
id==msg_entity
                
ColorChat(idRED,"Usun z nicku tag^x03 %s^x01, aby korzystac z chatu",szTag); 
            return 
PLUGIN_HANDLED
        } 
    } 
     
    new 
szBuffer2[192]; 
    
get_msg_arg_string(4szBuffer2191); 
     
    
message_begin(MSG_ONEgmsgSayText,{0,0,0}, msg_entity); 
    
write_byte(id); 
    
write_string(szBuffer); 
    
write_string(szName); 
    
write_string(szBuffer2); 
    
message_end(); 
    return 
PLUGIN_HANDLED


return 
PLUGIN_CONTINUE

__________________
naven.com.pl
"At the end of the day, there are always going to be mental disorders and people who cause violence for no other reason than the fact that they're fucked up and lost. And all we can do is try to learn from it." Corey Taylor.
naven is offline
Hunter-Digital
Veteran Member
Join Date: Aug 2006
Location: In the Game [ro]
Old 08-14-2010 , 08:29   Re: Chat Prefixes
Reply With Quote #5

You're hooking a message and instead of altering it you're sending other ones.

Better way (not tested):

Code:
public plugin_init()
   register_message(get_user_msgid("SayText"), "msg_SayText")

public msg_SayText()
{
   static szFormat[64]

   static sender
   sender = get_msg_arg_int(1)

   get_msg_arg_string(2, szFormat, charsmax(szFormat))

   if(equal(szFormat, "#Cstrike_Chat", 13))
   {
       static szTeam[24]

       switch(szFormat[16])
       {
          case 'C': copy(szTeam, charsmax(szTeam), "(Counter-Terrorist) ")
          case 'T': copy(szTeam, charsmax(szTeam), "(Terrorist) ")
          case 'S': copy(szTeam, charsmax(szTeam), "(Spectator) ")
       }

       formatex(szFormat, charsmax(szFormat),
          "^x01%s%s%s^x03%%s1^x01 :  %%s2",
          "[Prefix] ",
          (szFormat[18] == 'S' ? "*SPEC*" : (szFormat[17] == 'D' || szFormat[18] == 'D' ? "*DEAD*")),
          szTeam
       )

       set_msg_arg_string(2, szFormat)
   }
}
__________________

Last edited by Hunter-Digital; 08-14-2010 at 08:44.
Hunter-Digital is offline
Zpoke
Senior Member
Join Date: Aug 2009
Location: Sweden
Old 08-14-2010 , 09:47   Re: Chat Prefixes
Reply With Quote #6

PHP Code:
print_colorindex, const sFormat[], any:...)
{
new 
players[32], count 1
if ( index players[0] = index; else get_playersplayerscount"ch" )
for ( new 
0counti++ )
{
new 
message[256];
new 
len formatexmessage255"^x04[PREFIX]^x01 " )
vformatmessage[len], 255 lensFormat)
message[192] = '^0'
message_beginindex MSG_ONE MSG_ALLget_user_msgid("SayText"), _index )
write_byteplayers[0] )
write_stringmessage )
message_end()
}
return 
1

Zpoke is offline
Zpoke
Senior Member
Join Date: Aug 2009
Location: Sweden
Old 08-14-2010 , 09:49   Re: Chat Prefixes
Reply With Quote #7

or why don't you just use

PHP Code:
#define PREFIX 
Zpoke is offline
Kreation
Veteran Member
Join Date: Jan 2010
Location: Illinois
Old 08-14-2010 , 20:10   Re: Chat Prefixes
Reply With Quote #8

Quote:
Originally Posted by GXLZPGX View Post
Thank you for the quick reply but that is too sloppy to organize, I do not need cvars etc, I just want a simple way to change the message.
This is scripting help, not do everything for me. Go to Suggestions / Requests.
__________________
Hi.
Kreation is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 08-14-2010 , 21:06   Re: Chat Prefixes
Reply With Quote #9

Simple and efficient : http://forums.alliedmods.net/showthr...99#post1265199
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
GXLZPGX
Veteran Member
Join Date: Sep 2009
Old 08-15-2010 , 08:58   Re: Chat Prefixes
Reply With Quote #10

Quote:
Originally Posted by Kreation View Post
This is scripting help, not do everything for me. Go to Suggestions / Requests.
Why do you troll so many topics? This is for scripting you moron. Suggestions/Requests is more for requesting whole plugins, I just want the event and how to change it.
__________________
Currently accepting payment US DOLLARS ONLY for custom plugins, contact me through PM.
GXLZPGX is offline
Reply



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 21:55.


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