Okay, so. A server than I have admin on wanted a mod that allowed all the dead people to chat with all of the other dead people while the alive players could talk with other alive players and not head the dead players.
Here's what I made. It works fine just like how it should, the only thing is, players can't personally mute anyone through the Player List found in the escape menu, and admins cant globally mute anyone.
Am I doing something wrong?
Code:
#include <sourcemod>
#include <sdktools>
#define VOICE_NORMAL 0 /* Allow the client to listen and speak normally. */
#define VOICE_MUTED 1 /* Mutes the client from speaking to everyone. */
#define VOICE_SPEAKALL 2 /* Allow the client to speak to everyone. */
#define VOICE_LISTENALL 4 /* Allow the client to listen to everyone. */
#define VOICE_TEAM 8 /* Allow the client to always speak to team, even when dead. */
#define VOICE_LISTENTEAM 16 /* Allow the client to always hear teammates, including dead ones. */
public Plugin:myinfo =
{
name = "Dead Alltalk",
author = "BlackOps",
description = "Let dead people talk to other dead people while the alive players can continue playing",
version = "1",
url = ""
}
public OnPluginStart()
{
HookEvent("player_spawn", SpawnEvent)
HookEvent("player_death", DeathEvent)
HookEvent("player_team", TeamEvent)
}
public SpawnEvent(Handle:event, const String:name[], bool:dontBroadcast)
{
new client = GetClientOfUserId(GetEventInt(event, "userid"))
SetClientListeningFlags(client, VOICE_SPEAKALL)
}
public DeathEvent(Handle:event, const String:name[], bool:dontBroadcast)
{
new client = GetClientOfUserId(GetEventInt(event, "userid"))
SetClientListeningFlags(client, VOICE_LISTENALL)
PrintToChat(client, "\x04[DeadChat] \x03You are now dead. You can voice-chat with other dead players. Alive players can't hear you.");
}
public TeamEvent(Handle:event, const String:name[], bool:dontBroadcast)
{
new client = GetClientOfUserId(GetEventInt(event, "userid"))
new team = GetEventInt(event, "team")
if(client)
if (team == 1)
{
SetClientListeningFlags(client, VOICE_SPEAKALL|VOICE_LISTENALL)
PrintToChat(client, "\x04[SpecChat] \x03You are now a spectator. You can talk and listen to everyone!!!");
}
else
SetClientListeningFlags(client, VOICE_LISTENALL)
}