comitting the sourcemod plugin part for voice extension update

This commit is contained in:
jenz 2026-05-30 16:58:35 +02:00
parent 723525f8c5
commit b8ac8cc571
3 changed files with 158 additions and 0 deletions

6
CELT_VOICE/README.md Normal file
View File

@ -0,0 +1,6 @@
this is used for the voice extension:
https://git.unloze.com/UNLOZE/sm-ext-Voice/src/branch/opus
//the voice chat is now transcoded so both celt and opus work by sending each stream to the player that needs it.
the include belongs to the voice extension but is also put here extra

View File

@ -0,0 +1,35 @@
#if defined _voice_included
#endinput
#endif
#define _voice_included
native bool IsClientTalking(int client);
native bool SetClientNoSteam(int client, bool isNosteam);
native bool SendCeltVoiceInit(int client);
native bool ClientMutedOtherClient(int client, int otherclient, bool muted);
/**
* Do not edit below this line!
*/
public Extension __ext_voice =
{
name = "Voice",
file = "Voice.ext",
#if defined AUTOLOAD_EXTENSIONS
autoload = 1,
#else
autoload = 0,
#endif
#if defined REQUIRE_EXTENSIONS
required = 1,
#else
required = 0,
#endif
};
#if !defined REQUIRE_EXTENSIONS
public __ext_voice_SetNTVOptional()
{
MarkNativeAsOptional("IsClientTalking");
}
#endif

View File

@ -0,0 +1,117 @@
#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));
}
}
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;
}