Raised This Month: $ Target: $400
 0% 

REQ TF2 deadmute


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
nineteeneleven
Veteran Member
Join Date: Nov 2010
Old 04-04-2013 , 10:00   REQ TF2 deadmute
Reply With Quote #1

I'm looking for a plugin that will mute players when they die, and also mute everyone on red team for 30 seconds at the start of the map.

Can anyone lend me a hand?
__________________
nineteeneleven is offline
Cramik
Senior Member
Join Date: Jan 2013
Old 04-04-2013 , 17:36   Re: REQ TF2 deadmute
Reply With Quote #2

Jailbreak?
__________________
If you wanna learn anything (Im not exaggerating) tell me I probably have a book,answer,or tut.
Cramik is offline
Send a message via Skype™ to Cramik
nineteeneleven
Veteran Member
Join Date: Nov 2010
Old 04-04-2013 , 20:06   Re: REQ TF2 deadmute
Reply With Quote #3

Yea its for my jailbreak server
__________________
nineteeneleven is offline
thetwistedpanda
Good Little Panda
Join Date: Sep 2008
Old 04-12-2013 , 09:10   Re: REQ TF2 deadmute
Reply With Quote #4

Plugin is trivial, not something someone should sanely charge for. I'm about to walk out the door for work, so if no one has written it when I get off I'll throw something together. Here's quickly written pesudocode that gives an idea of how easy it is.

PHP Code:
g_fCounter
g_hStuff
g_hStuffing
MAXPLAYERS 1]

OnPluginStart
Hook round_start
Hook player_spawn
hook player_death
hook round_end

OnClientDIsconnect
g_hStuffing 
INVALID_HANDLE

OnMapEnd
g_hStuff 
INVALID_HANDLE

round_start
g_hStuff CreateTimer(1.0Timer_Stuff_TIMER_REPEAT)

Timer_Stuff
if(g_iCounter >= 30)
g_hStuff INVALID_HANDLE;
return 
Plugin_Stop
g_fCounter
++

player_spawn
g_hStuffing
[client] = CreateTimer(30.0 g_fCounterTimer_Stuffing)
Mute

Timer_Stuffing
Unmute
g_hStuffing
[client] = INVALID_HANDLE

player_death
mute

round_end
g_hStuff 
INVALID_HANDLE
g_hStuffing 
for all INVALID_HANDLE 
__________________

Last edited by thetwistedpanda; 04-12-2013 at 09:12.
thetwistedpanda is offline
nineteeneleven
Veteran Member
Join Date: Nov 2010
Old 04-12-2013 , 09:14   Re: REQ TF2 deadmute
Reply With Quote #5

Thanks a lot panda. It would be much appreciated. I did forget to mention in my post that I want players unmuted when they respawn though. But from what you wrote it seems you assumed the obvious
__________________

Last edited by nineteeneleven; 04-12-2013 at 09:15.
nineteeneleven is offline
thetwistedpanda
Good Little Panda
Join Date: Sep 2008
Old 04-12-2013 , 09:15   Re: REQ TF2 deadmute
Reply With Quote #6

That's only one extra line of code. Well, two, since you'd want to see if they were muted prior I suppose. Throw in another six lines to take into consideration admin / donator status so they're not muted, and a convar for the 30 seconds / mute on death, so another four lines. It's still under 100 lines lol. Easy easy.
__________________
thetwistedpanda is offline
nineteeneleven
Veteran Member
Join Date: Nov 2010
Old 04-12-2013 , 09:21   Re: REQ TF2 deadmute
Reply With Quote #7

yea that would be perfect. I didnt even think about admin/donors, the reserved slot flag would work for that.
__________________
nineteeneleven is offline
Dr. McKay
Sir Dr. SourceMod Plugin Approver Esq. Ltd. M.D. PhD
Join Date: Aug 2011
Location: Atlantis
Old 04-12-2013 , 09:56   Re: REQ TF2 deadmute
Reply With Quote #8

jailbreak_automute_time (default 30) - Time to mute RED for at the start of the round

Override: NoJailbreakMute (default a) - Access required to be immune to muting
Attached Files
File Type: sp Get Plugin or Get Source (jailbreak_mute.sp - 412 views - 2.4 KB)
__________________

