123 lines
3.1 KiB
SourcePawn
123 lines
3.1 KiB
SourcePawn
#include <sourcemod>
|
|
#include <PlayerManager>
|
|
#include <sdktools>
|
|
#include <basecomm>
|
|
#include <clientprefs>
|
|
#include <voice>
|
|
|
|
#pragma semicolon 1
|
|
#pragma newdecls required
|
|
|
|
Handle g_hCheckMutes = null;
|
|
Handle g_hCookieTorchMuted = null;
|
|
|
|
public Plugin myinfo =
|
|
{
|
|
name = "NoSteam CELT Voice override",
|
|
author = "jenz",
|
|
version = "1.0"
|
|
};
|
|
|
|
public void OnPluginStart()
|
|
{
|
|
g_hCheckMutes = CreateTimer(5.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 Action check_mutes(Handle timer, any data)
|
|
{
|
|
for (int i = 1; i <= MaxClients; i++)
|
|
{
|
|
if (!IsValidClient(i) || IsFakeClient(i))
|
|
{
|
|
continue;
|
|
}
|
|
for (int j = 1; j <= MaxClients; j++)
|
|
{
|
|
if (!IsValidClient(j) || i == j || IsFakeClient(j))
|
|
{
|
|
continue;
|
|
}
|
|
//i = muter, j = mutee
|
|
bool isMuted = GetListenOverride(i, j) == Listen_No;
|
|
if (!isMuted)
|
|
{
|
|
isMuted = BaseComm_IsClientMuted(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 OnClientAuthorized(int client, const char[] auth)
|
|
{
|
|
if (IsFakeClient(client))
|
|
{
|
|
return;
|
|
}
|
|
SetClientNoSteam(client, false);
|
|
if (!PM_IsPlayerSteam(client))
|
|
{
|
|
SetClientNoSteam(client, true);
|
|
//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;
|
|
}
|