Thread: [Solved] Chat Processor Limitations
View Single Post
Michael Shoe Maker
Senior Member
Join Date: Apr 2016
Old 02-03-2017 , 16:46   Re: Chat Processor Limitations
Reply With Quote #12

Thanks, that new buffer size is great.

However, I still am trying to convert to colour codes instead to maximize use like so:

PHP Code:
public Action CP_OnChatMessage(intiAuthorArrayList hRecipientschar[] sFlagStringchar[] sNamechar[] sMessageboolbProcessColoursboolbRemoveColours)
{
    if(!
IsValidClient(iAuthor))
    {
        return 
Plugin_Continue;
    }
    
    
Format(sNameMAXLENGTH_NAME" ");
    
    if(
g_iTagFlags[iAuthor] & TAG_LOADED && g_iTagFlags[iAuthor] & TAG_SHOWCUSTOM)
    {
        
char sAuthorName[MAX_NAME_LENGTH];
        
GetClientName(iAuthorsAuthorNamesizeof(sAuthorName));
    
        
Format(sNameMAXLENGTH_NAME"%s{default}[%s{default}] "sNameg_sTagFormatString[iAuthor]);
        
        
CProcessVariables(sNameMAXLENGTH_NAME);
        
        if(
strlen(sName) + strlen(sAuthorName) > MAXLENGTH_NAME)
        {
            if(
sMessage[0] != '!' && sMessage[0] != '/')
            {
                
RequestFrame(FrameRequestCallback_NameSizeErroriAuthor);
            }
            
            return 
Plugin_Stop;
        }
    }
    
    switch(
GetClientTeam(iAuthor))
    {
        case 
2:
        {
            
Format(sNameMAXLENGTH_NAME"%s{yellow}%N"sNameiAuthor);
        }
        
        case 
3:
        {
            
Format(sNameMAXLENGTH_NAME"%s{blue}%N"sNameiAuthor);
        }
        
        default:
        {
            
Format(sNameMAXLENGTH_NAME"%s{default}%N"sNameiAuthor);
        }
    }
    
    
Format(sMessageMAXLENGTH_MESSAGE"{default}%s"sMessage);
    
    
CProcessVariables(sNameMAXLENGTH_NAME);
    
CProcessVariables(sMessageMAXLENGTH_MESSAGE);
    
    
bProcessColours false;
    
    return 
Plugin_Changed;

I'm checking if their tag is set to be shown and if so:
- Format name with tag prefix
- Convert the colour tags to colour codes (each code max length of 4)
- Check if the length of the name string, author name, plus the addition space required for the name colouring exceeds the buffer size.

I do this same check when setting the tag in-game. But I get some weird results.
https://i.gyazo.com/cf05b1aea49f121d...cebbdc0648.png
Michael Shoe Maker is offline