Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #define DETECT_CHAR '#'
- public OnPlayerText(playerid, text[])
- {
- new msg[144];
- new insChars = 0; // inserted chars minus ignored chars
- for (new i = 0; text[i]; i++) {
- if (text[i] != DETECT_CHAR) {
- msg[i + insChars] = text[i];
- } else {
- new sID[4]; // Max ID 999
- for (new j = 0; j < 4; j++) {
- if (!('0' <= text[i + 1 + j] <= '9'))
- break;
- sID[j] = text[i + 1 + j]; // +1 = skip #
- }
- new ID = strval(sID);
- if (IsPlayerConnected(ID)) {
- new name[MAX_PLAYER_NAME + 1];
- GetPlayerName(ID, name, sizeof(name));
- format(msg, sizeof(msg), "%s{%06x}%s{ffffff}", msg, GetPlayerColor(ID) >>> 8, name);
- insChars += strlen(name) + 16 - strlen(sID) - 1; // sID + # = ignored chars
- } else {
- format(msg, sizeof(msg), "%s%c%s", msg, DETECT_CHAR, sID);
- }
- i += strlen(sID);
- }
- }
- new name[MAX_PLAYER_NAME + 1];
- GetPlayerName(playerid, name, sizeof(name));
- format(msg, sizeof(msg), "{%06x}%s: {ffffff}(ID: %d) %s", GetPlayerColor(playerid) >>> 8, name, playerid, msg);
- SendClientMessageToAll(-1, msg);
- return 0;
- }
Add Comment
Please, Sign In to add comment