mirror of
https://github.com/daffyyyy/CS2-SimpleAdmin.git
synced 2026-02-18 10:43:23 +00:00
ban/gag/mute
This commit is contained in:
@@ -459,7 +459,7 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
||||
public void OnGagCommand(CCSPlayerController? caller, CommandInfo command)
|
||||
{
|
||||
int time = 0;
|
||||
string reason = "Unknown";
|
||||
string reason = null;
|
||||
|
||||
TargetResult? targets = GetTarget(command);
|
||||
if (targets == null) return;
|
||||
@@ -481,7 +481,17 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
||||
{
|
||||
if (caller!.CanTarget(player))
|
||||
{
|
||||
PlayerInfo playerInfo = new PlayerInfo
|
||||
Gag(caller, player, time, reason, _muteManager);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void Gag(CCSPlayerController? caller, CCSPlayerController player, int time, string reason = null, MuteManager muteManager = null)
|
||||
{
|
||||
reason ??= "Unknown";
|
||||
muteManager ??= new(dbConnectionString);
|
||||
|
||||
PlayerInfo playerInfo = new PlayerInfo
|
||||
{
|
||||
SteamId = player?.AuthorizedSteamID?.SteamId64.ToString(),
|
||||
Name = player?.PlayerName,
|
||||
@@ -497,7 +507,7 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
||||
|
||||
Task.Run(async () =>
|
||||
{
|
||||
await _muteManager.MutePlayer(playerInfo, adminInfo, reason, time);
|
||||
await muteManager.MutePlayer(playerInfo, adminInfo, reason, time);
|
||||
});
|
||||
|
||||
if (TagsDetected)
|
||||
@@ -550,8 +560,6 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
||||
Server.PrintToChatAll(sb.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
[ConsoleCommand("css_addgag")]
|
||||
@@ -765,7 +773,7 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
||||
public void OnMuteCommand(CCSPlayerController? caller, CommandInfo command)
|
||||
{
|
||||
int time = 0;
|
||||
string reason = "Unknown";
|
||||
string reason = null;
|
||||
|
||||
TargetResult? targets = GetTarget(command);
|
||||
if (targets == null) return;
|
||||
@@ -787,82 +795,88 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
||||
{
|
||||
if (caller!.CanTarget(player))
|
||||
{
|
||||
PlayerInfo playerInfo = new PlayerInfo
|
||||
{
|
||||
SteamId = player?.AuthorizedSteamID?.SteamId64.ToString(),
|
||||
Name = player?.PlayerName,
|
||||
IpAddress = player?.IpAddress?.Split(":")[0]
|
||||
};
|
||||
|
||||
PlayerInfo adminInfo = new PlayerInfo
|
||||
{
|
||||
SteamId = caller?.AuthorizedSteamID?.SteamId64.ToString(),
|
||||
Name = caller?.PlayerName,
|
||||
IpAddress = caller?.IpAddress?.Split(":")[0]
|
||||
};
|
||||
|
||||
/*
|
||||
if (!mutedPlayers.Contains((ushort)player.UserId))
|
||||
mutedPlayers.Add((ushort)player.UserId);
|
||||
*/
|
||||
|
||||
player!.VoiceFlags = VoiceFlags.Muted;
|
||||
|
||||
Task.Run(async () =>
|
||||
{
|
||||
await _muteManager.MutePlayer(playerInfo, adminInfo, reason, time, 1);
|
||||
});
|
||||
|
||||
|
||||
if (time > 0 && time <= 30)
|
||||
{
|
||||
AddTimer(time * 60, () =>
|
||||
{
|
||||
if (player == null || !player.IsValid || player.AuthorizedSteamID == null) return;
|
||||
|
||||
//MuteManager _muteManager = new(dbConnectionString);
|
||||
//_ = _muteManager.UnmutePlayer(player.AuthorizedSteamID.SteamId64.ToString(), 1);
|
||||
|
||||
/*
|
||||
if (mutedPlayers.Contains((int)player.Index))
|
||||
{
|
||||
if (mutedPlayers.TryTake(out int removedItem) && removedItem != (int)player.Index)
|
||||
{
|
||||
mutedPlayers.Add(removedItem);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
player.VoiceFlags = VoiceFlags.Normal;
|
||||
}, CounterStrikeSharp.API.Modules.Timers.TimerFlags.STOP_ON_MAPCHANGE);
|
||||
}
|
||||
|
||||
if (time == 0)
|
||||
{
|
||||
player!.PrintToCenter(_localizer!["sa_player_mute_message_perm", reason, caller == null ? "Console" : caller.PlayerName]);
|
||||
|
||||
if (caller == null || caller != null && caller.UserId != null && !silentPlayers.Contains((ushort)caller.UserId))
|
||||
{
|
||||
StringBuilder sb = new(_localizer!["sa_prefix"]);
|
||||
sb.Append(_localizer["sa_admin_mute_message_perm", caller == null ? "Console" : caller.PlayerName, player.PlayerName, reason]);
|
||||
Server.PrintToChatAll(sb.ToString());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
player!.PrintToCenter(_localizer!["sa_player_mute_message_time", reason, time, caller == null ? "Console" : caller.PlayerName]);
|
||||
|
||||
if (caller == null || caller != null && caller.UserId != null && !silentPlayers.Contains((ushort)caller.UserId))
|
||||
{
|
||||
StringBuilder sb = new(_localizer!["sa_prefix"]);
|
||||
sb.Append(_localizer["sa_admin_mute_message_time", caller == null ? "Console" : caller.PlayerName, player.PlayerName, reason, time]);
|
||||
Server.PrintToChatAll(sb.ToString());
|
||||
}
|
||||
}
|
||||
Mute(caller, player, time, reason, _muteManager);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void Mute(CCSPlayerController? caller, CCSPlayerController player, int time, string reason = null, MuteManager muteManager = null)
|
||||
{
|
||||
reason ??= "Unknown";
|
||||
muteManager ??= new(dbConnectionString);
|
||||
|
||||
PlayerInfo playerInfo = new PlayerInfo
|
||||
{
|
||||
SteamId = player?.AuthorizedSteamID?.SteamId64.ToString(),
|
||||
Name = player?.PlayerName,
|
||||
IpAddress = player?.IpAddress?.Split(":")[0]
|
||||
};
|
||||
|
||||
PlayerInfo adminInfo = new PlayerInfo
|
||||
{
|
||||
SteamId = caller?.AuthorizedSteamID?.SteamId64.ToString(),
|
||||
Name = caller?.PlayerName,
|
||||
IpAddress = caller?.IpAddress?.Split(":")[0]
|
||||
};
|
||||
|
||||
/*
|
||||
if (!mutedPlayers.Contains((ushort)player.UserId))
|
||||
mutedPlayers.Add((ushort)player.UserId);
|
||||
*/
|
||||
|
||||
player!.VoiceFlags = VoiceFlags.Muted;
|
||||
|
||||
Task.Run(async () => { await muteManager.MutePlayer(playerInfo, adminInfo, reason, time, 1); });
|
||||
|
||||
|
||||
if (time > 0 && time <= 30)
|
||||
{
|
||||
AddTimer(time * 60, () =>
|
||||
{
|
||||
if (player == null || !player.IsValid || player.AuthorizedSteamID == null)
|
||||
return;
|
||||
|
||||
//MuteManager _muteManager = new(dbConnectionString);
|
||||
//_ = _muteManager.UnmutePlayer(player.AuthorizedSteamID.SteamId64.ToString(), 1);
|
||||
|
||||
/*
|
||||
if (mutedPlayers.Contains((int)player.Index))
|
||||
{
|
||||
if (mutedPlayers.TryTake(out int removedItem) && removedItem != (int)player.Index)
|
||||
{
|
||||
mutedPlayers.Add(removedItem);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
player.VoiceFlags = VoiceFlags.Normal;
|
||||
}, CounterStrikeSharp.API.Modules.Timers.TimerFlags.STOP_ON_MAPCHANGE);
|
||||
}
|
||||
|
||||
if (time == 0)
|
||||
{
|
||||
player!.PrintToCenter(_localizer!["sa_player_mute_message_perm", reason, caller == null ? "Console" : caller.PlayerName]);
|
||||
|
||||
if (caller == null || caller != null && caller.UserId != null && !silentPlayers.Contains((ushort)caller.UserId))
|
||||
{
|
||||
StringBuilder sb = new(_localizer!["sa_prefix"]);
|
||||
sb.Append(_localizer["sa_admin_mute_message_perm", caller == null ? "Console" : caller.PlayerName, player.PlayerName, reason]);
|
||||
Server.PrintToChatAll(sb.ToString());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
player!.PrintToCenter(_localizer!["sa_player_mute_message_time", reason, time, caller == null ? "Console" : caller.PlayerName]);
|
||||
|
||||
if (caller == null || caller != null && caller.UserId != null && !silentPlayers.Contains((ushort)caller.UserId))
|
||||
{
|
||||
StringBuilder sb = new(_localizer!["sa_prefix"]);
|
||||
sb.Append(_localizer["sa_admin_mute_message_time", caller == null ? "Console" : caller.PlayerName, player.PlayerName, reason, time]);
|
||||
Server.PrintToChatAll(sb.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[ConsoleCommand("css_addmute")]
|
||||
[RequiresPermissions("@css/chat")]
|
||||
[CommandHelper(minArgs: 1, usage: "<steamid> [time in minutes/0 perm] [reason]", whoCanExecute: CommandUsage.CLIENT_AND_SERVER)]
|
||||
@@ -1098,59 +1112,67 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
||||
{
|
||||
if (caller!.CanTarget(player))
|
||||
{
|
||||
if (player.PawnIsAlive)
|
||||
{
|
||||
player.Pawn.Value!.Freeze();
|
||||
player.CommitSuicide(true, true);
|
||||
}
|
||||
|
||||
PlayerInfo playerInfo = new PlayerInfo
|
||||
{
|
||||
SteamId = player?.AuthorizedSteamID?.SteamId64.ToString(),
|
||||
Name = player?.PlayerName,
|
||||
IpAddress = player?.IpAddress?.Split(":")[0]
|
||||
};
|
||||
|
||||
PlayerInfo adminInfo = new PlayerInfo
|
||||
{
|
||||
SteamId = caller?.AuthorizedSteamID?.SteamId64.ToString(),
|
||||
Name = caller?.PlayerName,
|
||||
IpAddress = caller?.IpAddress?.Split(":")[0]
|
||||
};
|
||||
|
||||
Task.Run(async () =>
|
||||
{
|
||||
await _banManager.BanPlayer(playerInfo, adminInfo, reason, time);
|
||||
});
|
||||
|
||||
AddTimer(Config.KickTime, () => Helper.KickPlayer((ushort)player!.UserId!));
|
||||
|
||||
if (time == 0)
|
||||
{
|
||||
player!.PrintToCenter(_localizer!["sa_player_ban_message_perm", reason, caller == null ? "Console" : caller.PlayerName]);
|
||||
|
||||
if (caller == null || caller != null && caller.UserId != null && !silentPlayers.Contains((ushort)caller.UserId))
|
||||
{
|
||||
StringBuilder sb = new(_localizer!["sa_prefix"]);
|
||||
sb.Append(_localizer["sa_admin_ban_message_perm", caller == null ? "Console" : caller.PlayerName, player.PlayerName, reason]);
|
||||
Server.PrintToChatAll(sb.ToString());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
player!.PrintToCenter(_localizer!["sa_player_ban_message_time", reason, time, caller == null ? "Console" : caller.PlayerName]);
|
||||
|
||||
if (caller == null || caller != null && caller.UserId != null && !silentPlayers.Contains((ushort)caller.UserId))
|
||||
{
|
||||
StringBuilder sb = new(_localizer!["sa_prefix"]);
|
||||
sb.Append(_localizer["sa_admin_ban_message_time", caller == null ? "Console" : caller.PlayerName, player.PlayerName, reason, time]);
|
||||
Server.PrintToChatAll(sb.ToString());
|
||||
}
|
||||
}
|
||||
Ban(caller, player, time, reason, _banManager);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void Ban(CCSPlayerController? caller, CCSPlayerController player, int time, string reason = null, BanManager banManager = null)
|
||||
{
|
||||
reason ??= "Unknown";
|
||||
banManager ??= new(dbConnectionString, Config);
|
||||
|
||||
if (player.PawnIsAlive)
|
||||
{
|
||||
player.Pawn.Value!.Freeze();
|
||||
player.CommitSuicide(true, true);
|
||||
}
|
||||
|
||||
PlayerInfo playerInfo = new PlayerInfo
|
||||
{
|
||||
SteamId = player?.AuthorizedSteamID?.SteamId64.ToString(),
|
||||
Name = player?.PlayerName,
|
||||
IpAddress = player?.IpAddress?.Split(":")[0]
|
||||
};
|
||||
|
||||
PlayerInfo adminInfo = new PlayerInfo
|
||||
{
|
||||
SteamId = caller?.AuthorizedSteamID?.SteamId64.ToString(),
|
||||
Name = caller?.PlayerName,
|
||||
IpAddress = caller?.IpAddress?.Split(":")[0]
|
||||
};
|
||||
|
||||
Task.Run(async () =>
|
||||
{
|
||||
await banManager.BanPlayer(playerInfo, adminInfo, reason, time);
|
||||
});
|
||||
|
||||
AddTimer(Config.KickTime, () => Helper.KickPlayer((ushort)player!.UserId!));
|
||||
|
||||
if (time == 0)
|
||||
{
|
||||
player!.PrintToCenter(_localizer!["sa_player_ban_message_perm", reason, caller == null ? "Console" : caller.PlayerName]);
|
||||
|
||||
if (caller == null || caller != null && caller.UserId != null && !silentPlayers.Contains((ushort)caller.UserId))
|
||||
{
|
||||
StringBuilder sb = new(_localizer!["sa_prefix"]);
|
||||
sb.Append(_localizer["sa_admin_ban_message_perm", caller == null ? "Console" : caller.PlayerName, player.PlayerName, reason]);
|
||||
Server.PrintToChatAll(sb.ToString());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
player!.PrintToCenter(_localizer!["sa_player_ban_message_time", reason, time, caller == null ? "Console" : caller.PlayerName]);
|
||||
|
||||
if (caller == null || caller != null && caller.UserId != null && !silentPlayers.Contains((ushort)caller.UserId))
|
||||
{
|
||||
StringBuilder sb = new(_localizer!["sa_prefix"]);
|
||||
sb.Append(_localizer["sa_admin_ban_message_time", caller == null ? "Console" : caller.PlayerName, player.PlayerName, reason, time]);
|
||||
Server.PrintToChatAll(sb.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[ConsoleCommand("css_addban")]
|
||||
[RequiresPermissions("@css/ban")]
|
||||
[CommandHelper(minArgs: 1, usage: "<steamid> [time in minutes/0 perm] [reason]", whoCanExecute: CommandUsage.CLIENT_AND_SERVER)]
|
||||
|
||||
@@ -44,13 +44,13 @@ namespace CS2_SimpleAdmin.Menus
|
||||
|
||||
if (hasBan)
|
||||
{
|
||||
options.Add(new ChatMenuOptionData("Ban", () => PlayersMenu.OpenMenu(admin, "Ban", (admin, player) => DurationMenu.OpenMenu(admin, "Ban", player, Ban))));
|
||||
options.Add(new ChatMenuOptionData("Ban", () => PlayersMenu.OpenMenu(admin, "Ban", (admin, player) => DurationMenu.OpenMenu(admin, "Ban", player, BanMenu))));
|
||||
}
|
||||
|
||||
if (hasChat)
|
||||
{
|
||||
options.Add(new ChatMenuOptionData("Gag", () => PlayersMenu.OpenMenu(admin, "Gag", (admin, player) => DurationMenu.OpenMenu(admin, "Gag", player, Gag))));
|
||||
options.Add(new ChatMenuOptionData("Mute", () => PlayersMenu.OpenMenu(admin, "Mute", (admin, player) => DurationMenu.OpenMenu(admin, "Mute", player, Mute))));
|
||||
options.Add(new ChatMenuOptionData("Gag", () => PlayersMenu.OpenMenu(admin, "Gag", (admin, player) => DurationMenu.OpenMenu(admin, "Gag", player, GagMenu))));
|
||||
options.Add(new ChatMenuOptionData("Mute", () => PlayersMenu.OpenMenu(admin, "Mute", (admin, player) => DurationMenu.OpenMenu(admin, "Mute", player, MuteMenu))));
|
||||
}
|
||||
|
||||
if (hasKick)
|
||||
@@ -110,19 +110,83 @@ namespace CS2_SimpleAdmin.Menus
|
||||
CS2_SimpleAdmin.Instance.Kick(admin, player);
|
||||
}
|
||||
|
||||
private static void Ban(CCSPlayerController admin, CCSPlayerController player, int duration)
|
||||
private static void BanMenu(CCSPlayerController admin, CCSPlayerController player, int duration)
|
||||
{
|
||||
// TODO: Ban
|
||||
CenterHtmlMenu menu = new CenterHtmlMenu($"Ban {player.PlayerName}");
|
||||
List<string> options = new()
|
||||
{
|
||||
"Hacking",
|
||||
"Voice Abuse",
|
||||
"Chat Abuse",
|
||||
"Admin disrespect",
|
||||
"Other"
|
||||
};
|
||||
|
||||
foreach (string option in options)
|
||||
{
|
||||
menu.AddMenuOption(option, (_, _) => { Ban(admin, player, duration, option); });
|
||||
}
|
||||
|
||||
MenuManager.OpenCenterHtmlMenu(CS2_SimpleAdmin.Instance, admin, menu);
|
||||
}
|
||||
|
||||
private static void Gag(CCSPlayerController admin, CCSPlayerController player, int duration)
|
||||
private static void Ban(CCSPlayerController admin, CCSPlayerController player, int duration, string reason)
|
||||
{
|
||||
// TODO: Gag
|
||||
CS2_SimpleAdmin.Instance.Ban(admin, player, duration, reason);
|
||||
}
|
||||
|
||||
private static void Mute(CCSPlayerController admin, CCSPlayerController player, int duration)
|
||||
private static void GagMenu(CCSPlayerController admin, CCSPlayerController player, int duration)
|
||||
{
|
||||
// TODO: Mute
|
||||
CenterHtmlMenu menu = new CenterHtmlMenu($"Gag {player.PlayerName}");
|
||||
List<string> options = new()
|
||||
{
|
||||
"Advertising",
|
||||
"Spamming",
|
||||
"Spectator camera abuse",
|
||||
"Hate",
|
||||
"Admin disrespect",
|
||||
"Other"
|
||||
};
|
||||
|
||||
foreach (string option in options)
|
||||
{
|
||||
menu.AddMenuOption(option, (_, _) => { Gag(admin, player, duration, option); });
|
||||
}
|
||||
|
||||
MenuManager.OpenCenterHtmlMenu(CS2_SimpleAdmin.Instance, admin, menu);
|
||||
}
|
||||
|
||||
private static void Gag(CCSPlayerController admin, CCSPlayerController player, int duration, string reason)
|
||||
{
|
||||
CS2_SimpleAdmin.Instance.Gag(admin, player, duration, reason);
|
||||
}
|
||||
|
||||
private static void MuteMenu(CCSPlayerController admin, CCSPlayerController player, int duration)
|
||||
{
|
||||
CenterHtmlMenu menu = new CenterHtmlMenu($"Mute {player.PlayerName}");
|
||||
List<string> options = new()
|
||||
{
|
||||
"Shouting",
|
||||
"Playing music",
|
||||
"Advertising",
|
||||
"Spamming",
|
||||
"Spectator camera abuse",
|
||||
"Hate",
|
||||
"Admin disrespect",
|
||||
"Other"
|
||||
};
|
||||
|
||||
foreach (string option in options)
|
||||
{
|
||||
menu.AddMenuOption(option, (_, _) => { Mute(admin, player, duration, option); });
|
||||
}
|
||||
|
||||
MenuManager.OpenCenterHtmlMenu(CS2_SimpleAdmin.Instance, admin, menu);
|
||||
}
|
||||
|
||||
private static void Mute(CCSPlayerController admin, CCSPlayerController player, int duration, string reason)
|
||||
{
|
||||
CS2_SimpleAdmin.Instance.Mute(admin, player, duration, reason);
|
||||
}
|
||||
|
||||
private static void ForceTeam(CCSPlayerController admin, CCSPlayerController player)
|
||||
|
||||
Reference in New Issue
Block a user