Quote:
Originally Posted by Bacardi
Check if server have this feature already. Type this without value you should get cvar result back in console.
sm_cvar sv_allow_voice_from_file
...and if it give output value, change cvar
sm_cvar sv_allow_voice_from_file 0
*edit
Players can still play music through microfone input though
|
Afraid there is no Cvar like that at all. I did "find allow" as well as "find voice" through the client console and found nothing of the sort.
I am aware you can still use virtual audio cable and what not but a lot of people use SLAM and this would weed out the majority of children that prefer using it.
With that said, the previously linked code doesn't work at all.
MASSIVE UPDATE and EDIT HERE:
Got it working! I assumed it wasn't working because it wasn't checking / binding to the clients correctly so I went looking around for a voice callback and found
this thread.
The code I used (I'm sure many would like to have it) is as follows (with of course both Dhooks and VoiceAnnounceEX installed):
PHP Code:
#include <sourcemod>
#include <sdktools>
#include <basecomm>
#include <voiceannounce_ex>
#define PLUGIN_VERSION "1.0"
#define message "You were kicked for attempting to micspam. Please set voice_inputfromfile to 0."
public Plugin:myinfo =
{
name = "Slam Protection",
author = "Furchee",
description = "Kicks clients that have voice_inputfromfile set to 1.",
version = PLUGIN_VERSION,
url = "http://furchee.com"
};
public OnClientPutInServer(client)
{
CreateTimer(2.0, StartVarChecker, client);
}
public void OnClientSpeakingEx(client)
{
QueryClientConVar(client, "voice_inputfromfile", ConVarQueryFinished:ClientConVar, client);
}
public Action:StartVarChecker(Handle:timer, any:client)
{
/*if (!IsClientInGame(client))
return Plugin_Stop;
*/
QueryClientConVar(client, "voice_inputfromfile", ConVarQueryFinished:ClientConVar, client);
return Plugin_Continue;
}
public ClientConVar(QueryCookie:cookie, client, ConVarQueryResult:result, const String:cvarName[], const String:cvarValue[])
{
if(!StrEqual(cvarValue, "0"))
{
LogAction(client, -1, "%L triggered mic spam protection, kicking", client);
KickClient(client, "%s", message);
}
}