Advertisement
_iLustcheR_

[SAMP-IL] Chat colors by LustcheR v1.0 - English

Dec 30th, 2014
855
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 1.84 KB | None | 0 0
  1. #include <a_samp>
  2.  
  3. enum ColorsVars
  4. {
  5.     ColorName[16],
  6.     ColorID[7]
  7. };
  8. new ColorsTag[][ColorsVars] =
  9. {
  10.     {"Green",  "00FF33"},
  11.     {"Red",    "FF2626"},
  12.     {"White",  "FFFFFF"},
  13.     {"Blue",   "0088FF"},
  14.     {"Yellow", "FFFB00"},
  15.     {"Orange", "FFA600"},
  16.     {"Grey",   "B8B8B8"},
  17.     {"Purple", "7340DB"}
  18. },
  19. String[160];
  20.    
  21. #define FStrcat(%0,%1,%2) format(String, sizeof(String),%1,%2) && strcat(%0, String)
  22. #define DialogColors 1
  23.  
  24. public OnPlayerText(playerid, text[])
  25. {
  26.     new sText[128], pName[MAX_PLAYERS];
  27.     GetPlayerName(playerid, pName, sizeof(pName));
  28.     format(sText, sizeof(sText), "%s: {FFFFFF}%s {FFFFFF}[ID: %d]", pName[playerid], ColouredText(text[0]), playerid) && SendClientMessageToAll(GetPlayerColor(playerid), sText);
  29.     return 0;
  30. }
  31.  
  32. public OnPlayerCommandText(playerid, cmdtext[])
  33. {
  34.     if(strcmp(cmdtext, "/cList", true) == 0)
  35.     {
  36.         new sColors[128];
  37.         for(new C = 0; C < sizeof(ColorsTag); C ++) FStrcat(sColors, "{%s}%s\n", ColorsTag[C][ColorID], ColorsTag[C][ColorName]);
  38.         ShowPlayerDialog(playerid, DialogColors, DIALOG_STYLE_MSGBOX, "{99CCFF}Chat Colors", sColors, "Okay", "");
  39.         return 1;
  40.     }
  41.     return 1;
  42. }
  43.  
  44. stock ColouredText(text[])
  45. {
  46.     new tString[16], I = -1;
  47.     strmid(String, text, 0, 128, sizeof(String));
  48.     for(new C = 0; C != sizeof(ColorsTag); C ++)
  49.     {
  50.         format(tString, sizeof(tString), "(%s)", ColorsTag[C][ColorName]);
  51.         while((I = strfind(String, tString, true, (I + 1))) != -1)
  52.         {
  53.             new tLen = strlen(tString);
  54.             format(tString, sizeof(tString), "{%s}", ColorsTag[C][ColorID]);
  55.             if(tLen < 8) for(new C2 = 0; C2 != (8 - tLen); C2 ++) strins(String, " ", I);
  56.             for(new tVar; ((String[I] != 0) && (tVar != 8)); I ++, tVar ++) String[I] = tString[tVar];
  57.             if(tLen > 8) strdel(String, I, (I + (tLen - 8)));
  58.         }
  59.     }
  60.     return String;
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement