Using clientprefs to store a cookie to determine whether or not a player can hear "say sounds". Racking my brain trying to figure out the proper way to have EmitSoundToClient only play to clients who have the global bool g_bCanHearSounds[] set to true.
This is probably the simplest bloody thing to do, but admittedly, I did smoke a bowl earlier so I'm having some troubles. I've tested various arrangements of the code below ingame, but no sounds have played.
PHP Code:
public Action Listener_Say(int iClient, const char[] strCommand, int iArgs)
{
if (!iClient || iClient > MaxClients || !IsClientInGame(iClient))
{
return Plugin_Continue;
}
char strChat[100];
GetCmdArgString(strChat, sizeof(strChat));
int iStart;
if (strChat[iStart] == '"')
{
iStart++;
}
int iLength = strlen(strChat[iStart]);
if (strChat[iLength+iStart-1] == '"')
{
strChat[iLength--+iStart-1] = '\0';
}
if (StrContains(strChat[iStart], "attention", false) != -1 && iLength <= 9)
{
for (int i=1; i<=MaxClients; i++)
{
if (IsClientInGame(i) && g_bCanHearSounds[i])
{
EmitSoundToClient(i, TF2_ATTENTION, _, _, SNDLEVEL_NORMAL, _, SNDVOL_NORMAL, _, _, _, _, _, _);
}
}
}
return Plugin_Continue;
}