Raised This Month: $51 Target: $400
 12% 

Solved Chat Processor Limitations


Post New Thread Reply   
 
Thread Tools Display Modes
404UserNotFound
BANNED
Join Date: Dec 2011
Old 02-02-2017 , 20:16   Re: Chat Processor Limitations
Reply With Quote #11

redwerewolf recently did something to his Chat Processor that bypasses the name size buffer thingme or something. Go check that out, that may be a better lead. He's told me what he did like, twice, but I still can't rightly remember the entirety of what he said (thank you mary jane)
404UserNotFound is offline
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
Michael Shoe Maker
Senior Member
Join Date: Apr 2016
Old 02-04-2017 , 16:55   Re: Chat Processor Limitations
Reply With Quote #13

PHP Code:
char sArg[MAX_UNPROCESSED_LENGTH];
        
GetCmdArgString(sArgsizeof(sArg));
        
        
char sTemp[MAX_UNPROCESSED_LENGTH];
        
Format(sTempsizeof(sTemp), sArg);
        
CProcessVariables(sTempsizeof(sTemp));
        
        
PrintToChat(iClient"Size: %d"strlen(sTemp));
        
PrintToConsole(iClient"String: %s"sTemp);
        
        
// MAX_UNPROCESSED_LENGTH = 128
        // MAX_FORMAT_LENGTH = 64
        // MAX_TAG_LENGTH = 16
        // {blue}H{red}e{orchid}y{blue}H{red}e{orchid}y{blue}H{red}e{orchid}y{blue}H{red}e{orchid}y{blue}H{red}e{orchid}y{blue}Hey        Length: 119
        // 0x24H0x34e0x35y0x24H0x34e0x35y0x24H0x34e0x35y0x24H0x34e0x35y0x24H0x34e0x35y0x24Hey        Length: 82 (Printed Length = 34) ??
        
        
if(strlen(sTemp) > MAX_FORMAT_LENGTH)
        {
            
ReplyToCommand(iClient"[%s] Error, entered tag format exceeds character limit. (Including colour tags)"PREFIX);
        
            return 
Plugin_Handled;
        }
        
        if(
GetFormatTrueLength(sArgsizeof(sArg)) > MAX_TAG_LENGTH)
        {
            
ReplyToCommand(iClient"[%s] Error, entered tag format exceeds character limit. (Excluding colour tags)"PREFIX);
        
            return 
Plugin_Handled;
        } 
I'm checking if the format, when processed, exceeds a limit. And if when colours are removed, it exceeds the visible character limit (To keep chat legible).

Why is the printed length 34 when it exceeds the limit specified?

EDIT: I know those codes aren't right, I just know they can be 4 chars long

Last edited by Michael Shoe Maker; 02-04-2017 at 16:57.
Michael Shoe Maker is offline
404UserNotFound
BANNED
Join Date: Dec 2011
Old 02-04-2017 , 20:34   Re: Chat Processor Limitations
Reply With Quote #14

I did some experimenting with the 82 length line. I removed all the numbers (because I had a feeling it was the case) but kept the "x" from the codes.

xHxexyxHxexyxHxexyxHxexyxHxexyxHey = 34 chars.

I don't know why it's not handling it properly when the string is over the limit though

Last edited by 404UserNotFound; 02-04-2017 at 20:35.
404UserNotFound is offline
Michael Shoe Maker
Senior Member
Join Date: Apr 2016
Old 02-04-2017 , 20:47   Re: Chat Processor Limitations
Reply With Quote #15

Quote:
Originally Posted by abrandnewday View Post
I did some experimenting with the 82 length line. I removed all the numbers (because I had a feeling it was the case) but kept the "x" from the codes.

xHxexyxHxexyxHxexyxHxexyxHxexyxHey = 34 chars.

I don't know why it's not handling it properly when the string is over the limit, though
Why is that, though? I printed the string in the console to see if it would print the codes but all I got was something like "{{}".

This is stopping me from finishing the plugin and its frustrating af.

(Just to clarify. I use the max length of 64 so it gives plenty of room for max name length and other formatting later on)
Michael Shoe Maker is offline
Drixevel
AlliedModders Donor
Join Date: Sep 2009
Location: Somewhere headbangin'
Old 02-06-2017 , 13:59   Re: Chat Processor Limitations
Reply With Quote #16

Pushed a new update, see if it affects anything and be sure to return Plugin_Handled in the pre-forward just to make sure the Chat-Processor itself is handling the message outputs.
Drixevel is offline
Michael Shoe Maker
Senior Member
Join Date: Apr 2016
Old 02-06-2017 , 17:23   Re: Chat Processor Limitations
Reply With Quote #17

PHP Code:
#define MAX_TAG_LENGTH            16
#define MAX_PROCESSED_LENGTH    MAX_TAG_LENGTH * 2
#define MAX_UNPROCESSED_LENGTH    MAX_TAG_LENGTH + (MAX_TAG_LENGTH * 9) 
Just used these.

Last edited by Michael Shoe Maker; 02-07-2017 at 09:33.
Michael Shoe Maker 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 20:38.


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