Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- ========================================================================================
- ////////////////////////////////////////////////////////////////////////////////////////
- // ¸,ø¤º°`°º¤ø,¸¸,ø¤º° pм ѕyѕтeм вy тнeғlyer °º¤ø,¸¸,ø¤º°`°º¤ø,¸ //
- ////////////////////////////////////////////////////////////////////////////////////////
- ========================================================================================
- - Private Message System by TheFlyer -
- - v0.1 -
- - Scripted by: TheFlyer -
- ////////////////////////////////////////////////////////////////////////////////////////
- SERVER CMDS:
- - /pm
- - /(r)eply
- - /disablepms
- - /enablepms
- ////////////////////////////////////////////////////////////////////////////////////////
- ========================================================================================
- */
- // Script Includes //
- #include <a_samp> // Credits to SA-MP Team
- #include <zcmd> // Credits to Zeex
- #include <sscanf2> // Credits to Y_Less
- /////////////////////
- // Script Defines //
- #define COLOR_DARK_GREEN 0x33AA33FF // Defines the Dark-Green color
- #define COLOR_RED 0xFF0000FF // Defines the Red color
- #define COLOR_YELLOW 0xFFFF00FF // Defines the Yellow color
- #define COLOR_GREEN 0x00FF00FF // Defines the Green color
- #define COLOR_BLUE 0x0000FFFF // Defines the Blue color
- #define COLOR_GREY 0xCCCCCCFF // Defines the Grey color
- ////////////////////
- // Script enum //
- enum PlayerInfo
- {
- readpm,
- Last,
- PM,
- NoPM
- }
- new pInfo[MAX_PLAYERS][PlayerInfo];
- //////////////////
- // Script stock //
- stock PlayerName(playerid)
- {
- new pName[MAX_PLAYER_NAME];
- GetPlayerName(playerid, pName, sizeof(pName));
- return pName;
- }
- //////////////////
- // Script Loading/Unloading //
- public OnFilterScriptInit()
- {
- print("\n--------------------------------------");
- print(" PM System Loaded ");
- print(" By TheFlyer ");
- print("--------------------------------------\n");
- return 1;
- }
- public OnFilterScriptExit()
- {
- print("\n--------------------------------------");
- print(" PM System Unloaded ");
- print(" By TheFlyer ");
- print("--------------------------------------\n");
- return 1;
- }
- ///////////////////////////////////////
- public OnPlayerConnect(playerid)
- {
- // Allows NPC to join with no problem
- if(IsPlayerNPC(playerid))
- {
- return 1;
- }
- // Sets the Last PM Received to prevent sending wrong PMS
- pInfo[playerid][Last] = -1;
- pInfo[playerid][NoPM] = 0;
- pInfo[playerid][readpm] = -1;
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- // Allows NPC to disconnect with no problem
- if(IsPlayerNPC(playerid))
- {
- return 1;
- }
- // Doubles checks the Last PM Received to prevent the next player logging receive that PM
- pInfo[playerid][Last] = -1;
- pInfo[playerid][NoPM] = 0;
- pInfo[playerid][readpm] = -1;
- return 1;
- }
- // PLAYER'S COMMANDS //
- CMD:pm(playerid, params[])
- {
- new pID, text[256], string[256];
- if(sscanf(params, "us[256]", pID, text)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /pm (nick/id) (message) - Enter a valid Nick / ID");
- if(!IsPlayerConnected(pID)) return SendClientMessage(playerid, COLOR_RED, "Player is not connected.");
- if(pID == playerid) return SendClientMessage(playerid, COLOR_RED, "You cannot PM yourself.");
- format(string, sizeof(string), "%s (%d) is not accepting private messages at the moment.", PlayerName(pID), pID);
- if(pInfo[pID][NoPM] == 1) return SendClientMessage(playerid, COLOR_RED, string);
- format(string, sizeof(string), "PM to %s: %s", PlayerName(pID), text);
- SendClientMessage(playerid, COLOR_YELLOW, string);
- format(string, sizeof(string), "PM from %s: %s", PlayerName(playerid), text);
- SendClientMessage(pID, COLOR_YELLOW, string);
- pInfo[pID][Last] = playerid;
- for (new i = 0; i < MAX_PLAYERS; i++)
- if (IsPlayerAdmin(i))
- {
- format(string, sizeof(string), "PM: %s(%d) to %s(%d): %s", PlayerName(playerid), playerid, PlayerName(pID), pID, text);
- {
- if (IsPlayerAdmin(i))
- SendClientMessage(i, COLOR_GREY, string);
- }
- }
- return 1;
- }
- CMD:reply(playerid, params[])
- {
- new text[256], string[256];
- if(sscanf(params, "s[256]", text)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /reply (message) - Enter your message");
- new pID = pInfo[playerid][Last];
- if(!IsPlayerConnected(pID)) return SendClientMessage(playerid, COLOR_RED, "Player is not connected.");
- if(pID == playerid) return SendClientMessage(playerid, COLOR_RED, "You cannot PM yourself.");
- format(string, sizeof(string), "%s (%d) is not accepting private messages at the moment.", PlayerName(pID), pID);
- if(pInfo[pID][NoPM] == 1) return SendClientMessage(playerid, COLOR_RED, string);
- format(string, sizeof(string), "PM to %s: %s", PlayerName(pID), text);
- SendClientMessage(playerid, COLOR_YELLOW, string);
- format(string, sizeof(string), "PM from %s: %s", PlayerName(playerid), text);
- SendClientMessage(pID, COLOR_YELLOW, string);
- pInfo[pID][Last] = playerid;
- for (new i = 0; i < MAX_PLAYERS; i++)
- if (IsPlayerAdmin(i))
- {
- format(string, sizeof(string), "PM: %s(%d) to %s(%d): %s", PlayerName(playerid), playerid, PlayerName(pID), pID, text);
- {
- if (IsPlayerAdmin(i))
- SendClientMessage(i, COLOR_GREY, string);
- }
- }
- return 1;
- }
- CMD:r(playerid, params[]) return cmd_reply(playerid, params);
- CMD:enablepms(playerid, params[])
- {
- PlayerPlaySound(playerid, 1085, 0.0, 0.0, 0.0);
- if(pInfo[playerid][NoPM] == 1)
- {
- SendClientMessage(playerid, COLOR_DARK_GREEN, "You Enabled your Private Message!");
- pInfo[playerid][NoPM] = 0;
- }
- else if(pInfo[playerid][NoPM] == 0)
- {
- SendClientMessage(playerid, COLOR_RED, "You've already Enabled your Private Message!");
- }
- return 1;
- }
- CMD:disablepms(playerid, params[])
- {
- PlayerPlaySound(playerid, 1085, 0.0, 0.0, 0.0);
- if(pInfo[playerid][NoPM] == 0)
- {
- SendClientMessage(playerid, COLOR_DARK_GREEN, "You Disabled your Private Message!");
- pInfo[playerid][NoPM] = 1;
- }
- else if(pInfo[playerid][NoPM] == 1)
- {
- SendClientMessage(playerid, COLOR_RED, "You've already Disabled your Private Message!");
- }
- return 1;
- }
- CMD:readpms(playerid, params[])
- {
- if (IsPlayerAdmin(playerid))
- {
- pInfo[playerid][readpm] = 1;
- SendClientMessage(playerid, COLOR_DARK_GREEN, "Congratz your a PM Admin xD");
- }
- else
- {
- SendClientMessage(playerid, COLOR_RED, "Your not RCON Admin, plz /rcon login YOUR_PASSWORD");
- return 0;
- }
- return 1;
- }
- ///////////////////////
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement