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

[L4D] Gag Spectators


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
spiderlemur
Senior Member
Join Date: Jul 2009
Old 09-18-2009 , 13:32   [L4D] Gag Spectators
Reply With Quote #1

In competitive scrims, the spectators sometimes talk in allchat (text), the players seem to find this annoying and distracting including myself. A simple plugin that restricts them to team chat would be amazing.
spiderlemur is offline
Send a message via AIM to spiderlemur
olj
Veteran Member
Join Date: Jun 2009
Old 09-18-2009 , 16:47   Re: [L4D] Gag Spectators
Reply With Quote #2

BLOCK say command for spectators. Thats all. We can hook player_team event for this. Should i make it right now?
__________________
olj is offline
Frus
Senior Member
Join Date: Aug 2009
Old 09-18-2009 , 17:46   Re: [L4D] Gag Spectators
Reply With Quote #3

Quote:
Originally Posted by olj View Post
BLOCK say command for spectators. Thats all. We can hook player_team event for this. Should i make it right now?
You could just use GetClientTeam when you hook a say command...
Frus is offline
olj
Veteran Member
Join Date: Jun 2009
Old 09-18-2009 , 20:15   Re: [L4D] Gag Spectators
Reply With Quote #4

Oh, damn what a noob i am, lolz
__________________
olj is offline
spiderlemur
Senior Member
Join Date: Jul 2009
Old 09-19-2009 , 13:22   Re: [L4D] Gag Spectators
Reply With Quote #5

Quote:
Originally Posted by olj View Post
BLOCK say command for spectators. Thats all. We can hook player_team event for this. Should i make it right now?
Go ahead, I'd really appreciate it.

Last edited by spiderlemur; 09-19-2009 at 13:25.
spiderlemur is offline
Send a message via AIM to spiderlemur
n0limit
Senior Member
Join Date: May 2009
Old 09-19-2009 , 14:33   Re: [L4D] Gag Spectators
Reply With Quote #6

Code:
#include <sourcemod>
#define TEAM_SPECTATOR 1
public Plugin:myinfo = 
{
    name = "n0limit",
    author = "SpectatorGag",
    description = "Gags spectators so they cannot speak in chat (for scrims)",
    version = "1.0",
    url = "<- URL ->"
}

public OnPluginStart()
{
    HookEvent("player_say",Event_PlayerSay,EventHookMode_Pre);
    
    
}
public Action:Event_PlayerSay(Handle:event, const String:name[], bool:dontBroadcast)
{
    new userid = GetEventInt(event,"userid");

    if(GetClientTeam(GetClientOfUserId(userid)) == TEAM_SPECTATOR)
        return Plugin_Handled;
    return Plugin_Continue;
}
Wrote this up real quick, but it seems like the event doesn't fire for specs.
I put PrintToChatAll("%d (%d) say",userid,GetClientTeam(GetClientOfUserId(u serid))); in the event handler and it only would print for players on a team..
n0limit is offline
bman87
Senior Member
Join Date: Dec 2008
Location: Michigan
Old 09-19-2009 , 15:44   Re: [L4D] Gag Spectators
Reply With Quote #7

Why dont you just hook the say command, check if the play is spectator, and return plugin_handled?
bman87 is offline
n0limit
Senior Member
Join Date: May 2009
Old 09-20-2009 , 00:04   Re: [L4D] Gag Spectators
Reply With Quote #8

Quote:
Originally Posted by bman87 View Post
Why dont you just hook the say command, check if the play is spectator, and return plugin_handled?
Code above does that, but when i tested it briefly player_say didn't fire when specs talked, only survivors/infected.
n0limit is offline
Mr. Zero
Veteran Member
Join Date: Jun 2009
Location: Denmark
Old 09-20-2009 , 10:30   Re: [L4D] Gag Spectators
Reply With Quote #9

I think what bman87 means is RegConsoleCmd with the say command, instead of hooking the player_say event.

