View Single Post
Mitchell
~lick~
Join Date: Mar 2010
Old 09-03-2019 , 12:32   Re: [HELP] Set Player's Name Color
Reply With Quote #3

Quote:
Originally Posted by Mathiaas View Post
Quickly reading through your code, it's not like your OnChatMessage callback does anything? Sure you format the "name" string but that's not what's being sent out to the clients as the message.

You will probably have to stop your message from going out and send your own, customized one. It's 03 in the morning and tired af, but try this one:

PHP Code:
public Action OnChatMessage(intauthorHandle recipientschar[] namechar[] message)
{
    
char file[512];
    
char msg[200];
    
BuildPath(Path_SMfilesizeof(file), "nc.cfg");
    
    
KeyValues kv = new KeyValues("NC");
    
kv.ImportFromFile(file);
    
    
char sid[64];
    
GetClientAuthId(authorAuthId_Steam2sidsizeof(sid));
    if(
KvJumpToKey(kvsid))
    {
        
char color[64];
        
KvGetString(kv"cor"colorsizeof(color));
        
Format(msgsizeof(msg), "%s%s: %s"colornamemessage);
        
PrintToChatAll(msg); // Change this into "SayText2" if you want the teamcolors in case you want teamchat etc. https://forums.alliedmods.net/showthread.php?t=206539
        
return Plugin_Handled;
    }
    return 
Plugin_Continue;

OnChatMessage comes from the scp include or a similar chat-processor.
There are several things wrong with this code, especially the reading the keyvalue from file everytime some one types in chat.
There are a ton of custom chat color plugins already out there try using those as examples and write your code off of that.
Mitchell is offline