View Single Post
11530
Veteran Member
Join Date: Sep 2011
Location: Underworld
Old 05-19-2012 , 20:38   Re: Colors in message
Reply With Quote #2

Taken from one of my other posts, given the message, sText, use the code below along with colors in the format {#FFFFFF} for RGB or {#FFFFFFFF} for RGBA etc.

PHP Code:
new iStartiEndiTotal;
decl String:sHex[9], String:sCodeBefore[12], String:sCodeAfter[10];
while ((
iStart StrContains(sText[(iTotal)], "{#")) != -1) {
    if ((
iEnd StrContains(sText[iTotal+iStart+2], "}")) != -1) {
        if (
iEnd == || iEnd == 8) {
            
strcopy(sHexiEnd+1sText[iTotal+iStart+2]);
            
Format(sCodeBeforesizeof(sCodeBefore), "{#%s}"sHex);
            
Format(sCodeAftersizeof(sCodeAfter), (iEnd == "\x07%s" "\x08%s"), sHex);
            
ReplaceString(sTextsizeof(sText), sCodeBeforesCodeAfter);
            
iTotal += iStart iEnd 1;
        }
        else {
            
iTotal += iStart iEnd 3;
        }
    }
    else {
        break;
    }

__________________

Last edited by 11530; 05-19-2012 at 20:41.
11530 is offline