03.10.2012, 17:31
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:
Usage
Simple. Like this:
Adding more colors to the function is very simple:
Credits
RaFaeL - Making the function
RyDeR`- The colors
Enjoy!
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; }
Simple. Like this:
Код:
printf("Color of Blue is: {%s}forum.sa-mp.co.il", ColorsName("Blue"));
Код:
{Color, Hex }
RaFaeL - Making the function
RyDeR`- The colors
Enjoy!