Here is something I'm working on (WIP, not tested).
Code:
#pragma semicolon 1
#include <sourcemod>

#define PLUGIN_VERSION	"0.90"
#define CVAR_FLAGS		FCVAR_PLUGIN|FCVAR_SPONLY

new Handle:g_hEnabled;
new Handle:g_hRedirect;
new Handle:g_hUngagSafe;
new Handle:g_hUngagFinal;
new Handle:g_hUngagRoundEnd;

new g_bGameHaveBegunOrEnded;

public Plugin:myinfo = 
{
	name = "Gag4Spec",
	author = "Mr. Zero",
	description = "Gages spectates while a game is active. Can ungag on different conditions.",
	version = PLUGIN_VERSION,
	url = "<- URL ->"
}

public OnPluginStart()
{
	CreateConVar("l4d_g4s_version",PLUGIN_VERSION,"Version number of Gag4Spec",CVAR_FLAGS|FCVAR_NOTIFY);
	g_hEnabled 			= CreateConVar("l4d_g4s_enable"			,"1", "Sets whether the Gag4Spec is active",CVAR_FLAGS);
	g_hRedirect 		= CreateConVar("l4d_g4s_redirect"		,"1", "Sets whether the plugin redirects a say command to say_team, for the spectator, if the game is active. If not the say command just gets ignored.",CVAR_FLAGS);
	g_hUngagSafe 		= CreateConVar("l4d_g4s_ungag_safe"		,"1", "Sets whether spectators is allowed to all chat while survivors still haven't left safe room.",CVAR_FLAGS);
	g_hUngagFinal 		= CreateConVar("l4d_g4s_ungag_final"	,"1", "Sets whether spectators is allowed to all chat when the rescue vehicle is taking off (or failed mission)",CVAR_FLAGS);
	g_hUngagRoundEnd 	= CreateConVar("l4d_g4s_ungag_roundend"	,"1", "Sets whether spectators is allowed to all chat when a round is ending",CVAR_FLAGS);
	
	AutoExecConfig(true,"Gag4Spec");
	
	HookEvent("player_left_start_area", Event_PlayerLeftStartArea);
	HookEvent("door_open", Event_OpenCheckPointDoor);
	HookEvent("round_start", Event_RoundStart);
	
	RegConsoleCmd("say",PlayerChat);
}

public Action:Event_OpenCheckPointDoor(Handle:event, const String:name[], bool:dontBroadcast)
{
	if(g_bGameHaveBegunOrEnded){return;}
	new bool:wasCheckpointDoor = GetEventBool(event,"checkpoint");
	if(wasCheckpointDoor)
	{
		g_bGameHaveBegunOrEnded = true;
	}
}

public Action:Event_PlayerLeftStartArea(Handle:event, const String:name[], bool:dontBroadcast)
{
	g_bGameHaveBegunOrEnded = true;
}

public Action:Event_RoundStart(Handle:event, const String:name[], bool:dontBroadcast)
{
	if(GetConVarBool(g_hUngagSafe))
	{
		g_bGameHaveBegunOrEnded = false;
	}
	else
	{
		g_bGameHaveBegunOrEnded = true;
	}
}

public Action:PlayerChat(client, arg)
{
	if((!GetConVarBool(g_hEnabled) || !g_bGameHaveBegunOrEnded)){return Plugin_Continue;}
	
	if(GetClientTeam(client) != 1){return Plugin_Continue;}
	
	if(!GetConVarBool(g_hRedirect)){return Plugin_Handled;}
	
	new String:text[256];
	GetCmdArgString(text,sizeof(text));
	
	FakeClientCommandEx(client,"say_team %s",text);
	return Plugin_Handled;
}
Mr. Zero is offline
Mr. Zero
Veteran Member
Join Date: Jun 2009
Location: Denmark
Old 09-24-2009 , 14:33   Re: [L4D] Gag Spectators
Reply With Quote #10

Plugin posted at: http://forums.alliedmods.net/showthread.php?t=104518
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 22:49.


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