Raised This Month: $51 Target: $400
 12% 

Mute players for eachother only by steam ID


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
midnight9
Senior Member
Join Date: Nov 2012
Old 06-23-2017 , 16:20   Mute players for eachother only by steam ID
Reply With Quote #1

Hello, Im using this plugin to allow local mute another client's text and voice chat. Im wondering if someone could help me edit it so I can pernamently mute 2 players by steam id so they cant see eachothers text and voice chat, but they still can see other players chat. Any ideas?

PHP Code:
#include <sourcemod>
#include <sdktools>

#include <scp>

#pragma semicolon 1

#define L4D2SELFM_VERSION   "0.4"

public Plugin:myinfo = {
    
name "L4D2 Self Mute",
    
author "Blade & Chdata",
    
description "Allows a player to local mute another client's text and voice chat.",
    
version L4D2SELFM_VERSION,
    
url "https://github.com/thebladeee/l4d2_selfmute"
};

enum Targeting
{
    
String:arg[MAX_NAME_LENGTH],
    
buffer[MAXPLAYERS],
    
buffersize,
    
String:targetname[MAX_TARGET_LENGTH],
    
bool:tn_is_ml
};

static 
Target[Targeting];

enum IgnoreStatus
{
    
bool:Chat,
    
bool:Voice
};

static 
bool:IgnoreMatrix[MAXPLAYERS 1][MAXPLAYERS 1][IgnoreStatus];

public 
OnPluginStart()
{
    
CreateConVar(
        
"sm_l4d2sgag_version"L4D2SELFM_VERSION,
        
"L4D2 Self Gag Version",
        
FCVAR_REPLICATED|FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_DONTRECORD|FCVAR_NOTIFY
    
);

    
LoadTranslations("common.phrases"); //ignore <player>

    
RegConsoleCmd("sm_smute"Command_Ignore"Usage: sm_smute <#userid|name>\nSet target's chat and voice to be ignored.");

    
RegConsoleCmd("sm_sunmute"Command_UnIgnore"Usage: sm_sunmute <#userid|name>\nUnmutes target.");
}

/*
Check for necessary plugin dependencies and shut down this plugin if not found.

*/
public OnAllPluginsLoaded()
{
    if (!
LibraryExists("scp"))
    {
        
SetFailState("Simple Chat Processor is not loaded. It is required for this plugin to work.");
    }
}

/*
If a necessary plugin is removed, also shut this one down.

*/
public OnLibraryRemoved(const String:name[])
{
    if (
StrEqual(name"scp"))
    {
        
SetFailState("Simple Chat Processor Unloaded. Plugin Disabled.");
    }
}

public 
OnClientDisconnect(client)
{
    for (new 
0<= MAXPLAYERSi++)
    {
        
IgnoreMatrix[client][i][Chat] = false;
        
IgnoreMatrix[client][i][Voice] = false;
    }
}

public 
Action:OnChatMessage(&authorHandle:recipientsString:name[], String:message[])
{
    if ((
author 0) || (author MaxClients))
    {
        
LogError("[Ignore list] Warning: author is out of bounds: %d"author);
        return 
Plugin_Continue;
    }
    new 
0;
    new 
client;
    while (
GetArraySize(recipients))
    {
        
client GetArrayCell(recipientsi);
        if ((
client 0) || (client MaxClients))
        {
            
LogError("[L4D2 Self Mute] Warning: client is out of bounds: %d, Try updating SCP"client);
            
i++;
            continue;
        }
        if (
IgnoreMatrix[client][author][Chat])
        {
            
RemoveFromArray(recipientsi);
        }
        else
        {
            
i++;
        }
    }
    return 
Plugin_Changed;
}

public 
Action:Command_Ignore(clientargs)
{
    if (
args == 0)
    {
        
ReplyToCommand(client"Usage: sm_smute <#userid|name>");
        return 
Plugin_Handled;
    }
    
    
ProcessIgnore(clienttruetrue3);

    return 
Plugin_Handled;
}

/*
client is the person ignoring someone
the chat/voice bool says what we want to set their status to
which says whether or not we're actually changing chat 1, voice 2, or both 3

*/
stock ProcessIgnore(client, const bool:chat false, const bool:voice false, const which)
{
    
GetCmdArg(1Target[arg], MAX_NAME_LENGTH);

    new 
bool:bTargetAll false;

    if (
strcmp(Target[arg], "@all"false) == 0)
    {
        
bTargetAll true;
    }

    
Target[buffersize] = ProcessTargetString(Target[arg], clientTarget[buffer], MAXPLAYERSCOMMAND_FILTER_CONNECTED|COMMAND_FILTER_NO_IMMUNITYTarget[targetname], MAX_TARGET_LENGTHTarget[tn_is_ml]);

    if (
Target[buffersize] <= 0)
    {
        
ReplyToTargetError(clientTarget[buffersize]);
        return;
    }

    for (new 
0Target[buffersize]; i++)
    {
        
ToggleIgnoreStatus(clientTarget[buffer][i], chatvoicewhichbTargetAll);        
    }

    if (
bTargetAll)
    {
        
decl String:s[MAXLENGTH_MESSAGE];

        
Format(ssizeof(s), "[SM] All Players - Chat: %s | Voice: %s",
            !(
which 1) ? "Unchanged" chat "OFF" "ON",
            !(
which 2) ? "Unchanged" voice "OFF" "ON"
        
);

        
ReplyToCommand(clients);
    }

    return;
}

ToggleIgnoreStatus(const client, const target, const bool:chat, const bool:voice, const which, const bool:bTargetAll)
{
    if (
which 1)
    {
        
IgnoreMatrix[client][target][Chat] = chat;
    }

    if (
which 2)
    {
        
IgnoreMatrix[client][target][Voice] = voice;

        if (
IgnoreMatrix[client][target][Voice])
        {
            
SetListenOverride(clienttargetListen_No);
        }
        else
        {
            
SetListenOverride(clienttargetListen_Default);
        }
    }

    if (
bTargetAll)
    {
        return;
    }

    
decl String:s[MAXLENGTH_MESSAGE];

    
Format(ssizeof(s), "[SM] %N - Chat: %s | Voice: %s",
        
target,
        
IgnoreMatrix[client][target][Chat] ? "OFF" "ON",
        
IgnoreMatrix[client][target][Voice] ? "OFF" "ON"
    
);

    
ReplyToCommand(clients);
    return;
}

public 
Action:Command_UnIgnore(clientargs)
{
    if (
args == 0)
    {
        
ReplyToCommand(client"Usage: sm_sunmute <#userid|name>");
        return 
Plugin_Handled;
    }
    
    
ProcessIgnore(clientfalsefalse3);

    return 
Plugin_Handled;
}

/*
Sets up a native to send whether or not a client is ignoring a specific target's chat

*/
public APLRes:AskPluginLoad2(Handle:myselfbool:lateString:error[], err_max)
{
    
CreateNative("GetIgnoreMatrix"Native_GetIgnoreMatrix);

    
RegPluginLibrary("ignorematrix");

    return 
APLRes_Success;
}

/*
The native itself

*/
public Native_GetIgnoreMatrix(Handle:pluginnumParams)
{
    new 
client GetNativeCell(1);
    new 
target GetNativeCell(2);

    return 
IgnoreMatrix[client][target][Chat];

midnight9 is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 07:34.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode