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

Solved Chat Processor Limitations


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Michael Shoe Maker
Senior Member
Join Date: Apr 2016
Old 01-11-2017 , 14:46   Chat Processor Limitations
Reply With Quote #1

Jellow,

I'm using this plugin to add chat tags and colours easier and better (https://forums.alliedmods.net/showthread.php?t=286913).

However there are limitations concerning the length of the name of the client. Which at a max is 32...

To elaborate, this is what I did before (Very messy):
PHP Code:
public Action OnClientSayCommand(int client, const char[] command, const char[] args)
{
    if(
client == || args[0] == '@' || args[0] == '/' || BaseComm_IsClientGagged(client) || warden_iswarden(client))
    {
        return 
Plugin_Continue;
    }

    if((
g_bTagLoaded[client] && !g_bCustomTagDisabled[client]) || (IsClientAdmin(client) && !g_bAdminTagDisabled[client]))
    {
        
char sChatString[256];
    
        if(
IsClientAdmin(client) && !g_bAdminTagDisabled[client])
        {
            
char sGroup[32];
            
GetClientAdminGroup(clientsGroupsizeof(sGroup));
            
            if(
strlen(sGroup) > 0)
            {
                
FormatEx(sChatStringsizeof(sChatString), "{default}[{blue}%s{default}] "sGroup);
            }
        }
    
        if(
g_bTagLoaded[client] && !g_bCustomTagDisabled[client])
        {
            
FormatEx(sChatStringsizeof(sChatString), "%s{default}[%s{default}] "sChatStringg_sTagFormatString[client]);
        }
        
        
FormatEx(sChatStringsizeof(sChatString), "%s%s%N{default}: %s"sChatString, (g_bTagLoaded[client] && !g_bCustomTagDisabled[client]) ? g_sNameColourString[client] : g_sTeamColours[GetClientTeam(client) - 1], client, (g_bTagLoaded[client] && !g_bCustomTagDisabled[client]) ? g_sTextColourString[client] : g_sTeamColours[GetClientTeam(client) - 1]);

        if(
StrEqual(command"say"))
        {
            switch(
GetClientTeam(client))
            {
                case 
1:
                {
                    
CPrintToChatAll("%s%s"sChatStringargs);
                }
                case 
2:
                {
                    
CPrintToChatAll("%s %s%s", !IsPlayerAlive(client) ? "{yellow}*DEAD*" ""sChatStringargs);
                }
                case 
3:
                {
                    
CPrintToChatAll("%s %s%s", !IsPlayerAlive(client) ? "{bluegrey}*DEAD*" ""sChatStringargs);
                }
            }
        }
        else if(
StrEqual(command"say_team"))
        {
            for(
int i 1<= MaxClientsi++)
            {
                if(
IsValidClient(i))
                {
                    if(
GetClientTeam(client) == GetClientTeam(i))
                    {
                        switch(
GetClientTeam(client))
                        {
                            case 
1:
                            {
                                
CPrintToChat(i"{default}(Spectator) %s%s"sChatStringargs);
                            }
                            case 
2:
                            {
                                
CPrintToChat(i"%s {yellow}(Terrorist) %s%s", !IsPlayerAlive(client) ? "{yellow}*DEAD*" ""sChatStringargs);
                            }
                            case 
3:
                            {
                                
CPrintToChat(i"%s {bluegrey}(Counter-Terrorist) %s%s", !IsPlayerAlive(client) ? "{bluegrey}*DEAD*" ""sChatStringargs);
                            }
                        }
                    }
                }
            }
        }
        
        
PrintToServer("%L: %s"clientargs);
        
LogToGame("\"%L\" say \"%s\""clientargs);
        
        return 
Plugin_Handled;
    }
    
    return 
Plugin_Continue;

And I tried this but it won't work with the limit:
PHP Code:
public Action OnChatMessage(int &iAuthorArrayList hRecipientschar[] sFlagStringchar[] sNamechar[] sMessagebool &ProcessColoursbool &RemoveColours)
{
    if(!
IsValidClient(iAuthor) || sMessage[0] == '@' || sMessage[0] == '/' || BaseComm_IsClientGagged(iAuthor))
    {
        return 
Plugin_Continue;
    }
    
    if(
IsClientAdmin(iAuthor) && g_iTagFlags[iAuthor] & TAG_SHOWADMIN)
    {
        
char sGroup[32];
        
GetClientAdminGroup(iAuthorsGroupsizeof(sGroup));
        
        if(
strlen(sGroup) > 0)
        {
            
FormatEx(sNameMAXLENGTH_NAME"{default}[{blue}%s{default}] "sGroup);
        }
    }
    
    if(
g_iTagFlags[iAuthor] & TAG_LOADED && g_iTagFlags[iAuthor] & TAG_SHOWCUSTOM)
    {
        
FormatEx(sNameMAXLENGTH_NAME"%s{default}[%s{default}] "sNameg_sTagFormatString[iAuthor]);
    }
    
    
FormatEx(sNameMAXLENGTH_NAME"%s%N"sNameiAuthor);
    
    return 
Plugin_Changed;

Any ideas? Or do I just do it the bad way.

Last edited by Michael Shoe Maker; 02-07-2017 at 09:32.
Michael Shoe Maker is offline
KissLick
Veteran Member
Join Date: Nov 2012
Location: void
Old 01-11-2017 , 15:47   Re: Chat Processor Limitations
Reply With Quote #2

Try to call CProcessVariables(str, strLen) to translate the color names to codes.
__________________
Plugins: TeamGames
Includes: Menu stocks, ColorVariables, DownloadTableConfig

> No help through PM, make a topic.
KissLick is offline
Michael Shoe Maker
Senior Member
Join Date: Apr 2016
Old 01-11-2017 , 17:23   Re: Chat Processor Limitations
Reply With Quote #3

Quote:
Originally Posted by KissLick View Post
Try to call CProcessVariables(str, strLen) to translate the color names to codes.
Tried this and setting "ProcessVariables" to true. Just resulted in the name overlapping into the message and creating some weird bug.
Michael Shoe Maker is offline
KissLick
Veteran Member
Join Date: Nov 2012
Location: void
Old 01-11-2017 , 17:50   Re: Chat Processor Limitations
Reply With Quote #4

Looks like name is 64 chars long - https://github.com/Drixevel/Chat-Pro...ocessor.inc#L8

Anyway, you can recompile Chat Processor with modified name length
__________________
Plugins: TeamGames
Includes: Menu stocks, ColorVariables, DownloadTableConfig

> No help through PM, make a topic.
KissLick is offline
Drixevel
AlliedModders Donor
Join Date: Sep 2009
Location: Somewhere headbangin'
Old 01-12-2017 , 03:58   Re: Chat Processor Limitations
Reply With Quote #5

I'm pretty sure the limitations set in the defines for the plugin are engine limits. If they can be increased then let me know but I think those are defaults.
Drixevel is offline
404UserNotFound
BANNED
Join Date: Dec 2011
Old 01-18-2017 , 15:39   Re: Chat Processor Limitations
Reply With Quote #6

I'm guessing you're attempting the same thing I already attempted and half-succeeded at doing. What with the many support threads I made on this, I'm surprised no-one here mentioned that to you. You can't actually bypass the client name maxlen, but you can work around it.

Here's a paste of the Chat Processor Tags plugin I created, released, and then removed because it actually suffered from a bug that redwerewolf and I haven't been able to fix in TF2, where it will spam chat with multiple copies of the same chat message (one copy for each player currently on the server): http://pastebin.com/iMk84iGP

Specifically, I'll direct you to line 569 (OnChatMessagePost) to see how I go about working around the client name maxlen that allowed me to successfully have long, multicolored tags without having half the client name chopped off by the maxlen.

Now right off the bat you'll notice I'm doing a bad thing and using CPrintToChatAll within OnChatMessagePost which is advised against because it can lead to said message duplication issues, but at the time redwerewolf and I were looking at red's Chat Processor plugin and trying to find a way to manually send the chat message out to each client via something like a standard CPrintToChat, but to no avail.

So yeah, feel free to continue trying to make this work, but as shown above, I already tried, succeeded somewhat, but failed overall.

Here's the final product, long multicolored tags without half my name being cut off, plus I showed how many characters still show up for the chat message. I hit the limit on text I could send through the chatbox with the message below:


And if you want my research, here's a thread full of it.

Last edited by 404UserNotFound; 01-18-2017 at 15:48.
404UserNotFound is offline
Michael Shoe Maker
Senior Member
Join Date: Apr 2016
Old 01-18-2017 , 17:25   Re: Chat Processor Limitations
Reply With Quote #7

Quote:
Originally Posted by abrandnewday View Post
I'm guessing you're attempting the same thing I already attempted and half-succeeded at doing. What with the many support threads I made on this, I'm surprised no-one here mentioned that to you. You can't actually bypass the client name maxlen, but you can work around it.

Here's a paste of the Chat Processor Tags plugin I created, released, and then removed because it actually suffered from a bug that redwerewolf and I haven't been able to fix in TF2, where it will spam chat with multiple copies of the same chat message (one copy for each player currently on the server): http://pastebin.com/iMk84iGP

Specifically, I'll direct you to line 569 (OnChatMessagePost) to see how I go about working around the client name maxlen that allowed me to successfully have long, multicolored tags without having half the client name chopped off by the maxlen.

Now right off the bat you'll notice I'm doing a bad thing and using CPrintToChatAll within OnChatMessagePost which is advised against because it can lead to said message duplication issues, but at the time redwerewolf and I were looking at red's Chat Processor plugin and trying to find a way to manually send the chat message out to each client via something like a standard CPrintToChat, but to no avail.

So yeah, feel free to continue trying to make this work, but as shown above, I already tried, succeeded somewhat, but failed overall.

Here's the final product, long multicolored tags without half my name being cut off, plus I showed how many characters still show up for the chat message. I hit the limit on text I could send through the chatbox with the message below:


And if you want my research, here's a thread full of it.
Thanks for such a detailed reply. This is quite a bummer. I wanted to use CP since it required so little fuss with managing chat.

PrintToChat seems like such a messy and bad way to do things :/
Michael Shoe Maker is offline
Michael Shoe Maker
Senior Member
Join Date: Apr 2016
Old 01-19-2017 , 16:52   Re: Chat Processor Limitations
Reply With Quote #8

I've decided to just limit the size of the tag because this is just a massive hassle, but to my delight it turns out I can't even get this right.

I tried:
PHP Code:
public Action OnChatMessage(intiAuthorArrayList hRecipientschar[] sFlagStringchar[] sNamechar[] sMessageboolbProcessColoursboolbRemoveColours)
{
    if(!
IsValidClient(iAuthor))
    {
        return 
Plugin_Continue;
    }

    
//Format(sName, MAXLENGTH_NAME, " ");
    
    /* if(g_iTagFlags[iAuthor] & TAG_LOADED && g_iTagFlags[iAuthor] & TAG_SHOWCUSTOM)
    {
        Format(sName, MAXLENGTH_NAME, "%s{default}[%s{default}] ", sName, g_sTagFormatString[iAuthor]);
    } */
    
    
Format(sNameMAXLENGTH_NAME"{red}%s"sName);
    
    
Format(sMessageMAXLENGTH_MESSAGE"{blue}%s"sMessage);

    return 
Plugin_Changed;

And only the message colour works in all chat, and both work only in team chat??
Michael Shoe Maker is offline
404UserNotFound
BANNED
Join Date: Dec 2011
Old 01-19-2017 , 21:03   Re: Chat Processor Limitations
Reply With Quote #9

I was actually shown a fix for the multiple message error by nosoop. His version of SCP has a proper fix for the issue.: https://git.csrd.science/nosoop/CSRD...atprocessor.sp

Quote:
Originally Posted by nosoop
The way I solved it is to map unique messages (stored as, for example, #TF_Chat_All:Hi everyone!) to an ArrayList with all recipients in a per-client StringMap. During a SDKHook_PostThink hook, the messages are processed and passed to forwards, then flushed out to chat if permitted.
Potentially, someone could take the above fix, implement it and then create a brand new chat tags plugin with the ability to use multi-colored chat tags and incredibly long tags. I'm already working on a similar system but it's private (the main body of the system is a private commission I paid for and haven't been able to use yet due to the multi-message spam glitch)

Last edited by 404UserNotFound; 01-19-2017 at 21:06.
404UserNotFound is offline
Michael Shoe Maker
Senior Member
Join Date: Apr 2016
Old 02-02-2017 , 19:31   Re: Chat Processor Limitations
Reply With Quote #10

Decided to just keep it simple and make the chat uniform and have a limited size tag.

I want to check if the name of the player exceeds the max, this is easy but I want to squeeze the most characters into the string. I thought I could convert the colours into codes with CProcessVariables and set ProcessColours to false. This didnt work at all.

Last edited by Michael Shoe Maker; 02-02-2017 at 19:32.
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 01:00.


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