Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- enum ColorsVars
- {
- ColorName[16],
- ColorID[7]
- };
- new ColorsTag[][ColorsVars] =
- {
- {"Green", "00FF33"},
- {"Red", "FF2626"},
- {"White", "FFFFFF"},
- {"Blue", "0088FF"},
- {"Yellow", "FFFB00"},
- {"Orange", "FFA600"},
- {"Grey", "B8B8B8"},
- {"Purple", "7340DB"}
- },
- String[160];
- #define FStrcat(%0,%1,%2) format(String, sizeof(String),%1,%2) && strcat(%0, String)
- #define DialogColors 1
- public OnPlayerText(playerid, text[])
- {
- new sText[128], pName[MAX_PLAYERS];
- GetPlayerName(playerid, pName, sizeof(pName));
- format(sText, sizeof(sText), "%s: {FFFFFF}%s {FFFFFF}[ID: %d]", pName[playerid], ColouredText(text[0]), playerid) && SendClientMessageToAll(GetPlayerColor(playerid), sText);
- return 0;
- }
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- if(strcmp(cmdtext, "/cList", true) == 0)
- {
- new sColors[128];
- for(new C = 0; C < sizeof(ColorsTag); C ++) FStrcat(sColors, "{%s}%s\n", ColorsTag[C][ColorID], ColorsTag[C][ColorName]);
- ShowPlayerDialog(playerid, DialogColors, DIALOG_STYLE_MSGBOX, "{99CCFF}Chat Colors", sColors, "Okay", "");
- return 1;
- }
- return 1;
- }
- stock ColouredText(text[])
- {
- new tString[16], I = -1;
- strmid(String, text, 0, 128, sizeof(String));
- for(new C = 0; C != sizeof(ColorsTag); C ++)
- {
- format(tString, sizeof(tString), "(%s)", ColorsTag[C][ColorName]);
- while((I = strfind(String, tString, true, (I + 1))) != -1)
- {
- new tLen = strlen(tString);
- format(tString, sizeof(tString), "{%s}", ColorsTag[C][ColorID]);
- if(tLen < 8) for(new C2 = 0; C2 != (8 - tLen); C2 ++) strins(String, " ", I);
- for(new tVar; ((String[I] != 0) && (tVar != 8)); I ++, tVar ++) String[I] = tString[tVar];
- if(tLen > 8) strdel(String, I, (I + (tLen - 8)));
- }
- }
- return String;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement