Raised This Month: $ Target: $400
 0% 

Remove colors from a color formatted string.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Chdata
Veteran Member
Join Date: Aug 2012
Location: Computer Chair, Illinois
Old 12-17-2017 , 20:17   Remove colors from a color formatted string.
Reply With Quote #1

This is something I ended up needing for a plugin that sends command results through a socket to a bot, to get rid of color codes from chat messages formatted by morecolors or similar.

Not the most efficient but it works.

PHP Code:
stock void RemoveColorCodes(char[] szTextint iSize)
{
    for (
int i 0iSize && szText[i] != '\0'i++)
    {
        if (
szText[i] >= '\1' && szText[i] <= '\6')
        {
            
strcopy(szText[i], iSize-iszText[i+1]);
        }
        else
        {
            switch (
szText[i])
            {
                case 
'\7':
                {
                    
strcopy(szText[i], iSize-iszText[i+4]); // \x07%06X \x07 0x3E FF 3E (4 bytes)
                
}
                case 
'\8':
                {
                    
strcopy(szText[i], iSize-iszText[i+5]); // \x08 00 00 00 32 (5 bytes)
                
}
            }
        }
    }

__________________

Last edited by Chdata; 12-17-2017 at 20:18.
Chdata is offline
Reply


Thread Tools
Display Modes

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 23:45.


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