Raised This Month: $ Target: $400
 0% 

[L4D2] Possible to disable All Talk for spectators?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Inker
SourceMod Donor
Join Date: Dec 2008
Old 11-09-2010 , 11:07   [L4D2] Possible to disable All Talk for spectators?
Reply With Quote #1

I run a 20 slot L4D2 server and we often get a lot of spectators during VS games. We like to have All Talk on but the noise can get a bit overwhelming when you have 20 voices talking at once. So I'm wondering if there's a plugin out there that can toggle on and off the ability to have just the survivors and infected talking to one another, but spectator voices can only be heard by other spectators. Or if there isnt an existing plugin, would it be hard to code?
Inker is offline
Mr. Zero
Veteran Member
Join Date: Jun 2009
Location: Denmark
Old 11-09-2010 , 11:53   Re: [L4D2] Possible to disable All Talk for spectators?
Reply With Quote #2

Something like this just in a voice mute version?
Mr. Zero is offline
Inker
SourceMod Donor
Join Date: Dec 2008
Old 11-09-2010 , 22:07   Re: [L4D2] Possible to disable All Talk for spectators?
Reply With Quote #3

Possibly, although I'd ideally like the spectators to be able to voice chat to one another but that isnt super important
Inker is offline
Inker
SourceMod Donor
Join Date: Dec 2008
Old 11-11-2010 , 02:41   Re: [L4D2] Possible to disable All Talk for spectators?
Reply With Quote #4

Is there a command similar to 'sm_mute @spectators' or something like that?
Inker is offline
Mr. Zero
Veteran Member
Join Date: Jun 2009
Location: Denmark
Old 11-11-2010 , 05:42   Re: [L4D2] Possible to disable All Talk for spectators?
Reply With Quote #5

Unfortunately no.

I will add your feature request to gag 4 spec later on.

In the mean time, here is a temporary solution.

Not tested, but it should work alright. sm_mutespecs to mute spectators.
Meaning that they won't be able to talk to the teams, but they can still talk to all in spectator. They can still hear what the teams say.

Of course this plugin "ruins" a normal game if sv_alltalk ain't on. Meaning that the teams can hear each other.

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

#define PLUGIN_VERSION    "1.0.0"
#define TEAM_SPECTATOR    1

static             bool:    g_bIsMuteOn false;
static    const    
Float:    UPDATE_DELAY 0.3// After a team change, use this delay to make sure voice updates corretly

public Plugin:myinfo 
{
    
name "Mute Specs",
    
author "Mr. Zero",
    
description "A temporary solution for Inker and his loud mouthed spectators (yes you NeoIyse :p)",
    
version PLUGIN_VERSION,
    
url "http://forums.alliedmods.net/showthread.php?t=142755"
}

public 
OnPluginStart()
{
    
RegAdminCmd("sm_mutespecs"OnMuteSpecsCommandADMFLAG_CHAT"Toggles mute on spectators"_FCVAR_PLUGIN);
    
    
HookEvent("round_start",         OnUpdateEventTempEventHookMode_PostNoCopy);
    
HookEvent("round_end",             OnUpdateEventTempEventHookMode_PostNoCopy);
    
HookEvent("player_team",         OnUpdateEventTempEventHookMode_PostNoCopy);
    
HookEvent("player_spawn",         OnUpdateEventEventHookMode_PostNoCopy);
    
HookEvent("player_disconnect",     OnUpdateEventEventHookMode_PostNoCopy);
    
HookEvent("player_death",         OnUpdateEventEventHookMode_PostNoCopy);
    
HookEvent("player_bot_replace"OnUpdateEventEventHookMode_PostNoCopy);
    
HookEvent("bot_player_replace"OnUpdateEventEventHookMode_PostNoCopy);
    
HookEvent("defibrillator_used"OnUpdateEventEventHookMode_PostNoCopy);
}

public 
Action:OnMuteSpecsCommand(clientargs)
{
    new 
bool:wasOn g_bIsMuteOn;
    
g_bIsMuteOn = !g_bIsMuteOn;
    
ShowActivity(client"Toggled mute for spectators");
    if (
wasOnRestoreListenOverrides();
    return 
Plugin_Handled;
}

public 
OnUpdateEventTemp(Handle:event, const String:name[], bool:dontBroadcast)
{
    
CreateTimer(UPDATE_DELAYUpdateListenOverrides_Timer);
}

public 
OnUpdateEvent(Handle:event, const String:name[], bool:dontBroadcast)
{
    
UpdateListenOverrides();
}

public 
Action:UpdateListenOverrides_Timer(Handle:timer)
{
    
UpdateListenOverrides();
    return 
Plugin_Stop;
}

static 
UpdateListenOverrides()
{
    if (!
g_bIsMuteOn) return;

    new 
bool:isReceiverSpecbool:isSenderSpec;
    for (new 
receiver 1receiver <= MaxClientsreceiver++)
    {
        if (!
IsClientInGame(receiver) || IsFakeClient(receiver)) continue;
        
isReceiverSpec = (GetClientTeam(receiver) == TEAM_SPECTATOR);

        for (new 
sender 1sender <= MaxClientssender++)
        {
            if (
receiver == sender || !IsClientInGame(sender) || IsFakeClient(sender)) continue;
            
isSenderSpec = (GetClientTeam(sender) == TEAM_SPECTATOR);

            
/* Listen tabel: 
             * Receiver / Sender | On Team | On Spec |
             * On Team           | Yes     | No      |
             * On Spec           | Yes     | Yes     |
             */

            
if (!isReceiverSpec && !isSenderSpec// Receiver on team, Sender on team
            
{
                
SetListenOverride(receiversenderListen_Yes);
            }
            else if (
isReceiverSpec && !isSenderSpec// Receiver on spec, Sender on team
            
{
                
SetListenOverride(receiversenderListen_Yes);
            }
            else if (!
isReceiverSpec && isSenderSpec// Receiver on team, Sender on spec
            
{
                
SetListenOverride(receiversenderListen_No);
            }
            else if (
isReceiverSpec && isSenderSpec// Receiver on spec, Sender on spec
            
{
                
SetListenOverride(receiversenderListen_Yes);
            }
        }
    }
}

static 
RestoreListenOverrides()
{
    for (new 
receiver 1receiver <= MaxClientsreceiver++)
    {
        if (!
IsClientInGame(receiver) || IsFakeClient(receiver)) continue;

        for (new 
sender 1sender <= MaxClientssender++)
        {
            if (
receiver == sender || !IsClientInGame(sender) || IsFakeClient(sender)) continue;
            
SetListenOverride(receiversenderListen_Default);
        }
    }


Last edited by Mr. Zero; 11-11-2010 at 06:05.
Mr. Zero 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 03:48.


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