Advertisement
Guest User

Untitled

a guest
Jan 27th, 2014
450
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.84 KB | None | 0 0
  1.  
  2. #include <a_samp>
  3. #include <sscanf>
  4.  
  5. #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
  6.  
  7.  
  8. #define COLOR_RED 0xFF0000FF
  9. #define COLOR_YELLOW 0xFFFF00AA
  10. #define COLOR_ORANGE 0xFF9900AA
  11.  
  12.  
  13. enum PlayerInfo
  14. {
  15. LastPM,
  16. Ingore,
  17. }
  18.  
  19. new pInfo[MAX_PLAYERS][PlayerInfo];
  20.  
  21. public OnFilterScriptInit()
  22. {
  23. print("\n--------------------------------------------");
  24. print(" ");
  25. print("--------------------------------------------\n");
  26. return 1;
  27. }
  28.  
  29. public OnFilterScriptExit()
  30. {
  31. print("\n--------------------------------------------");
  32. print(" ");
  33. print("--------------------------------------------\n");
  34. return 1;
  35. }
  36.  
  37. public OnPlayerConnect(playerid)
  38. {
  39. pInfo[playerid][LastPM] = -1;
  40. pInfo[playerid][NoPM] = 0;
  41. return 1;
  42. }
  43.  
  44. public OnPlayerDisconnect(playerid, reason)
  45. {
  46. pInfo[playerid][LastPM] = -1;
  47. pInfo[playerid][NoPM] = 0;
  48. return 1;
  49. }
  50.  
  51. stock PlayerName(playerid)
  52. {
  53. new pName[MAX_PLAYER_NAME];
  54. GetPlayerName(playerid, pName, sizeof(pName));
  55. return pName;
  56. }
  57.  
  58. dcmd_nopm(playerid, params[])
  59. {
  60. #pragma unused params
  61. if(pInfo[playerid][NoPM] == 0)
  62. {
  63. pInfo[playerid][NoPM] = 1;
  64. SendClientMessage(playerid, COLOR_YELLOW, "{0x0000BBAA}[System]:{8B8B8B} You are no longer accepting private messages.");
  65. }
  66. else
  67. {
  68. pInfo[playerid][NoPM] = 0;
  69. SendClientMessage(playerid, COLOR_YELLOW, "{0x0000BBAA}[System]:{8B8B8B}You are now accepting private messages.");
  70. }
  71. }
  72.  
  73. dcmd_pm(playerid, params[])
  74. {
  75. new pID, text[128], string[128];
  76. if(sscanf(params, "us", pID, text)) return SendClientMessage(playerid, COLOR_RED, "{0x0000BBAA}[Usage]:{8B8B8B}Use /pm [ID] [Message] .");
  77. if(!IsPlayerConnected(pID)) return SendClientMessage(playerid, COLOR_RED, "{0x0000BBAA}[Error]:{8B8B8B} Invalid ID.");
  78. if(pID == playerid) return SendClientMessage(playerid, COLOR_RED, "{0x0000BBAA}[Error]:{8B8B8B} You cannot PM yourself.");
  79. format(string, sizeof(string), "{0x0000BBAA}[System]:{8B8B8B} %s is not accepting any private mesages at the moment (%d)", PlayerName(pID), pID);
  80. if(pInfo[pID][NoPM] == 1) return SendClientMessage(playerid, COLOR_RED, string);
  81. format(string, sizeof(string), "{0x0000BBAA}[System]:{8B8B8B}Private message send to %s: %s", PlayerName(pID), text);
  82. SendClientMessage(playerid, COLOR_YELLOW, string);
  83. format(string, sizeof(string), "{0x0000BBAA}[System]:{8B8B8B}Private message from %s: %s", PlayerName(playerid), text);
  84. SendClientMessage(pID, COLOR_YELLOW, string);
  85. pInfo[pID][LastPM] = playerid;
  86. return 1;
  87. }
  88.  
  89. dcmd_r(playerid, params[])
  90. {
  91. new text[128], string[128];
  92. if(sscanf(params, "s", text)) return SendClientMessage(playerid, COLOR_RED, "{0x0000BBAA}[Usage]:{8B8B8B} /r[reply] [Message]");
  93. new pID = pInfo[playerid][LastPM];
  94. if(!IsPlayerConnected(pID)) return SendClientMessage(playerid, COLOR_RED, "{0x0000BBAA}[Error]:{8B8B8B}Player is not connected.");
  95. if(pID == playerid) return SendClientMessage(playerid, COLOR_RED, "{0x0000BBAA}[Error]:{8B8B8B}You cannot PM yourself.");
  96. format(string, sizeof(string), "{0x0000BBAA}[System]:{8B8B8B} %s is not accepting any private mesages at the moment (%d", PlayerName(pID), pID);
  97. if(pInfo[pID][NoPM] == 1) return SendClientMessage(playerid, COLOR_RED, string);
  98. format(string, sizeof(string), "{0x0000BBAA}[System]:{8B8B8B}Private message send to %s: %s", PlayerName(pID), text);
  99. SendClientMessage(playerid, COLOR_YELLOW, string);
  100. format(string, sizeof(string), "{0x0000BBAA}[System]:{8B8B8B}Private message from %s: %s", PlayerName(playerid), text);
  101. SendClientMessage(pID, COLOR_YELLOW, string);
  102. pInfo[pID][LastPM] = playerid;
  103. return 1;
  104. }
  105.  
  106.  
  107.  
  108. public OnPlayerCommandText(playerid, cmdtext[])
  109. {
  110. dcmd(pm, 2, cmdtext);
  111. dcmd(r, 5, cmdtext);
  112. dcmd(nopm, 4, cmdtext);
  113. return 0;
  114. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement