Advertisement
Guest User

Untitled

a guest
Jul 17th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. stock ColouredText(text[])
  2. {
  3.     enum
  4.         colorEnum
  5.         {
  6.             colorName[16],
  7.             colorID[7]
  8.         }
  9.     ;
  10.     new
  11.         colorInfo[][colorEnum] =
  12.         {
  13.             { "BLUE",           "1B1BE0" },
  14.             { "PINK",           "E81CC9" },
  15.             { "YELLOW",         "DBED15" },
  16.             { "LIGHTGREEN",     "8CED15" },
  17.             { "LIGHTBLUE",      "15D4ED" },
  18.             { "RED",            "FF0000" },
  19.             { "GREY",           "BABABA" },
  20.             { "WHITE",          "FFFFFF" },
  21.             { "ORANGE",         "DB881A" },
  22.             { "GREEN",          "37DB45" },
  23.             { "PURPLE",         "7340DB" }
  24.         },
  25.         string[(128 + 32)],
  26.         tempString[16],
  27.         pos = -1,
  28.         x
  29.     ;
  30.     strmid(string, text, 0, 128, sizeof(string));
  31.  
  32.     for( ; x != sizeof(colorInfo); ++x)
  33.     {
  34.         format(tempString, sizeof(tempString), "#%s", colorInfo[x][colorName]);
  35.  
  36.         while((pos = strfind(string, tempString, true, (pos + 1))) != -1)
  37.         {
  38.             new
  39.                 tempLen = strlen(tempString),
  40.                 tempVar,
  41.                 i = pos
  42.             ;
  43.             format(tempString, sizeof(tempString), "{%s}", colorInfo[x][colorID]);
  44.  
  45.             if(tempLen < 8)
  46.             {
  47.                 for(new j; j != (8 - tempLen); ++j)
  48.                 {
  49.                     strins(string, " ", pos);
  50.                 }
  51.             }
  52.             for( ; ((string[i] != 0) && (tempVar != 8)) ; ++i, ++tempVar)
  53.             {
  54.                 string[i] = tempString[tempVar];
  55.             }
  56.             if(tempLen > 8)
  57.             {
  58.                 strdel(string, i, (i + (tempLen - 8)));
  59.             }
  60.             x = -1;
  61.         }
  62.     }
  63.     return string;
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement