Advertisement
Deaderik

Setcolor FS nastavenia farby nick titul a text

Feb 10th, 2024
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 1.91 KB | Gaming | 0 0
  1. #include <a_samp>
  2.  
  3. new playerColors[MAX_PLAYERS][3]; // Pole pre uchovávanie farieb hráčov [hráč][0: titul, 1: nick, 2: text písma]
  4.  
  5. public OnPlayerConnect(playerid) {
  6.     for (new i = 0; i < 3; i++)
  7.         playerColors[playerid][i] = 0xFFFFFF; // Nastavenie predvolených farieb hráča na bielu
  8.     SetPlayerColor(playerid, playerColors[playerid][0], playerColors[playerid][1], playerColors[playerid][2]);
  9.     return 1;
  10. }
  11.  
  12. public OnPlayerCommandText(playerid, cmdtext[]) {
  13.     if (!strcmp(cmdtext, "/setcolor", true)) {
  14.         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ť");
  15.         return 1;
  16.     }
  17.     return 0;
  18. }
  19.  
  20. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) {
  21.     if (dialogid == 1 && response) {
  22.         new colorData[3][6];
  23.         sscanf(inputtext, "s[6],s[6],s[6]", colorData[0], colorData[1], colorData[2]);
  24.         for (new i = 0; i < 3; i++) {
  25.             if (!IsValidColor(colorData[i])) {
  26.                 SendClientMessage(playerid, 0xFFFFFFAA, "Neplatný hexadecimálny kód farby. Skúste znova.");
  27.                 return 1;
  28.             }
  29.             playerColors[playerid][i] = strval(colorData[i]);
  30.         }
  31.         SetPlayerColor(playerid, playerColors[playerid][0], playerColors[playerid][1], playerColors[playerid][2]);
  32.         SendClientMessage(playerid, 0xFFFFFFAA, "Farby boli úspešne zmenené.");
  33.     }
  34.     return 1;
  35. }
  36.  
  37. forward IsValidColor(color[]);
  38. public IsValidColor(color[]) {
  39.     new length = strlen(color);
  40.     if (length != 6)
  41.         return false;
  42.     for (new i = 0; i < length; i++) {
  43.         if (!(color[i] >= '0' && color[i] <= '9') && !(color[i] >= 'A' && color[i] <= 'F') && !(color[i] >= 'a' && color[i] <= 'f'))
  44.             return false;
  45.     }
  46.     return true;
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement