Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #include <sscanf>
- #define dcmd(%1,%2,%3) if (!strcmp((%3)[1], #%1, true, (%2)) && ((((%3)[(%2) + 1] == '\0') && (dcmd_%1(playerid, ""))) || (((%3)[(%2) + 1] == ' ') && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
- #define COLOR_RED 0xFF0000FF
- #define COLOR_YELLOW 0xFFFF00AA
- #define COLOR_ORANGE 0xFF9900AA
- enum PlayerInfo
- {
- LastPM,
- Ingore,
- }
- new pInfo[MAX_PLAYERS][PlayerInfo];
- public OnFilterScriptInit()
- {
- print("\n--------------------------------------------");
- print(" ");
- print("--------------------------------------------\n");
- return 1;
- }
- public OnFilterScriptExit()
- {
- print("\n--------------------------------------------");
- print(" ");
- print("--------------------------------------------\n");
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- pInfo[playerid][LastPM] = -1;
- pInfo[playerid][NoPM] = 0;
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- pInfo[playerid][LastPM] = -1;
- pInfo[playerid][NoPM] = 0;
- return 1;
- }
- stock PlayerName(playerid)
- {
- new pName[MAX_PLAYER_NAME];
- GetPlayerName(playerid, pName, sizeof(pName));
- return pName;
- }
- dcmd_nopm(playerid, params[])
- {
- #pragma unused params
- if(pInfo[playerid][NoPM] == 0)
- {
- pInfo[playerid][NoPM] = 1;
- SendClientMessage(playerid, COLOR_YELLOW, "{0x0000BBAA}[System]:{8B8B8B} You are no longer accepting private messages.");
- }
- else
- {
- pInfo[playerid][NoPM] = 0;
- SendClientMessage(playerid, COLOR_YELLOW, "{0x0000BBAA}[System]:{8B8B8B}You are now accepting private messages.");
- }
- }
- dcmd_pm(playerid, params[])
- {
- new pID, text[128], string[128];
- if(sscanf(params, "us", pID, text)) return SendClientMessage(playerid, COLOR_RED, "{0x0000BBAA}[Usage]:{8B8B8B}Use /pm [ID] [Message] .");
- if(!IsPlayerConnected(pID)) return SendClientMessage(playerid, COLOR_RED, "{0x0000BBAA}[Error]:{8B8B8B} Invalid ID.");
- if(pID == playerid) return SendClientMessage(playerid, COLOR_RED, "{0x0000BBAA}[Error]:{8B8B8B} You cannot PM yourself.");
- format(string, sizeof(string), "{0x0000BBAA}[System]:{8B8B8B} %s is not accepting any private mesages at the moment (%d)", PlayerName(pID), pID);
- if(pInfo[pID][NoPM] == 1) return SendClientMessage(playerid, COLOR_RED, string);
- format(string, sizeof(string), "{0x0000BBAA}[System]:{8B8B8B}Private message send to %s: %s", PlayerName(pID), text);
- SendClientMessage(playerid, COLOR_YELLOW, string);
- format(string, sizeof(string), "{0x0000BBAA}[System]:{8B8B8B}Private message from %s: %s", PlayerName(playerid), text);
- SendClientMessage(pID, COLOR_YELLOW, string);
- pInfo[pID][LastPM] = playerid;
- return 1;
- }
- dcmd_r(playerid, params[])
- {
- new text[128], string[128];
- if(sscanf(params, "s", text)) return SendClientMessage(playerid, COLOR_RED, "{0x0000BBAA}[Usage]:{8B8B8B} /r[reply] [Message]");
- new pID = pInfo[playerid][LastPM];
- if(!IsPlayerConnected(pID)) return SendClientMessage(playerid, COLOR_RED, "{0x0000BBAA}[Error]:{8B8B8B}Player is not connected.");
- if(pID == playerid) return SendClientMessage(playerid, COLOR_RED, "{0x0000BBAA}[Error]:{8B8B8B}You cannot PM yourself.");
- format(string, sizeof(string), "{0x0000BBAA}[System]:{8B8B8B} %s is not accepting any private mesages at the moment (%d", PlayerName(pID), pID);
- if(pInfo[pID][NoPM] == 1) return SendClientMessage(playerid, COLOR_RED, string);
- format(string, sizeof(string), "{0x0000BBAA}[System]:{8B8B8B}Private message send to %s: %s", PlayerName(pID), text);
- SendClientMessage(playerid, COLOR_YELLOW, string);
- format(string, sizeof(string), "{0x0000BBAA}[System]:{8B8B8B}Private message from %s: %s", PlayerName(playerid), text);
- SendClientMessage(pID, COLOR_YELLOW, string);
- pInfo[pID][LastPM] = playerid;
- return 1;
- }
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- dcmd(pm, 2, cmdtext);
- dcmd(r, 5, cmdtext);
- dcmd(nopm, 4, cmdtext);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement