28.06.2011, 10:49
try this
Код:
stock ColouredText(text[]) { enum colorEnum { colorName[16], colorID[7] } ; new colorInfo[][colorEnum] = { { "BLUE", "0x1B1BE0" }, { "PINK", "0xE81CC9" }, { "YELLOW", "0xDBED15" }, { "LIGHTGREEN", "0x8CED15" }, { "LIGHTBLUE", "0x15D4ED" }, { "RED", "0xFF0000" }, { "GREY", "0xBABABA" }, { "WHITE", "0xFFFFFF" }, { "ORANGE", "0xDB881A" }, { "GREEN", "0x37DB45" }, { "PURPLE", "0x7340DB" } }, 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; }