Advertisement
iCool

iCool's PM System

May 21st, 2014
570
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.95 KB | None | 0 0
  1. //Hey All. Its me iCool. I m again back with a good FS.This is a simple pm system.
  2.  
  3. //Please do not re-release this without my permission or remove the credits.
  4.  
  5. //By iCool
  6.  
  7. // Includes
  8. #include <a_samp>
  9. #include <sscanf>
  10.  
  11. #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
  12.  
  13. // Colours
  14. #define COLOR_RED 0xFF0000FF
  15. #define COLOR_YELLOW 0xFFFF00AA
  16. #define COLOR_ORANGE 0xFF9900AA
  17.  
  18. // Player Variable
  19. enum PlayerInfo
  20. {
  21. Last,
  22. NoPM,
  23. }
  24.  
  25. new pInfo[MAX_PLAYERS][PlayerInfo];
  26.  
  27. public OnFilterScriptInit()
  28. {
  29. print("\n--------------------------------------------");
  30. print(" Simple PM System by iCool");
  31. print("--------------------------------------------\n");
  32. return 1;
  33. }
  34.  
  35. public OnFilterScriptExit()
  36. {
  37. print("\n--------------------------------------------");
  38. print(" Simple PM System by iCool");
  39. print("--------------------------------------------\n");
  40. return 1;
  41. }
  42.  
  43. public OnPlayerConnect(playerid)
  44. {
  45. pInfo[playerid][Last] = -1;
  46. pInfo[playerid][NoPM] = 0;
  47. return 1;
  48. }
  49.  
  50. public OnPlayerDisconnect(playerid, reason)
  51. {
  52. pInfo[playerid][Last] = -1;
  53. pInfo[playerid][NoPM] = 0;
  54. return 1;
  55. }
  56.  
  57. stock PlayerName(playerid)
  58. {
  59. new pName[MAX_PLAYER_NAME];
  60. GetPlayerName(playerid, pName, sizeof(pName));
  61. return pName;
  62. }
  63.  
  64. dcmd_nopm(playerid, params[])
  65. {
  66. #pragma unused params
  67. if(pInfo[playerid][NoPM] == 0)
  68. {
  69. pInfo[playerid][NoPM] = 1;
  70. SendClientMessage(playerid, COLOR_YELLOW, "You are no longer accepting private messages.");
  71. }
  72. else
  73. {
  74. pInfo[playerid][NoPM] = 0;
  75. SendClientMessage(playerid, COLOR_YELLOW, "You are now accepting private messages.");
  76. }
  77. }
  78.  
  79. dcmd_pm(playerid, params[])
  80. {
  81. new pID, text[128], string[128];
  82. if(sscanf(params, "us", pID, text)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /pm [ID] [message] - Enter a valid ID");
  83. if(!IsPlayerConnected(pID)) return SendClientMessage(playerid, COLOR_RED, "Player is not connected.");
  84. if(pID == playerid) return SendClientMessage(playerid, COLOR_RED, "You cannot PM yourself.");
  85. format(string, sizeof(string), "%s (%d) is not accepting private messages at the moment.", PlayerName(pID), pID);
  86. if(pInfo[pID][NoPM] == 1) return SendClientMessage(playerid, COLOR_RED, string);
  87. format(string, sizeof(string), "PM to %s: %s", PlayerName(pID), text);
  88. SendClientMessage(playerid, COLOR_YELLOW, string);
  89. format(string, sizeof(string), "PM from %s: %s", PlayerName(playerid), text);
  90. SendClientMessage(pID, COLOR_YELLOW, string);
  91. pInfo[pID][Last] = playerid;
  92. return 1;
  93. }
  94.  
  95. dcmd_reply(playerid, params[])
  96. {
  97. new text[128], string[128];
  98. if(sscanf(params, "s", text)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /reply [message] - Enter your message");
  99. new pID = pInfo[playerid][Last];
  100. if(!IsPlayerConnected(pID)) return SendClientMessage(playerid, COLOR_RED, "Player is not connected.");
  101. if(pID == playerid) return SendClientMessage(playerid, COLOR_RED, "You cannot PM yourself.");
  102. format(string, sizeof(string), "%s (%d) is not accepting private messages at the moment.", PlayerName(pID), pID);
  103. if(pInfo[pID][NoPM] == 1) return SendClientMessage(playerid, COLOR_RED, string);
  104. format(string, sizeof(string), "PM to %s: %s", PlayerName(pID), text);
  105. SendClientMessage(playerid, COLOR_YELLOW, string);
  106. format(string, sizeof(string), "PM from %s: %s", PlayerName(playerid), text);
  107. SendClientMessage(pID, COLOR_YELLOW, string);
  108. pInfo[pID][Last] = playerid;
  109. return 1;
  110. }
  111.  
  112. dcmd_ms(playerid, params[]) return dcmd_pm(playerid, params);
  113. dcmd_m(playerid, params[]) return dcmd_pm(playerid, params);
  114. dcmd_r(playerid, params[]) return dcmd_reply(playerid, params);
  115.  
  116. public OnPlayerCommandText(playerid, cmdtext[])
  117. {
  118. dcmd(pm, 2, cmdtext);
  119. dcmd(ms, 2, cmdtext);
  120. dcmd(m, 1, cmdtext);
  121. dcmd(r, 1, cmdtext);
  122. dcmd(reply, 5, cmdtext);
  123. dcmd(nopm, 4, cmdtext);
  124. return 0;
  125. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement