[Include] Colors Name to Hex
#1

Colors Name to Hex

Hey all,
This is simple function that i made in 2 minutes.
The function returns the color Hex from color name, Like blue to 1B1BE0.

Code
This is simple code, his level is -5 and i will show the code in the forum:
Код:
stock ColorsName(color[])
{
    enum eColor
        {
            colorName[16],
            colorID[7]
        };
    new cInfo[][eColor] =
        {
        //  {Color,             Hex      }
            { "BLUE",           "1B1BE0" },
            { "PINK",           "E81CC9" },
            { "YELLOW",         "DBED15" },
            { "LIGHTGREEN",     "8CED15" },
            { "LIGHTBLUE",      "15D4ED" },
            { "RED",            "FF0000" },
            { "GREY",           "BABABA" },
            { "WHITE",          "FFFFFF" },
            { "ORANGE",         "DB881A" },
            { "GREEN",          "37DB45" },
            { "PURPLE",         "7340DB" }
        },
		tString[7];

    for(new x; x != sizeof(cInfo); x++) if(!strcmp(cInfo[x][colorName], color, true))
    {
		format(tString, 7, "%s", cInfo[x][colorID]);
		return tString;
    }
    return tString;
}
Usage
Simple. Like this:
Код:
printf("Color of Blue is: {%s}forum.sa-mp.co.il", ColorsName("Blue"));
Adding more colors to the function is very simple:
Код:
{Color,             Hex      }
Credits
RaFaeL - Making the function
RyDeR`- The colors

Enjoy!
Reply
#2

any ss m8
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)