Advertisement
TheFlyer

PM System

Feb 1st, 2014
1,069
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 6.57 KB | None | 0 0
  1. /*
  2.  
  3.  
  4. ========================================================================================
  5.  
  6. ////////////////////////////////////////////////////////////////////////////////////////
  7. //            ¸,ø¤º°`°º¤ø,¸¸,ø¤º° pм ѕyѕтeм вy тнeғlyer °º¤ø,¸¸,ø¤º°`°º¤ø,¸           //
  8. ////////////////////////////////////////////////////////////////////////////////////////
  9.  
  10. ========================================================================================
  11.  
  12.                       - Private Message System by TheFlyer -
  13.                                      - v0.1 -
  14.                              - Scripted by: TheFlyer -
  15.  
  16. ////////////////////////////////////////////////////////////////////////////////////////
  17. SERVER CMDS:
  18. - /pm
  19. - /(r)eply
  20. - /disablepms
  21. - /enablepms
  22. ////////////////////////////////////////////////////////////////////////////////////////
  23. ========================================================================================
  24.  
  25.  
  26. */
  27. // Script Includes //
  28. #include <a_samp> // Credits to SA-MP Team
  29. #include <zcmd> // Credits to Zeex
  30. #include <sscanf2> // Credits to Y_Less
  31. /////////////////////
  32.  
  33. // Script Defines //
  34. #define COLOR_DARK_GREEN 0x33AA33FF // Defines the Dark-Green color
  35. #define COLOR_RED 0xFF0000FF // Defines the Red color
  36. #define COLOR_YELLOW 0xFFFF00FF // Defines the Yellow color
  37. #define COLOR_GREEN 0x00FF00FF // Defines the Green color
  38. #define COLOR_BLUE 0x0000FFFF // Defines the Blue color
  39. #define COLOR_GREY 0xCCCCCCFF // Defines the Grey color
  40. ////////////////////
  41.  
  42. // Script enum //
  43. enum PlayerInfo
  44. {
  45.     readpm,
  46.     Last,
  47.     PM,
  48.     NoPM
  49. }
  50. new pInfo[MAX_PLAYERS][PlayerInfo];
  51. //////////////////
  52.  
  53. // Script stock //
  54. stock PlayerName(playerid)
  55. {
  56.     new pName[MAX_PLAYER_NAME];
  57.     GetPlayerName(playerid, pName, sizeof(pName));
  58.     return pName;
  59. }
  60. //////////////////
  61.  
  62. // Script Loading/Unloading //
  63. public OnFilterScriptInit()
  64. {
  65.     print("\n--------------------------------------");
  66.     print(" PM System Loaded ");
  67.     print("    By TheFlyer   ");
  68.     print("--------------------------------------\n");
  69.     return 1;
  70. }
  71.  
  72. public OnFilterScriptExit()
  73. {
  74.     print("\n--------------------------------------");
  75.     print(" PM System Unloaded ");
  76.     print("     By TheFlyer    ");
  77.     print("--------------------------------------\n");
  78.     return 1;
  79. }
  80. ///////////////////////////////////////
  81.  
  82. public OnPlayerConnect(playerid)
  83. {
  84.     // Allows NPC to join with no problem
  85.     if(IsPlayerNPC(playerid))
  86.     {
  87.         return 1;
  88.     }
  89.     // Sets the Last PM Received to prevent sending wrong PMS
  90.     pInfo[playerid][Last] = -1;
  91.     pInfo[playerid][NoPM] = 0;
  92.     pInfo[playerid][readpm] = -1;
  93.     return 1;
  94. }
  95.  
  96. public OnPlayerDisconnect(playerid, reason)
  97. {
  98.     // Allows NPC to disconnect with no problem
  99.     if(IsPlayerNPC(playerid))
  100.     {
  101.         return 1;
  102.     }
  103.     // Doubles checks the Last PM Received to prevent the next player logging receive that PM
  104.     pInfo[playerid][Last] = -1;
  105.     pInfo[playerid][NoPM] = 0;
  106.     pInfo[playerid][readpm] = -1;
  107.     return 1;
  108. }
  109.  
  110. // PLAYER'S COMMANDS //
  111. CMD:pm(playerid, params[])
  112. {
  113.     new pID, text[256], string[256];
  114.     if(sscanf(params, "us[256]", pID, text)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /pm (nick/id) (message) - Enter a valid Nick / ID");
  115.     if(!IsPlayerConnected(pID)) return SendClientMessage(playerid, COLOR_RED, "Player is not connected.");
  116.     if(pID == playerid) return SendClientMessage(playerid, COLOR_RED, "You cannot PM yourself.");
  117.     format(string, sizeof(string), "%s (%d) is not accepting private messages at the moment.", PlayerName(pID), pID);
  118.     if(pInfo[pID][NoPM] == 1) return SendClientMessage(playerid, COLOR_RED, string);
  119.     format(string, sizeof(string), "PM to %s: %s", PlayerName(pID), text);
  120.     SendClientMessage(playerid, COLOR_YELLOW, string);
  121.     format(string, sizeof(string), "PM from %s: %s", PlayerName(playerid), text);
  122.     SendClientMessage(pID, COLOR_YELLOW, string);
  123.     pInfo[pID][Last] = playerid;
  124.     for (new i = 0; i < MAX_PLAYERS; i++)
  125.     if (IsPlayerAdmin(i))
  126.     {
  127.         format(string, sizeof(string), "PM: %s(%d) to %s(%d): %s", PlayerName(playerid), playerid, PlayerName(pID), pID, text);
  128.         {
  129.             if (IsPlayerAdmin(i))
  130.             SendClientMessage(i, COLOR_GREY, string);
  131.         }
  132.     }
  133.     return 1;
  134. }
  135.  
  136. CMD:reply(playerid, params[])
  137. {
  138.     new text[256], string[256];
  139.     if(sscanf(params, "s[256]", text)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /reply (message) - Enter your message");
  140.     new pID = pInfo[playerid][Last];
  141.     if(!IsPlayerConnected(pID)) return SendClientMessage(playerid, COLOR_RED, "Player is not connected.");
  142.     if(pID == playerid) return SendClientMessage(playerid, COLOR_RED, "You cannot PM yourself.");
  143.     format(string, sizeof(string), "%s (%d) is not accepting private messages at the moment.", PlayerName(pID), pID);
  144.     if(pInfo[pID][NoPM] == 1) return SendClientMessage(playerid, COLOR_RED, string);
  145.     format(string, sizeof(string), "PM to %s: %s", PlayerName(pID), text);
  146.     SendClientMessage(playerid, COLOR_YELLOW, string);
  147.     format(string, sizeof(string), "PM from %s: %s", PlayerName(playerid), text);
  148.     SendClientMessage(pID, COLOR_YELLOW, string);
  149.     pInfo[pID][Last] = playerid;
  150.     for (new i = 0; i < MAX_PLAYERS; i++)
  151.     if (IsPlayerAdmin(i))
  152.     {
  153.         format(string, sizeof(string), "PM: %s(%d) to %s(%d): %s", PlayerName(playerid), playerid, PlayerName(pID), pID, text);
  154.         {
  155.             if (IsPlayerAdmin(i))
  156.             SendClientMessage(i, COLOR_GREY, string);
  157.         }
  158.     }
  159.     return 1;
  160. }
  161. CMD:r(playerid, params[]) return cmd_reply(playerid, params);
  162.  
  163. CMD:enablepms(playerid, params[])
  164. {
  165.     PlayerPlaySound(playerid, 1085, 0.0, 0.0, 0.0);
  166.     if(pInfo[playerid][NoPM] == 1)
  167.     {
  168.         SendClientMessage(playerid, COLOR_DARK_GREEN, "You Enabled your Private Message!");
  169.         pInfo[playerid][NoPM] = 0;
  170.     }
  171.     else if(pInfo[playerid][NoPM] == 0)
  172.     {
  173.         SendClientMessage(playerid, COLOR_RED, "You've already Enabled your Private Message!");
  174.     }
  175.     return 1;
  176. }
  177. CMD:disablepms(playerid, params[])
  178. {
  179.     PlayerPlaySound(playerid, 1085, 0.0, 0.0, 0.0);
  180.     if(pInfo[playerid][NoPM] == 0)
  181.     {
  182.         SendClientMessage(playerid, COLOR_DARK_GREEN, "You Disabled your Private Message!");
  183.         pInfo[playerid][NoPM] = 1;
  184.     }
  185.     else if(pInfo[playerid][NoPM] == 1)
  186.     {
  187.         SendClientMessage(playerid, COLOR_RED, "You've already Disabled your Private Message!");
  188.     }
  189.     return 1;
  190. }
  191. CMD:readpms(playerid, params[])
  192. {
  193.     if (IsPlayerAdmin(playerid))
  194.     {
  195.         pInfo[playerid][readpm] = 1;
  196.         SendClientMessage(playerid, COLOR_DARK_GREEN, "Congratz your a PM Admin xD");
  197.     }
  198.     else
  199.     {
  200.         SendClientMessage(playerid, COLOR_RED, "Your not RCON Admin, plz /rcon login YOUR_PASSWORD");
  201.         return 0;
  202.     }
  203.     return 1;
  204. }
  205. ///////////////////////
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement