91 lines
2.4 KiB
SourcePawn
91 lines
2.4 KiB
SourcePawn
//----------------------------------------------------------------------------------------------------
|
|
// Radio bans: per-map bans keyed by SteamID, so they survive reconnects but die with the map.
|
|
//----------------------------------------------------------------------------------------------------
|
|
|
|
static StringMap g_BannedAuths;
|
|
|
|
void Bans_Init()
|
|
{
|
|
g_BannedAuths = new StringMap();
|
|
|
|
RegAdminCmd("sm_radiomute", Command_RadioBan, ADMFLAG_CHAT, "sm_radiomute <target> - mute target(s)' radio for the rest of the map");
|
|
RegAdminCmd("sm_radiounmute", Command_RadioUnban, ADMFLAG_CHAT, "sm_radiounmute <target> - allow target(s) to use the radio again");
|
|
}
|
|
|
|
void Bans_Clear()
|
|
{
|
|
g_BannedAuths.Clear();
|
|
}
|
|
|
|
bool Bans_IsBanned(int client)
|
|
{
|
|
char auth[32];
|
|
if (!GetClientAuthId(client, AuthId_Steam2, auth, sizeof(auth)))
|
|
return false;
|
|
|
|
int dummy;
|
|
return g_BannedAuths.GetValue(auth, dummy);
|
|
}
|
|
|
|
static void Bans_Set(int client, bool banned)
|
|
{
|
|
char auth[32];
|
|
if (!GetClientAuthId(client, AuthId_Steam2, auth, sizeof(auth)))
|
|
return;
|
|
|
|
if (banned)
|
|
g_BannedAuths.SetValue(auth, 1);
|
|
else
|
|
g_BannedAuths.Remove(auth);
|
|
}
|
|
|
|
public Action Command_RadioBan(int client, int argc)
|
|
{
|
|
return Bans_Command(client, argc, true, "sm_radiomute");
|
|
}
|
|
|
|
public Action Command_RadioUnban(int client, int argc)
|
|
{
|
|
return Bans_Command(client, argc, false, "sm_radiounmute");
|
|
}
|
|
|
|
static Action Bans_Command(int client, int argc, bool ban, const char[] command)
|
|
{
|
|
if (argc < 1)
|
|
{
|
|
ReplyToCommand(client, "[SM] Usage: %s <target>", command);
|
|
return Plugin_Handled;
|
|
}
|
|
|
|
char pattern[MAX_TARGET_LENGTH];
|
|
GetCmdArg(1, pattern, sizeof(pattern));
|
|
|
|
char targetName[MAX_TARGET_LENGTH];
|
|
int targets[MAXPLAYERS];
|
|
bool tnIsML;
|
|
|
|
int count = ProcessTargetString(pattern, client, targets, sizeof(targets),
|
|
COMMAND_FILTER_CONNECTED | COMMAND_FILTER_NO_BOTS, targetName, sizeof(targetName), tnIsML);
|
|
if (count <= 0)
|
|
{
|
|
ReplyToTargetError(client, count);
|
|
return Plugin_Handled;
|
|
}
|
|
|
|
for (int i = 0; i < count; i++)
|
|
Bans_Set(targets[i], ban);
|
|
|
|
if (ban)
|
|
{
|
|
ShowActivity2(client, "[SM] ", "Radio-muted %s for the rest of the map.", targetName);
|
|
LogAction(client, count == 1 ? targets[0] : -1, "\"%L\" radio-muted \"%s\"", client, targetName);
|
|
}
|
|
else
|
|
{
|
|
ShowActivity2(client, "[SM] ", "Radio-unmuted %s.", targetName);
|
|
LogAction(client, count == 1 ? targets[0] : -1, "\"%L\" radio-unmuted \"%s\"", client, targetName);
|
|
}
|
|
|
|
return Plugin_Handled;
|
|
}
|