mirror of
https://github.com/daffyyyy/CS2-SimpleAdmin.git
synced 2026-03-06 23:27:24 +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)
|
public void OnGagCommand(CCSPlayerController? caller, CommandInfo command)
|
||||||
{
|
{
|
||||||
int time = 0;
|
int time = 0;
|
||||||
string reason = "Unknown";
|
string reason = null;
|
||||||
|
|
||||||
TargetResult? targets = GetTarget(command);
|
TargetResult? targets = GetTarget(command);
|
||||||
if (targets == null) return;
|
if (targets == null) return;
|
||||||
@@ -481,6 +481,16 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
{
|
{
|
||||||
if (caller!.CanTarget(player))
|
if (caller!.CanTarget(player))
|
||||||
{
|
{
|
||||||
|
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
|
PlayerInfo playerInfo = new PlayerInfo
|
||||||
{
|
{
|
||||||
SteamId = player?.AuthorizedSteamID?.SteamId64.ToString(),
|
SteamId = player?.AuthorizedSteamID?.SteamId64.ToString(),
|
||||||
@@ -497,7 +507,7 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
|
|
||||||
Task.Run(async () =>
|
Task.Run(async () =>
|
||||||
{
|
{
|
||||||
await _muteManager.MutePlayer(playerInfo, adminInfo, reason, time);
|
await muteManager.MutePlayer(playerInfo, adminInfo, reason, time);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (TagsDetected)
|
if (TagsDetected)
|
||||||
@@ -551,8 +561,6 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
[ConsoleCommand("css_addgag")]
|
[ConsoleCommand("css_addgag")]
|
||||||
[RequiresPermissions("@css/chat")]
|
[RequiresPermissions("@css/chat")]
|
||||||
@@ -765,7 +773,7 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
public void OnMuteCommand(CCSPlayerController? caller, CommandInfo command)
|
public void OnMuteCommand(CCSPlayerController? caller, CommandInfo command)
|
||||||
{
|
{
|
||||||
int time = 0;
|
int time = 0;
|
||||||
string reason = "Unknown";
|
string reason = null;
|
||||||
|
|
||||||
TargetResult? targets = GetTarget(command);
|
TargetResult? targets = GetTarget(command);
|
||||||
if (targets == null) return;
|
if (targets == null) return;
|
||||||
@@ -787,6 +795,16 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
{
|
{
|
||||||
if (caller!.CanTarget(player))
|
if (caller!.CanTarget(player))
|
||||||
{
|
{
|
||||||
|
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
|
PlayerInfo playerInfo = new PlayerInfo
|
||||||
{
|
{
|
||||||
SteamId = player?.AuthorizedSteamID?.SteamId64.ToString(),
|
SteamId = player?.AuthorizedSteamID?.SteamId64.ToString(),
|
||||||
@@ -808,17 +826,15 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
|
|
||||||
player!.VoiceFlags = VoiceFlags.Muted;
|
player!.VoiceFlags = VoiceFlags.Muted;
|
||||||
|
|
||||||
Task.Run(async () =>
|
Task.Run(async () => { await muteManager.MutePlayer(playerInfo, adminInfo, reason, time, 1); });
|
||||||
{
|
|
||||||
await _muteManager.MutePlayer(playerInfo, adminInfo, reason, time, 1);
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
if (time > 0 && time <= 30)
|
if (time > 0 && time <= 30)
|
||||||
{
|
{
|
||||||
AddTimer(time * 60, () =>
|
AddTimer(time * 60, () =>
|
||||||
{
|
{
|
||||||
if (player == null || !player.IsValid || player.AuthorizedSteamID == null) return;
|
if (player == null || !player.IsValid || player.AuthorizedSteamID == null)
|
||||||
|
return;
|
||||||
|
|
||||||
//MuteManager _muteManager = new(dbConnectionString);
|
//MuteManager _muteManager = new(dbConnectionString);
|
||||||
//_ = _muteManager.UnmutePlayer(player.AuthorizedSteamID.SteamId64.ToString(), 1);
|
//_ = _muteManager.UnmutePlayer(player.AuthorizedSteamID.SteamId64.ToString(), 1);
|
||||||
@@ -860,8 +876,6 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
[ConsoleCommand("css_addmute")]
|
[ConsoleCommand("css_addmute")]
|
||||||
[RequiresPermissions("@css/chat")]
|
[RequiresPermissions("@css/chat")]
|
||||||
@@ -1098,6 +1112,16 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
{
|
{
|
||||||
if (caller!.CanTarget(player))
|
if (caller!.CanTarget(player))
|
||||||
{
|
{
|
||||||
|
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)
|
if (player.PawnIsAlive)
|
||||||
{
|
{
|
||||||
player.Pawn.Value!.Freeze();
|
player.Pawn.Value!.Freeze();
|
||||||
@@ -1120,7 +1144,7 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
|
|
||||||
Task.Run(async () =>
|
Task.Run(async () =>
|
||||||
{
|
{
|
||||||
await _banManager.BanPlayer(playerInfo, adminInfo, reason, time);
|
await banManager.BanPlayer(playerInfo, adminInfo, reason, time);
|
||||||
});
|
});
|
||||||
|
|
||||||
AddTimer(Config.KickTime, () => Helper.KickPlayer((ushort)player!.UserId!));
|
AddTimer(Config.KickTime, () => Helper.KickPlayer((ushort)player!.UserId!));
|
||||||
@@ -1148,8 +1172,6 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
[ConsoleCommand("css_addban")]
|
[ConsoleCommand("css_addban")]
|
||||||
[RequiresPermissions("@css/ban")]
|
[RequiresPermissions("@css/ban")]
|
||||||
|
|||||||
@@ -44,13 +44,13 @@ namespace CS2_SimpleAdmin.Menus
|
|||||||
|
|
||||||
if (hasBan)
|
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)
|
if (hasChat)
|
||||||
{
|
{
|
||||||
options.Add(new ChatMenuOptionData("Gag", () => PlayersMenu.OpenMenu(admin, "Gag", (admin, player) => DurationMenu.OpenMenu(admin, "Gag", player, Gag))));
|
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, Mute))));
|
options.Add(new ChatMenuOptionData("Mute", () => PlayersMenu.OpenMenu(admin, "Mute", (admin, player) => DurationMenu.OpenMenu(admin, "Mute", player, MuteMenu))));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hasKick)
|
if (hasKick)
|
||||||
@@ -110,19 +110,83 @@ namespace CS2_SimpleAdmin.Menus
|
|||||||
CS2_SimpleAdmin.Instance.Kick(admin, player);
|
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); });
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void Gag(CCSPlayerController admin, CCSPlayerController player, int duration)
|
MenuManager.OpenCenterHtmlMenu(CS2_SimpleAdmin.Instance, admin, menu);
|
||||||
{
|
|
||||||
// TODO: Gag
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void Mute(CCSPlayerController admin, CCSPlayerController player, int duration)
|
private static void Ban(CCSPlayerController admin, CCSPlayerController player, int duration, string reason)
|
||||||
{
|
{
|
||||||
// TODO: Mute
|
CS2_SimpleAdmin.Instance.Ban(admin, player, duration, reason);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void GagMenu(CCSPlayerController admin, CCSPlayerController player, int duration)
|
||||||
|
{
|
||||||
|
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)
|
private static void ForceTeam(CCSPlayerController admin, CCSPlayerController player)
|
||||||
|
|||||||
Reference in New Issue
Block a user