154 lines
4.2 KiB
SourcePawn
154 lines
4.2 KiB
SourcePawn
#include <sourcemod>
|
|
#include <PlayerManager>
|
|
#include <sdktools>
|
|
#include <basecomm>
|
|
#include <clientprefs>
|
|
#include <selfmute>
|
|
#include <voice>
|
|
|
|
#pragma semicolon 1
|
|
#pragma newdecls required
|
|
|
|
Handle g_hCheckMutes = null;
|
|
Handle g_hCookieTorchMuted = null;
|
|
|
|
bool g_bWasChecked[MAXPLAYERS + 1];
|
|
|
|
public Plugin myinfo =
|
|
{
|
|
name = "NoSteam CELT Voice override",
|
|
author = "jenz",
|
|
version = "1.0"
|
|
};
|
|
|
|
public void OnPluginStart()
|
|
{
|
|
g_hCheckMutes = CreateTimer(2.0, check_mutes, _, TIMER_REPEAT);
|
|
g_hCookieTorchMuted = RegClientCookie("torch_muted", "is torch muted", CookieAccess_Protected);
|
|
}
|
|
|
|
public void OnPluginEnd()
|
|
{
|
|
if (g_hCheckMutes != null)
|
|
{
|
|
delete g_hCheckMutes;
|
|
}
|
|
}
|
|
|
|
public void set_webclient_listen_override(int client)
|
|
{
|
|
for (int j = 1; j <= MaxClients; j++)
|
|
{
|
|
if (!IsValidClient(j) || client == j || IsFakeClient(j))
|
|
continue;
|
|
if (!PM_IsPlayerSteam(client) && PM_IsPlayerSteam(j))
|
|
{
|
|
//the nosteam client is not allowed to hear the steam client because broadcastvoicedata would ear rape them.
|
|
//LogMessage("%N has muted %N", client, j);
|
|
SetListenOverride(client, j, Listen_No);
|
|
}
|
|
}
|
|
}
|
|
|
|
public Action check_mutes(Handle timer, any data)
|
|
{
|
|
for (int i = 1; i <= MaxClients; i++)
|
|
{
|
|
if (!IsValidClient(i) || IsFakeClient(i))
|
|
{
|
|
continue;
|
|
}
|
|
if (!g_bWasChecked[i])
|
|
{
|
|
//this exists for the webclient. the webclient is skipping all connection related forwards. hence a manual check like this is needed for the webclient.
|
|
char dummy[64];
|
|
OnClientAuthorized(i, dummy);
|
|
set_webclient_listen_override(i);
|
|
}
|
|
for (int j = 1; j <= MaxClients; j++)
|
|
{
|
|
if (!IsValidClient(j) || i == j || IsFakeClient(j))
|
|
{
|
|
continue;
|
|
}
|
|
bool isMuted = BaseComm_IsClientMuted(j);
|
|
if (!isMuted)
|
|
{
|
|
isMuted = SelfMute_IsIgnoring(i, j);
|
|
}
|
|
//PrintToChatAll("i: %N. j: %N. isMuted: %i", i, j, isMuted);
|
|
ClientMutedOtherClient(i, j, isMuted);
|
|
}
|
|
}
|
|
|
|
//sourceTV special case, index 0.
|
|
for (int j = 1; j <= MaxClients; j++)
|
|
{
|
|
if (!IsValidClient(j) || IsFakeClient(j))
|
|
{
|
|
continue;
|
|
}
|
|
//yeah its monkey work but server can probably handle it fine.
|
|
char sBuffer[2];
|
|
GetClientCookie(j, g_hCookieTorchMuted, sBuffer, sizeof(sBuffer));
|
|
//PrintToChatAll("sBuffer: %s. j: %N", sBuffer, j);
|
|
if(sBuffer[0] != '\0')
|
|
{
|
|
ClientMutedOtherClient(j, 0, true);
|
|
}
|
|
else
|
|
{
|
|
ClientMutedOtherClient(j, 0, false);
|
|
}
|
|
}
|
|
return Plugin_Continue;
|
|
}
|
|
|
|
public void OnClientDisconnect(int client)
|
|
{
|
|
g_bWasChecked[client] = false;
|
|
}
|
|
|
|
public void OnClientAuthorized(int client, const char[] auth)
|
|
{
|
|
g_bWasChecked[client] = true;
|
|
if (IsFakeClient(client))
|
|
{
|
|
return;
|
|
}
|
|
SetClientNoSteam(client, false);
|
|
if (!PM_IsPlayerSteam(client))
|
|
{
|
|
SetClientNoSteam(client, true);
|
|
//LogMessage("here in onauthorized client: %N", client);
|
|
//setting it too early does not work, so some delay needed.
|
|
CreateTimer(10.0, Timer_SendVoiceInit, GetClientSerial(client));
|
|
CreateTimer(20.0, Timer_SendVoiceInit, GetClientSerial(client));
|
|
CreateTimer(30.0, Timer_SendVoiceInit, GetClientSerial(client));
|
|
CreateTimer(40.0, Timer_SendVoiceInit, GetClientSerial(client));
|
|
CreateTimer(50.0, Timer_SendVoiceInit, GetClientSerial(client));
|
|
CreateTimer(60.0, Timer_SendVoiceInit, GetClientSerial(client));
|
|
}
|
|
}
|
|
|
|
public Action Timer_SendVoiceInit(Handle timer, int Serial)
|
|
{
|
|
int client;
|
|
if ((client = GetClientFromSerial(Serial)) == 0)
|
|
{
|
|
return Plugin_Handled;
|
|
}
|
|
if (IsValidClient(client))
|
|
{
|
|
SendCeltVoiceInit(client);
|
|
}
|
|
return Plugin_Handled;
|
|
}
|
|
|
|
stock bool IsValidClient(int client)
|
|
{
|
|
if (client > 0 && client <= MaxClients && IsClientConnected(client) && IsClientInGame(client))
|
|
return true;
|
|
return false;
|
|
}
|