Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- new playerColors[MAX_PLAYERS][3]; // Pole pre uchovávanie farieb hráčov [hráč][0: titul, 1: nick, 2: text písma]
- public OnPlayerConnect(playerid) {
- for (new i = 0; i < 3; i++)
- playerColors[playerid][i] = 0xFFFFFF; // Nastavenie predvolených farieb hráča na bielu
- SetPlayerColor(playerid, playerColors[playerid][0], playerColors[playerid][1], playerColors[playerid][2]);
- return 1;
- }
- public OnPlayerCommandText(playerid, cmdtext[]) {
- if (!strcmp(cmdtext, "/setcolor", true)) {
- ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "Nastavenie farieb", "Zadajte hexadecimálny kód farby pre titul, nick a text písma oddelený čiarkami (napr. FFFFFF,FF0000,00FF00):", "OK", "Zrušiť");
- return 1;
- }
- return 0;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) {
- if (dialogid == 1 && response) {
- new colorData[3][6];
- sscanf(inputtext, "s[6],s[6],s[6]", colorData[0], colorData[1], colorData[2]);
- for (new i = 0; i < 3; i++) {
- if (!IsValidColor(colorData[i])) {
- SendClientMessage(playerid, 0xFFFFFFAA, "Neplatný hexadecimálny kód farby. Skúste znova.");
- return 1;
- }
- playerColors[playerid][i] = strval(colorData[i]);
- }
- SetPlayerColor(playerid, playerColors[playerid][0], playerColors[playerid][1], playerColors[playerid][2]);
- SendClientMessage(playerid, 0xFFFFFFAA, "Farby boli úspešne zmenené.");
- }
- return 1;
- }
- forward IsValidColor(color[]);
- public IsValidColor(color[]) {
- new length = strlen(color);
- if (length != 6)
- return false;
- for (new i = 0; i < length; i++) {
- if (!(color[i] >= '0' && color[i] <= '9') && !(color[i] >= 'A' && color[i] <= 'F') && !(color[i] >= 'a' && color[i] <= 'f'))
- return false;
- }
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement