SA-MP Forums Archive
[Include] Colors Name to Hex - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Filterscripts (https://sampforum.blast.hk/forumdisplay.php?fid=17)
+---- Forum: Includes (https://sampforum.blast.hk/forumdisplay.php?fid=83)
+---- Thread: [Include] Colors Name to Hex (/showthread.php?tid=382493)



Colors Name to Hex - Swimor - 03.10.2012

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!



Re: Colors Name to Hex - Simplyfrag - 07.10.2012

any ss m8