mirror of
https://github.com/Jackzmc/sourcemod-plugins.git
synced 2025-05-05 23:03:20 +00:00
Add l4d2_vocalize_control
This commit is contained in:
parent
c4c814f2f8
commit
a7e8cd67f8
3 changed files with 120 additions and 1 deletions
|
@ -32,6 +32,7 @@ Useful things:
|
|||
* [l4d2_autorestart](#l4d2_autorestart)
|
||||
* [l4d2_TKStopper](#l4d2_TKStopper)
|
||||
* [l4d2_crescendo_control](#l4d2_crescendo_control)
|
||||
* [l4d2_vocalize_control](#l4d2_vocalize_control)
|
||||
|
||||
### Modified Others
|
||||
* [200IQBots_FlyYouFools](#200IQBots_FlyYouFools)
|
||||
|
@ -325,4 +326,10 @@ _This plugin is currently in **development.**_ Current implementation may be lac
|
|||
|
||||
* **Cvars:**
|
||||
* `l4d2_crescendo_percent`
|
||||
* `l4d2_crescendo_range`
|
||||
* `l4d2_crescendo_range`
|
||||
|
||||
### l4d2_vocalize_control
|
||||
A very small plugin that simply allows a player to mute another player's vocalizations only for them.
|
||||
|
||||
* **Commands:**
|
||||
* `sm_vgag <player(s)>` - Vocalize gag or ungags selected player(s)
|
BIN
plugins/l4d2_vocalize_control.smx
Normal file
BIN
plugins/l4d2_vocalize_control.smx
Normal file
Binary file not shown.
112
scripting/l4d2_vocalize_control.sp
Normal file
112
scripting/l4d2_vocalize_control.sp
Normal file
|
@ -0,0 +1,112 @@
|
|||
#pragma semicolon 1
|
||||
#pragma newdecls required
|
||||
|
||||
//#define DEBUG
|
||||
|
||||
#define PLUGIN_VERSION "1.0"
|
||||
|
||||
#include <sourcemod>
|
||||
#include <sdktools>
|
||||
//#include <sdkhooks>
|
||||
|
||||
public Plugin myinfo =
|
||||
{
|
||||
name = "L4D2 Vocalize Control",
|
||||
author = "jackzmc",
|
||||
description = "",
|
||||
version = PLUGIN_VERSION,
|
||||
url = ""
|
||||
};
|
||||
|
||||
ArrayList gaggedPlayers[MAXPLAYERS];
|
||||
|
||||
public void OnPluginStart()
|
||||
{
|
||||
EngineVersion g_Game = GetEngineVersion();
|
||||
if(g_Game != Engine_Left4Dead2)
|
||||
{
|
||||
SetFailState("This plugin is for L4D2 only.");
|
||||
}
|
||||
|
||||
for(int i = 0; i < sizeof(gaggedPlayers); i++) {
|
||||
gaggedPlayers[i] = new ArrayList(MAXPLAYERS - 1);
|
||||
}
|
||||
|
||||
HookEvent("player_disconnect", Event_PlayerDisconnect);
|
||||
|
||||
RegConsoleCmd("sm_vgag", Cmd_Gag, "Gags a player\'s vocalizations locally");
|
||||
AddNormalSoundHook(view_as<NormalSHook>(SoundHook));
|
||||
}
|
||||
|
||||
public void Event_PlayerDisconnect(Event event, const char[] name, bool dontBroadcast) {
|
||||
int client = GetClientOfUserId(event.GetInt("userid"));
|
||||
if(client > 0) {
|
||||
//Clear the player's list of gagged
|
||||
gaggedPlayers[client].Clear();
|
||||
//Remove this player from any other player's gag list
|
||||
for(int i = 0; i <= MaxClients; i++) {
|
||||
int index = gaggedPlayers[i].FindValue(client);
|
||||
if(index > -1) {
|
||||
gaggedPlayers[i].Erase(index);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Action Cmd_Gag(int client, int args) {
|
||||
if(args < 1) {
|
||||
ReplyToCommand(client, "Usage: sm_vgag <player>");
|
||||
} else {
|
||||
char arg1[32];
|
||||
GetCmdArg(1, arg1, sizeof(arg1));
|
||||
char target_name[MAX_TARGET_LENGTH];
|
||||
int target_list[MAXPLAYERS], target_count;
|
||||
bool tn_is_ml;
|
||||
if ((target_count = ProcessTargetString(
|
||||
arg1,
|
||||
client,
|
||||
target_list,
|
||||
MAXPLAYERS,
|
||||
COMMAND_FILTER_ALIVE, /* Only allow alive players */
|
||||
target_name,
|
||||
sizeof(target_name),
|
||||
tn_is_ml)) <= 0)
|
||||
{
|
||||
/* This function replies to the admin with a failure message */
|
||||
ReplyToTargetError(client, target_count);
|
||||
return Plugin_Handled;
|
||||
}
|
||||
for (int i = 0; i < target_count; i++)
|
||||
{
|
||||
int playerIndex = gaggedPlayers[client].FindValue(target_list[i]);
|
||||
if(playerIndex > -1) {
|
||||
gaggedPlayers[client].Erase(playerIndex);
|
||||
ReplyToCommand(client, "locally vocalize ungagged %s", target_name[i]);
|
||||
}else{
|
||||
gaggedPlayers[client].Push(target_list[i]);
|
||||
ReplyToCommand(client, "locally vocalize gagged %s", target_name[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
public Action SoundHook(int[] clients, int& numClients, char sample[PLATFORM_MAX_PATH], int& entity, int& channel, float& volume, int& level, int& pitch, int& flags, char[] soundEntry, int& seed) {
|
||||
if(numClients > 0 && entity > 0 && entity <= MaxClients) {
|
||||
if(StrContains(sample, "survivor\\voice") > -1) {
|
||||
for(int i = 0; i < numClients; i++) {
|
||||
int client = clients[i];
|
||||
if(gaggedPlayers[client].FindValue(entity) > -1) {
|
||||
int swap = clients[numClients - 1];
|
||||
clients[numClients - 1] = client;
|
||||
clients[i] = swap;
|
||||
numClients -= 1;
|
||||
return Plugin_Handled;
|
||||
//Remove client from clients
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return Plugin_Continue;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue