Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define FILTERSCRIPT
- // ==============================================
- // INCLUDES
- // ==============================================
- #include <a_samp>
- #include <zcmd>
- #include <sscanf2>
- #include <YSI\y_ini>
- // ----------------------------------------------
- // ==============================================
- // COLOR DEFINES
- // ==============================================
- #define COLOR_RED 0xFF0000FF
- #define COLOR_YELLOW 0xFFFF00AA
- #define COLOR_LIGHTBLUE 0x33CCFFAA
- #define COLOR_TOMATO 0xFF6347AA
- #define COLOR_LAWNGREEN 0x7CFC00AA
- #define COLOR_LIMEGREEN 0x32CD32AA
- // ----------------------------------------------
- // ==============================================
- // SYSTEM CONFIG
- // ==============================================
- #define PATH "/AMS/%s.ini" // Path to save the data.
- #define MAX_WARNINGS 3 // Maximum warning while speaking when muted.
- #define RANDOM_MSG_TIME 2 // Random messages interval (In Minutes).
- // ----------------------------------------------
- // ==============================================
- // PLAYER INFO
- // ==============================================
- enum pInfo
- {
- Muted,
- MutedReason[128],
- MuteWarnings,
- SpamMute,
- TotalMute
- }
- new PlayerInfo[MAX_PLAYERS][pInfo];
- // -----------------------------------------------
- // ===============================================
- // RANDOM MESSAGES
- // ===============================================
- new RandomMessages[][] =
- {
- "*Use /minfo [playerid] to view players total mutes.",
- "*Use /requestunmute to send unmute request to online admins.",
- "*Use /mlist to view online muted players."
- };
- forward SendRandomMessages();
- public SendRandomMessages()
- {
- SendClientMessageToAll(COLOR_YELLOW, RandomMessages[random(sizeof(RandomMessages))]);
- return 1;
- }
- // -----------------------------------------------
- // ===============================================
- // CUSTOM FUNCTIONS
- // ===============================================
- stock UserPath(playerid)
- {
- new string[128],playername[MAX_PLAYER_NAME];
- GetPlayerName(playerid,playername,sizeof(playername));
- format(string,sizeof(string),PATH,playername);
- return string;
- }
- forward LoadUser_data(playerid,name[],value[]);
- public LoadUser_data(playerid,name[],value[])
- {
- INI_Int("Muted",PlayerInfo[playerid][Muted]);
- INI_String("MutedReason",PlayerInfo[playerid][MutedReason], 128);
- INI_Int("MuteWarnings",PlayerInfo[playerid][MuteWarnings]);
- INI_Int("SpamMute",PlayerInfo[playerid][SpamMute]);
- INI_Int("TotalMute",PlayerInfo[playerid][TotalMute]);
- return 1;
- }
- forward KickDelay(playerid);
- public KickDelay(playerid)
- {
- Kick(playerid);
- }
- stock IsPlayerMuted(playerid) {
- if (PlayerInfo[playerid][Muted] == 1 || PlayerInfo[playerid][SpamMute] == 1)
- return true;
- return false;
- }
- stock IsAnyMutedPlayerOnline() {
- new count;
- for (new i=0; i < MAX_PLAYERS; i++) {
- if (IsPlayerConnected(i) && IsPlayerMuted(i)) {
- count++;
- }
- }
- if (count == 0) {
- return false;
- } else {
- return true;
- }
- }
- // ------------------------------------------------
- public OnFilterScriptInit()
- {
- print("\n--------------------------------------");
- print(" Advanced Mute System by DarkSkull");
- print("--------------------------------------\n");
- SetTimer("SendRandomMessages",RANDOM_MSG_TIME*60000,1);
- return 1;
- }
- public OnFilterScriptExit()
- {
- return 1;
- }
- public OnPlayerText(playerid, text[])
- {
- if (PlayerInfo[playerid][Muted] == 1){
- PlayerInfo[playerid][MuteWarnings]++;
- new msg1[128];
- format(msg1, sizeof(msg1), "*You're Muted, You can't talk. (Warnings: %d/%d)", PlayerInfo[playerid][MuteWarnings], MAX_WARNINGS);
- SendClientMessage(playerid, COLOR_YELLOW, msg1);
- if (PlayerInfo[playerid][MuteWarnings] >= MAX_WARNINGS) {
- new msg2[128], name[MAX_PLAYER_NAME];
- SendClientMessage(playerid, COLOR_RED, "*You've been kicked due to Mute spamming!");
- PlayerInfo[playerid][Muted] = 0;
- PlayerInfo[playerid][MuteWarnings] = 0;
- format(PlayerInfo[playerid][MutedReason], 128, "None");
- SetTimerEx("KickDelay", 1000, false, "d", playerid);
- GetPlayerName(playerid,name, sizeof(name));
- format(msg2, sizeof(msg2), "[KICK]: %s has been kicked [Reason: Mute Spamming].", name);
- SendClientMessageToAll(COLOR_YELLOW, msg2);
- }
- return 0;
- }
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- if(fexist(UserPath(playerid)))
- {
- INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
- }
- else
- {
- new INI:File = INI_Open(UserPath(playerid));
- INI_SetTag(File,"data");
- INI_WriteInt(File,"Muted",0);
- INI_WriteString(File,"MutedReason", "None");
- INI_WriteInt(File,"MuteWarnings",0);
- INI_WriteInt(File,"SpamMute", 0);
- INI_WriteInt(File,"TotalMute",0);
- INI_Close(File);
- }
- if (IsPlayerMuted(playerid)) {
- new string[128];
- SendClientMessage(playerid, COLOR_TOMATO, "*You have been muted since you last left the game.");
- format(string, sizeof(string), "[Reason: %s | Warnings: %d/%d]", PlayerInfo[playerid][MutedReason], PlayerInfo[playerid][MuteWarnings], MAX_WARNINGS);
- SendClientMessage(playerid, COLOR_TOMATO, string);
- }
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- new INI:File = INI_Open(UserPath(playerid));
- INI_SetTag(File,"data");
- INI_WriteInt(File,"Muted",PlayerInfo[playerid][Muted]);
- INI_WriteString(File,"MutedReason",PlayerInfo[playerid][MutedReason]);
- INI_WriteInt(File,"MuteWarnings",PlayerInfo[playerid][MuteWarnings]);
- INI_WriteInt(File,"SpamMute",PlayerInfo[playerid][SpamMute]);
- INI_WriteInt(File,"TotalMute",PlayerInfo[playerid][TotalMute]);
- INI_Close(File);
- return 1;
- }
- // ==============================================
- // COMMANDS
- // ==============================================
- CMD:mute(playerid, params[]) {
- if (IsPlayerAdmin(playerid)) {
- new targetid, aname[MAX_PLAYER_NAME], tname[MAX_PLAYER_NAME], msg1[128], reason[128];
- if(sscanf(params, "us[64]", targetid, reason)) return SendClientMessage(playerid, COLOR_LIGHTBLUE,"[USAGE]: /mute [playerid] [reason]" );
- if(targetid == INVALID_PLAYER_ID) return SendClientMessage( playerid, COLOR_RED,"[ERROR]: Player Is Not Connected!" );
- if (IsPlayerMuted(playerid)) return SendClientMessage(playerid, COLOR_RED, "[ERROR]: That player is already muted.");
- GetPlayerName(playerid, aname, sizeof(aname));
- GetPlayerName(targetid, tname, sizeof(tname));
- PlayerInfo[targetid][MutedReason] = reason;
- PlayerInfo[targetid][Muted] = 1;
- PlayerInfo[targetid][MuteWarnings] = 0;
- PlayerInfo[targetid][SpamMute] = 0;
- PlayerInfo[targetid][TotalMute]++;
- new string[128];
- format(string, sizeof(string), "Reason: %s", PlayerInfo[targetid][MutedReason]);
- format(msg1, sizeof(msg1), "*Administrator %s has muted %s. [Reason: %s]", aname, tname, PlayerInfo[targetid][MutedReason]);
- SendClientMessageToAll(COLOR_LIGHTBLUE, msg1);
- PlayerPlaySound(playerid,1057,0.0,0.0,0.0);
- PlayerPlaySound(targetid,1057,0.0,0.0,0.0);
- } else {
- SendClientMessage(playerid, COLOR_RED, "*Only admins can use that command.");
- }
- return 1;
- }
- CMD:unmute(playerid, params[]) {
- if (IsPlayerAdmin(playerid)) {
- new targetid, aname[MAX_PLAYER_NAME], tname[MAX_PLAYER_NAME], msg1[128];
- if(sscanf(params, "u", targetid)) return SendClientMessage(playerid, COLOR_LIGHTBLUE,"[USAGE]: /unmute [playerid]" );
- if(targetid == INVALID_PLAYER_ID) return SendClientMessage( playerid, COLOR_RED,"[ERROR]: Player Is Not Connected!" );
- if (!IsPlayerMuted(playerid)) return SendClientMessage(playerid, COLOR_RED, "[ERROR]: That player is not muted.");
- GetPlayerName(playerid, aname, sizeof(aname));
- GetPlayerName(targetid, tname, sizeof(tname));
- format(msg1, sizeof(msg1), "*Administrator %s has unmuted %s.", aname, tname);
- SendClientMessageToAll(COLOR_LIGHTBLUE, msg1);
- PlayerInfo[targetid][Muted] = 0;
- format(PlayerInfo[targetid][MutedReason], 128, "None");
- PlayerInfo[targetid][MuteWarnings] = 0;
- PlayerInfo[targetid][SpamMute] = 0;
- PlayerPlaySound(playerid,1057,0.0,0.0,0.0);
- PlayerPlaySound(targetid,1057,0.0,0.0,0.0);
- } else {
- SendClientMessage(playerid, COLOR_RED, "*Only admins can use that command!");
- }
- return 1;
- }
- CMD:mlist(playerid) {
- SendClientMessage(playerid, COLOR_LAWNGREEN, "_______| Online Muted Players |______");
- if (IsAnyMutedPlayerOnline()) {
- for (new i=0; i < MAX_PLAYERS; i++) {
- if (IsPlayerConnected(i) && IsPlayerMuted(i)) {
- new string[128], name[MAX_PLAYER_NAME];
- GetPlayerName(i, name, sizeof(name));
- format(string, sizeof(string), "%s[ID: %d]: Reason: %s | Warnings: %d/%d", name, i, PlayerInfo[i][MutedReason], PlayerInfo[i][MuteWarnings], MAX_WARNINGS);
- SendClientMessage(playerid, COLOR_LIMEGREEN, string);
- }
- }
- } else {
- SendClientMessage(playerid, COLOR_RED, "No muted players online.");
- }
- SendClientMessage(playerid, COLOR_LAWNGREEN, "____________________________________");
- return 1;
- }
- CMD:requestunmute(playerid) {
- if (IsPlayerMuted(playerid)) {
- if (IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_RED, "* You can unmute yourself, Idiot!");
- new string[128], name[MAX_PLAYER_NAME];
- GetPlayerName(playerid, name, sizeof(name));
- format(string, sizeof(string), "*%s is requesting to unmute him. Reason: %s | Warning: %d/%d", name, PlayerInfo[playerid][MutedReason], PlayerInfo[playerid][MuteWarnings], MAX_WARNINGS);
- for (new i=0; i < MAX_PLAYERS; i++) {
- if (IsPlayerConnected(i) && IsPlayerAdmin(i)) {
- SendClientMessage(i, COLOR_YELLOW, string);
- }
- }
- SendClientMessage(playerid, COLOR_YELLOW, "*You're request has been sent to online admins.");
- } else {
- SendClientMessage(playerid, COLOR_RED, "*You are not muted");
- }
- return 1;
- }
- CMD:minfo(playerid, params[]) {
- new targetid, string[128], name[MAX_PLAYER_NAME];
- if(sscanf(params, "u", targetid)) return SendClientMessage(playerid, COLOR_LIGHTBLUE,"[USAGE]: /minfo [playerid]" );
- if(targetid == INVALID_PLAYER_ID) return SendClientMessage( playerid, COLOR_RED,"[ERROR]: Player Is Not Connected!" );
- GetPlayerName(targetid, name, sizeof(name));
- format(string, sizeof(string), "Player Name: %s | Total Mutes: %d", name, PlayerInfo[targetid][TotalMute]);
- SendClientMessage(playerid, COLOR_LAWNGREEN, string);
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement