__DuFF

Označenie nicku v chate pomocou @ / # || NETESTOVANÉ

Aug 24th, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 1.10 KB | None | 0 0
  1. #include <a_samp>
  2. #define DETECT_CHAR '#'
  3.  
  4. public OnPlayerText(playerid, text[])
  5. {
  6.     new msg[144];
  7.     new insChars = 0; // inserted chars minus ignored chars
  8.     for (new i = 0; text[i]; i++) {
  9.         if (text[i] != DETECT_CHAR) {
  10.             msg[i + insChars] = text[i];
  11.         } else {
  12.             new sID[4]; // Max ID 999
  13.             for (new j = 0; j < 4; j++) {
  14.                 if (!('0' <= text[i + 1 + j] <= '9'))
  15.                     break;
  16.  
  17.                 sID[j] = text[i + 1 + j]; // +1 = skip #
  18.             }
  19.             new ID = strval(sID);
  20.             if (IsPlayerConnected(ID)) {
  21.                 new name[MAX_PLAYER_NAME + 1];
  22.                 GetPlayerName(ID, name, sizeof(name));
  23.                 format(msg, sizeof(msg), "%s{%06x}%s{ffffff}", msg, GetPlayerColor(ID) >>> 8, name);
  24.                 insChars += strlen(name) + 16 - strlen(sID) - 1; // sID + # = ignored chars
  25.             } else {
  26.                 format(msg, sizeof(msg), "%s%c%s", msg, DETECT_CHAR, sID);
  27.             }
  28.             i += strlen(sID);
  29.         }
  30.     }
  31.     new name[MAX_PLAYER_NAME + 1];
  32.     GetPlayerName(playerid, name, sizeof(name));
  33.     format(msg, sizeof(msg), "{%06x}%s: {ffffff}(ID: %d) %s", GetPlayerColor(playerid) >>> 8, name, playerid, msg);
  34.     SendClientMessageToAll(-1, msg);
  35.     return 0;
  36. }
Add Comment
Please, Sign In to add comment