Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- stock ColouredText(text[])
- {
- enum
- colorEnum
- {
- colorName[16],
- colorID[7]
- }
- ;
- new
- colorInfo[][colorEnum] =
- {
- { "BLUE", "1B1BE0" },
- { "PINK", "E81CC9" },
- { "YELLOW", "DBED15" },
- { "LIGHTGREEN", "8CED15" },
- { "LIGHTBLUE", "15D4ED" },
- { "RED", "FF0000" },
- { "GREY", "BABABA" },
- { "WHITE", "FFFFFF" },
- { "ORANGE", "DB881A" },
- { "GREEN", "37DB45" },
- { "PURPLE", "7340DB" }
- },
- string[(128 + 32)],
- tempString[16],
- pos = -1,
- x
- ;
- strmid(string, text, 0, 128, sizeof(string));
- for( ; x != sizeof(colorInfo); ++x)
- {
- format(tempString, sizeof(tempString), "#%s", colorInfo[x][colorName]);
- while((pos = strfind(string, tempString, true, (pos + 1))) != -1)
- {
- new
- tempLen = strlen(tempString),
- tempVar,
- i = pos
- ;
- format(tempString, sizeof(tempString), "{%s}", colorInfo[x][colorID]);
- if(tempLen < 8)
- {
- for(new j; j != (8 - tempLen); ++j)
- {
- strins(string, " ", pos);
- }
- }
- for( ; ((string[i] != 0) && (tempVar != 8)) ; ++i, ++tempVar)
- {
- string[i] = tempString[tempVar];
- }
- if(tempLen > 8)
- {
- strdel(string, i, (i + (tempLen - 8)));
- }
- x = -1;
- }
- }
- return string;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement