AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Problem with message (https://forums.alliedmods.net/showthread.php?t=183952)

Enomine 04-28-2012 19:06

Problem with message
 
I made a All Chat & Dead Name Changer, but I have a problem with all chat.
When admins uses the chat doesn't change the color and have an extra space in nick and chat...

PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <fakemeta>

/* Pragma */
#pragma semicolon    1

/* Message */
new SayText;

public 
plugin_init()
{
    
/* Plugin Registration */
    
register_plugin("AllChat & Dead Name Changer","0.0.1","Enomine");
    
    
/* Forward */
    
register_forward(FM_ClientUserInfoChanged,"fwdClientInfoChanged");
    
    
/* Messages */
    
SayText get_user_msgid("SayText");
    
register_message(SayText,"MsgSayText");
}

public 
MsgSayText(MsgID,MsgDEST,id)
{
    if(!
id)
        return 
PLUGIN_CONTINUE;
        
    new 
said[192];
    
get_msg_arg_string(4,said,charsmax(said));
    
    new 
name[32];
    
get_user_name(id,name,charsmax(name));
    
    new 
msg[193];
    new 
namex[33];
    
    if(
id == get_msg_arg_int(1))
    {
        if(
is_user_admin(id))
        {
            
formatex(msg,charsmax(msg),"^x01%s",said);
            
formatex(namex,charsmax(namex),"^x04%s",name);
            
MessageSaytext(id,namex,msg);
        }
        else
            
MessageSaytext(id,name,said);
    }
    
    return 
PLUGIN_HANDLED;
}

public 
fwdClientInfoChanged(idbuffer)
{
    if(!
is_user_connected(id))
        return 
FMRES_IGNORED;
    
    new 
name[32];
    new 
newname[32];
    
    
get_user_name(id,name,charsmax(name));
    
engfunc(EngFunc_InfoKeyValue,buffer,"name",newname,charsmax(newname));
    
    if(
equal(name,newname))
        return 
FMRES_IGNORED;
        
    new 
Message[33];
        
    if(
is_user_admin(id))
    {
        
formatex(Message,charsmax(Message),"^x04%s",newname);
        
MsgNameChange(id,name,Message);
    }
    else
        
MsgNameChange(id,name,newname);
    
    return 
FMRES_SUPERCEDE;
}
    
    
public 
MsgNameChange(id,name[],newname[])
{
    
message_begin(MSG_BROADCASTSayText);
    
write_byte(id);
    
write_string("#Cstrike_Name_Change");
    
write_string(name);
    
write_string(newname);
    
message_end();
}


public 
MessageSaytext(id,name[],said[])
{
    
message_begin(MSG_BROADCAST,SayText);
    
write_byte(id);
    
write_string("#Cstrike_Chat_All");
    
write_string(name);
    
write_string(said);
    
message_end();



Exolent[jNr] 04-28-2012 19:27

Re: Problem with message
 
Try this:
PHP Code:

            formatex(msg,charsmax(msg),"%c%s",0x01,said);
            
formatex(namex,charsmax(namex),"%c%s",0x04,name); 


ConnorMcLeod 04-28-2012 19:28

Re: Problem with message
 
Because #Cstrike_Name_Change starts with 0x02, which had to consequence to only change name into team color, so 0x04 (^4) has no effect.

Try "^4#Cstrike_Name_Change"

Enomine 04-28-2012 19:37

Re: Problem with message
 
Quote:

Originally Posted by Exolent[jNr] (Post 1698407)
Try this:
PHP Code:

            formatex(msg,charsmax(msg),"%c%s",0x01,said);
            
formatex(namex,charsmax(namex),"%c%s",0x04,name); 


Doesn't work.

Quote:

Originally Posted by ConnorMcLeod (Post 1698408)
Because #Cstrike_Name_Change starts with 0x02, which had to consequence to only change name into team color, so 0x04 (^4) has no effect.

Try "^4#Cstrike_Name_Change"

Name Changer is working very well, allchat is who doesn't change the color.


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

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