Last edited by Dr. McKay; 04-12-2013 at 19:58.
Dr. McKay is offline
nineteeneleven
Veteran Member
Join Date: Nov 2010
Old 04-12-2013 , 10:02   Re: REQ TF2 deadmute
Reply With Quote #9

Thank you guys
__________________
nineteeneleven is offline
lyric
Veteran Member
Join Date: Sep 2012
Old 04-12-2013 , 10:21   Re: REQ TF2 deadmute
Reply With Quote #10

something like this would be great if it would mute dead/spectators and not do the RED team mute at round startup.

Code:
#pragma semicolon 1

#include <sourcemod>
#include <basecomm>
#include <tf2>

public Plugin:myinfo = {
	name        = "[TF2] Jailbreak Auto-Mute",
	author      = "Dr. McKay",
	description = "https://forums.alliedmods.net/showthread.php?t=212566",
	version     = "1.0.0",
	url         = "http://www.doctormckay.com"
};

new Handle:cvarMuteTime;
new Handle:cvarImmunityFlag;
new Handle:checkTimer;
new muteTime;

public OnPluginStart() {
	HookEvent("player_spawn", Event_PlayerSpawn);
	HookEvent("player_death", Event_PlayerDeath);
	HookEvent("teamplay_round_start", Event_RoundStart);
	HookEvent("teamplay_round_win", Event_RoundEnd);
	HookEvent("teamplay_round_stalemate", Event_RoundEnd);
}

public Event_RoundStart(Handle:event, const String:name[], bool:dontBroadcast) {
	muteTime = GetConVarInt(cvarMuteTime);
	checkTimer = CreateTimer(1.0, Timer_CheckMute, _, TIMER_REPEAT);
	
	decl String:flags[4];
	GetConVarString(cvarImmunityFlag, flags, sizeof(flags));
	new AdminFlag:flag, AdminId:admin;
	FindFlagByChar(flags[0], flag);
	
	for(new i = 1; i <= MaxClients; i++) {
		if(!IsClientInGame(i)) {
			continue;
		}
		admin = GetUserAdmin(i);
		if(admin != INVALID_ADMIN_ID && GetAdminFlag(admin, flag)) {
			continue; // immune
		}
	}
}

public Action:Timer_CheckMute(Handle:timer) {
	muteTime--;
	if(muteTime <= 0) {
		for(new i = 1; i <= MaxClients; i++) {
			if(!IsClientInGame(i)) {
				continue;
			}
			if(TFTeam:GetClientTeam(i) == TFTeam_Red) {
				BaseComm_SetClientMute(i, false);
			}
		}
		checkTimer = INVALID_HANDLE;
		return Plugin_Stop;
	}
	return Plugin_Continue;
}

public Event_PlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast) {
	new client = GetClientOfUserId(GetEventInt(event, "userid"));
	
	if(muteTime > 0 && TFTeam:GetClientTeam(client) == TFTeam_Red) {
		BaseComm_SetClientMute(client, true);
		return; // Timer hasn't expired yet
	}
	
	BaseComm_SetClientMute(client, false); // Unmute
}

public Event_PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast) {
	new client = GetClientOfUserId(GetEventInt(event, "userid"));
	
	decl String:flags[4];
	GetConVarString(cvarImmunityFlag, flags, sizeof(flags));
	new AdminFlag:flag, AdminId:admin;
	FindFlagByChar(flags[0], flag);
	admin = GetUserAdmin(client);
	if(admin != INVALID_ADMIN_ID && GetAdminFlag(admin, flag)) {
		return; // Immune
	}
	
	BaseComm_SetClientMute(client, true);
}

public Event_RoundEnd(Handle:event, const String:name[], bool:dontBroadcast) {
	for(new i = 1; i <= MaxClients; i++) {
		if(IsClientInGame(i)) {
			BaseComm_SetClientMute(i, false);
		}
	}
	if(checkTimer != INVALID_HANDLE) {
		CloseHandle(checkTimer);
		checkTimer = INVALID_HANDLE;
	}
}
i treid to remove that myself but not sure if it works. it atleast compiles proper with no warning/errors

also, any idea if this would interfere with other mods such as Commsblock? i'd hate to see a billion mute/unmute entries because of this
__________________

Last edited by lyric; 04-12-2013 at 10:30.
lyric 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 20:44.


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