mirror of
https://github.com/daffyyyy/CS2-SimpleAdmin.git
synced 2026-03-10 08:31:44 +00:00
Last merge conflicts
This commit is contained in:
@@ -25,7 +25,7 @@ using CS2_SimpleAdmin.Menus;
|
|||||||
namespace CS2_SimpleAdmin;
|
namespace CS2_SimpleAdmin;
|
||||||
|
|
||||||
[MinimumApiVersion(159)]
|
[MinimumApiVersion(159)]
|
||||||
public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdminConfig>
|
public partial class CS2_SimpleAdmin: BasePlugin, IPluginConfig<CS2_SimpleAdminConfig>
|
||||||
{
|
{
|
||||||
public static CS2_SimpleAdmin Instance { get; private set; } = null;
|
public static CS2_SimpleAdmin Instance { get; private set; } = null;
|
||||||
|
|
||||||
@@ -44,9 +44,7 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
internal string dbConnectionString = string.Empty;
|
internal string dbConnectionString = string.Empty;
|
||||||
internal static Database? _database;
|
internal static Database? _database;
|
||||||
|
|
||||||
public static MemoryFunctionVoid<CBasePlayerController, CCSPlayerPawn, bool, bool> CBasePlayerController_SetPawnFunc = new(
|
public static MemoryFunctionVoid<CBasePlayerController, CCSPlayerPawn, bool, bool> CBasePlayerController_SetPawnFunc = new(RuntimeInformation.IsOSPlatform(OSPlatform.Linux) ? "\\x55\\x48\\x89\\xE5\\x41\\x57\\x41\\x56\\x41\\x55\\x41\\x54\\x49\\x89\\xFC\\x53\\x48\\x89\\xF3\\x48\\x81\\xEC\\xC8\\x00\\x00\\x00" : "\\x44\\x88\\x4C\\x24\\x2A\\x55\\x57");
|
||||||
RuntimeInformation.IsOSPlatform(OSPlatform.Linux) ? "\\x55\\x48\\x89\\xE5\\x41\\x57\\x41\\x56\\x41\\x55\\x41\\x54\\x49\\x89\\xFC\\x53\\x48\\x89\\xF3\\x48\\x81\\xEC\\xC8\\x00\\x00\\x00" : "\\x44\\x88\\x4C\\x24\\x2A\\x55\\x57"
|
|
||||||
);
|
|
||||||
|
|
||||||
public override string ModuleName => "CS2-SimpleAdmin";
|
public override string ModuleName => "CS2-SimpleAdmin";
|
||||||
public override string ModuleDescription => "Simple admin plugin for Counter-Strike 2 :)";
|
public override string ModuleDescription => "Simple admin plugin for Counter-Strike 2 :)";
|
||||||
@@ -81,7 +79,7 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
UserID = config.DatabaseUser,
|
UserID = config.DatabaseUser,
|
||||||
Password = config.DatabasePassword,
|
Password = config.DatabasePassword,
|
||||||
Port = (uint)config.DatabasePort,
|
Port = (uint)config.DatabasePort,
|
||||||
Pooling = true,
|
Pooling = true
|
||||||
};
|
};
|
||||||
|
|
||||||
dbConnectionString = builder.ConnectionString;
|
dbConnectionString = builder.ConnectionString;
|
||||||
@@ -91,9 +89,9 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
using (var connection = _database.GetConnection())
|
using (MySqlConnection connection = _database.GetConnection())
|
||||||
{
|
{
|
||||||
using var transaction = await connection.BeginTransactionAsync();
|
using MySqlTransaction transaction = await connection.BeginTransactionAsync();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
string sql = @"CREATE TABLE IF NOT EXISTS `sa_bans` (
|
string sql = @"CREATE TABLE IF NOT EXISTS `sa_bans` (
|
||||||
@@ -181,13 +179,14 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
[RequiresPermissions("@css/generic")]
|
[RequiresPermissions("@css/generic")]
|
||||||
public void OnAdminHelpCommand(CCSPlayerController? caller, CommandInfo command)
|
public void OnAdminHelpCommand(CCSPlayerController? caller, CommandInfo command)
|
||||||
{
|
{
|
||||||
if (caller == null || !caller.IsValid) return;
|
if (caller == null || !caller.IsValid)
|
||||||
|
return;
|
||||||
|
|
||||||
using (new WithTemporaryCulture(caller.GetLanguage()))
|
using (new WithTemporaryCulture(caller.GetLanguage()))
|
||||||
{
|
{
|
||||||
var splitMessage = _localizer!["sa_adminhelp"].ToString().Split(new[] { "\r\n", "\r", "\n" }, StringSplitOptions.None);
|
string[] splitMessage = _localizer!["sa_adminhelp"].ToString().Split(new[] { "\r\n", "\r", "\n" }, StringSplitOptions.None);
|
||||||
|
|
||||||
foreach (var line in splitMessage)
|
foreach (string line in splitMessage)
|
||||||
{
|
{
|
||||||
caller.PrintToChat(Helper.ReplaceTags($" {line}"));
|
caller.PrintToChat(Helper.ReplaceTags($" {line}"));
|
||||||
}
|
}
|
||||||
@@ -209,18 +208,21 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
[RequiresPermissions("@css/root")]
|
[RequiresPermissions("@css/root")]
|
||||||
public void OnAddAdminCommand(CCSPlayerController? caller, CommandInfo command)
|
public void OnAddAdminCommand(CCSPlayerController? caller, CommandInfo command)
|
||||||
{
|
{
|
||||||
if (_database == null) return;
|
if (_database == null)
|
||||||
|
return;
|
||||||
|
|
||||||
if (!Helper.IsValidSteamID64(command.GetArg(1)))
|
if (!Helper.IsValidSteamID64(command.GetArg(1)))
|
||||||
{
|
{
|
||||||
command.ReplyToCommand($"Invalid SteamID64.");
|
command.ReplyToCommand($"Invalid SteamID64.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (command.GetArg(2).Length <= 0)
|
if (command.GetArg(2).Length <= 0)
|
||||||
{
|
{
|
||||||
command.ReplyToCommand($"Invalid player name.");
|
command.ReplyToCommand($"Invalid player name.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!command.GetArg(3).Contains("@") && !command.GetArg(3).Contains("#"))
|
if (!command.GetArg(3).Contains("@") && !command.GetArg(3).Contains("#"))
|
||||||
{
|
{
|
||||||
command.ReplyToCommand($"Invalid flag or group.");
|
command.ReplyToCommand($"Invalid flag or group.");
|
||||||
@@ -247,7 +249,8 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
[RequiresPermissions("@css/root")]
|
[RequiresPermissions("@css/root")]
|
||||||
public void OnDelAdminCommand(CCSPlayerController? caller, CommandInfo command)
|
public void OnDelAdminCommand(CCSPlayerController? caller, CommandInfo command)
|
||||||
{
|
{
|
||||||
if (_database == null) return;
|
if (_database == null)
|
||||||
|
return;
|
||||||
|
|
||||||
if (!Helper.IsValidSteamID64(command.GetArg(1)))
|
if (!Helper.IsValidSteamID64(command.GetArg(1)))
|
||||||
{
|
{
|
||||||
@@ -263,7 +266,7 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
|
|
||||||
AddTimer(2, () =>
|
AddTimer(2, () =>
|
||||||
{
|
{
|
||||||
if (!string.IsNullOrEmpty(steamid) && SteamID.TryParse(steamid, out var steamId) && steamId != null)
|
if (!string.IsNullOrEmpty(steamid) && SteamID.TryParse(steamid, out SteamID? steamId) && steamId != null)
|
||||||
{
|
{
|
||||||
if (AdminSQLManager._adminCache.ContainsKey(steamId))
|
if (AdminSQLManager._adminCache.ContainsKey(steamId))
|
||||||
{
|
{
|
||||||
@@ -284,7 +287,8 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
[RequiresPermissions("@css/root")]
|
[RequiresPermissions("@css/root")]
|
||||||
public void OnRelAdminCommand(CCSPlayerController? caller, CommandInfo command)
|
public void OnRelAdminCommand(CCSPlayerController? caller, CommandInfo command)
|
||||||
{
|
{
|
||||||
if (_database == null) return;
|
if (_database == null)
|
||||||
|
return;
|
||||||
|
|
||||||
foreach (SteamID steamId in AdminSQLManager._adminCache.Keys.ToList())
|
foreach (SteamID steamId in AdminSQLManager._adminCache.Keys.ToList())
|
||||||
{
|
{
|
||||||
@@ -307,7 +311,8 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
[RequiresPermissions("@css/kick")]
|
[RequiresPermissions("@css/kick")]
|
||||||
public void OnHideCommand(CCSPlayerController? caller, CommandInfo command)
|
public void OnHideCommand(CCSPlayerController? caller, CommandInfo command)
|
||||||
{
|
{
|
||||||
if (caller == null) return;
|
if (caller == null)
|
||||||
|
return;
|
||||||
|
|
||||||
if (silentPlayers.Contains(caller.Slot))
|
if (silentPlayers.Contains(caller.Slot))
|
||||||
{
|
{
|
||||||
@@ -332,10 +337,7 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
if (Config.DiscordWebhook.Length > 0 && _localizer != null)
|
if (Config.DiscordWebhook.Length > 0 && _localizer != null)
|
||||||
_ = SendWebhookMessage($"{caller.PlayerName} is hidden now.");
|
_ = SendWebhookMessage($"{caller.PlayerName} is hidden now.");
|
||||||
});
|
});
|
||||||
Server.NextFrame(() =>
|
Server.NextFrame(() => { AddTimer(1.1f, () => { Server.ExecuteCommand("sv_disable_teamselect_menu 0"); }); });
|
||||||
{
|
|
||||||
AddTimer(1.1f, () => { Server.ExecuteCommand("sv_disable_teamselect_menu 0"); });
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -344,10 +346,12 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
[RequiresPermissions("@css/generic")]
|
[RequiresPermissions("@css/generic")]
|
||||||
public void OnWhoCommand(CCSPlayerController? caller, CommandInfo command)
|
public void OnWhoCommand(CCSPlayerController? caller, CommandInfo command)
|
||||||
{
|
{
|
||||||
if (_database == null) return;
|
if (_database == null)
|
||||||
|
return;
|
||||||
|
|
||||||
TargetResult? targets = GetTarget(command);
|
TargetResult? targets = GetTarget(command);
|
||||||
if (targets == null) return;
|
if (targets == null)
|
||||||
|
return;
|
||||||
List<CCSPlayerController> playersToTarget = targets!.Players.Where(player => caller!.CanTarget(player) && player != null && player.IsValid && !player.IsBot && !player.IsHLTV).ToList();
|
List<CCSPlayerController> playersToTarget = targets!.Players.Where(player => caller!.CanTarget(player) && player != null && player.IsValid && !player.IsBot && !player.IsHLTV).ToList();
|
||||||
|
|
||||||
Database database = new Database(dbConnectionString);
|
Database database = new Database(dbConnectionString);
|
||||||
@@ -420,25 +424,20 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
public void OnPlayersCommand(CCSPlayerController? caller, CommandInfo command)
|
public void OnPlayersCommand(CCSPlayerController? caller, CommandInfo command)
|
||||||
{
|
{
|
||||||
TargetResult? targets = GetTarget(command);
|
TargetResult? targets = GetTarget(command);
|
||||||
if (targets == null) return;
|
if (targets == null)
|
||||||
|
return;
|
||||||
List<CCSPlayerController> playersToTarget = targets!.Players.Where(player => caller!.CanTarget(player) && player != null && player.IsValid && player.Connected == PlayerConnectedState.PlayerConnected && !player.IsHLTV).ToList();
|
List<CCSPlayerController> playersToTarget = targets!.Players.Where(player => caller!.CanTarget(player) && player != null && player.IsValid && player.Connected == PlayerConnectedState.PlayerConnected && !player.IsHLTV).ToList();
|
||||||
|
|
||||||
if (caller != null)
|
if (caller != null)
|
||||||
{
|
{
|
||||||
caller!.PrintToConsole($"--------- PLAYER LIST ---------");
|
caller!.PrintToConsole($"--------- PLAYER LIST ---------");
|
||||||
playersToTarget.ForEach(player =>
|
playersToTarget.ForEach(player => { caller!.PrintToConsole($"• [#{player.UserId}] \"{player.PlayerName}\" (IP Address: \"{player.IpAddress?.Split(":")[0]}\" SteamID64: \"{player.AuthorizedSteamID?.SteamId64}\")"); });
|
||||||
{
|
|
||||||
caller!.PrintToConsole($"• [#{player.UserId}] \"{player.PlayerName}\" (IP Address: \"{player.IpAddress?.Split(":")[0]}\" SteamID64: \"{player.AuthorizedSteamID?.SteamId64}\")");
|
|
||||||
});
|
|
||||||
caller!.PrintToConsole($"--------- END PLAYER LIST ---------");
|
caller!.PrintToConsole($"--------- END PLAYER LIST ---------");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Server.PrintToConsole($"--------- PLAYER LIST ---------");
|
Server.PrintToConsole($"--------- PLAYER LIST ---------");
|
||||||
playersToTarget.ForEach(player =>
|
playersToTarget.ForEach(player => { Server.PrintToConsole($"• [#{player.UserId}] \"{player.PlayerName}\" (IP Address: \"{player.IpAddress?.Split(":")[0]}\" SteamID64: \"{player.AuthorizedSteamID?.SteamId64}\")"); });
|
||||||
{
|
|
||||||
Server.PrintToConsole($"• [#{player.UserId}] \"{player.PlayerName}\" (IP Address: \"{player.IpAddress?.Split(":")[0]}\" SteamID64: \"{player.AuthorizedSteamID?.SteamId64}\")");
|
|
||||||
});
|
|
||||||
Server.PrintToConsole($"--------- END PLAYER LIST ---------");
|
Server.PrintToConsole($"--------- END PLAYER LIST ---------");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -451,7 +450,8 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
string reason = null;
|
string reason = null;
|
||||||
|
|
||||||
TargetResult? targets = GetTarget(command);
|
TargetResult? targets = GetTarget(command);
|
||||||
if (targets == null) return;
|
if (targets == null)
|
||||||
|
return;
|
||||||
List<CCSPlayerController> playersToTarget = targets!.Players.Where(player => caller!.CanTarget(player) && player != null && player.IsValid).ToList();
|
List<CCSPlayerController> playersToTarget = targets!.Players.Where(player => caller!.CanTarget(player) && player != null && player.IsValid).ToList();
|
||||||
|
|
||||||
if (playersToTarget.Count > 1 && Config.DisableDangerousCommands || playersToTarget.Count == 0)
|
if (playersToTarget.Count > 1 && Config.DisableDangerousCommands || playersToTarget.Count == 0)
|
||||||
@@ -485,6 +485,7 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
{
|
{
|
||||||
player.PrintToCenter(_localizer!["sa_player_kick_message", reason, caller == null ? "Console" : caller.PlayerName]);
|
player.PrintToCenter(_localizer!["sa_player_kick_message", reason, caller == null ? "Console" : caller.PlayerName]);
|
||||||
}
|
}
|
||||||
|
|
||||||
AddTimer(Config.KickTime, () => Helper.KickPlayer((ushort)player.UserId!, reason), CounterStrikeSharp.API.Modules.Timers.TimerFlags.STOP_ON_MAPCHANGE);
|
AddTimer(Config.KickTime, () => Helper.KickPlayer((ushort)player.UserId!, reason), CounterStrikeSharp.API.Modules.Timers.TimerFlags.STOP_ON_MAPCHANGE);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -517,13 +518,15 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
[CommandHelper(minArgs: 1, usage: "<#userid or name> [time in minutes/0 perm] [reason]", whoCanExecute: CommandUsage.CLIENT_AND_SERVER)]
|
[CommandHelper(minArgs: 1, usage: "<#userid or name> [time in minutes/0 perm] [reason]", whoCanExecute: CommandUsage.CLIENT_AND_SERVER)]
|
||||||
public void OnGagCommand(CCSPlayerController? caller, CommandInfo command)
|
public void OnGagCommand(CCSPlayerController? caller, CommandInfo command)
|
||||||
{
|
{
|
||||||
if (_database == null) return;
|
if (_database == null)
|
||||||
|
return;
|
||||||
|
|
||||||
int time = 0;
|
int time = 0;
|
||||||
string reason = null;
|
string reason = null;
|
||||||
|
|
||||||
TargetResult? targets = GetTarget(command);
|
TargetResult? targets = GetTarget(command);
|
||||||
if (targets == null) return;
|
if (targets == null)
|
||||||
|
return;
|
||||||
List<CCSPlayerController> playersToTarget = targets!.Players.Where(player => caller!.CanTarget(player) && player != null && player.IsValid).ToList();
|
List<CCSPlayerController> playersToTarget = targets!.Players.Where(player => caller!.CanTarget(player) && player != null && player.IsValid).ToList();
|
||||||
|
|
||||||
if (playersToTarget.Count > 1 && Config.DisableDangerousCommands || playersToTarget.Count == 0)
|
if (playersToTarget.Count > 1 && Config.DisableDangerousCommands || playersToTarget.Count == 0)
|
||||||
@@ -592,6 +595,7 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
_player.PrintToChat(sb.ToString());
|
_player.PrintToChat(sb.ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Config.DiscordWebhook.Length > 0 && _localizer != null)
|
if (Config.DiscordWebhook.Length > 0 && _localizer != null)
|
||||||
{
|
{
|
||||||
LocalizedString localizedMessage = _localizer["sa_admin_gag_message_perm", caller == null ? "Console" : caller.PlayerName, player.PlayerName, reason];
|
LocalizedString localizedMessage = _localizer["sa_admin_gag_message_perm", caller == null ? "Console" : caller.PlayerName, player.PlayerName, reason];
|
||||||
@@ -617,6 +621,7 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
_player.PrintToChat(sb.ToString());
|
_player.PrintToChat(sb.ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Config.DiscordWebhook.Length > 0 && _localizer != null)
|
if (Config.DiscordWebhook.Length > 0 && _localizer != null)
|
||||||
{
|
{
|
||||||
LocalizedString localizedMessage = _localizer["sa_admin_gag_message_time", caller == null ? "Console" : caller.PlayerName, player.PlayerName, reason, time];
|
LocalizedString localizedMessage = _localizer["sa_admin_gag_message_time", caller == null ? "Console" : caller.PlayerName, player.PlayerName, reason, time];
|
||||||
@@ -625,18 +630,18 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
[ConsoleCommand("css_addgag")]
|
[ConsoleCommand("css_addgag")]
|
||||||
[RequiresPermissions("@css/chat")]
|
[RequiresPermissions("@css/chat")]
|
||||||
[CommandHelper(minArgs: 1, usage: "<steamid> [time in minutes/0 perm] [reason]", whoCanExecute: CommandUsage.CLIENT_AND_SERVER)]
|
[CommandHelper(minArgs: 1, usage: "<steamid> [time in minutes/0 perm] [reason]", whoCanExecute: CommandUsage.CLIENT_AND_SERVER)]
|
||||||
public void OnAddGagCommand(CCSPlayerController? caller, CommandInfo command)
|
public void OnAddGagCommand(CCSPlayerController? caller, CommandInfo command)
|
||||||
{
|
{
|
||||||
if (_database == null) return;
|
if (_database == null)
|
||||||
|
return;
|
||||||
if (command.ArgCount < 2)
|
if (command.ArgCount < 2)
|
||||||
return;
|
return;
|
||||||
if (string.IsNullOrEmpty(command.GetArg(1))) return;
|
if (string.IsNullOrEmpty(command.GetArg(1)))
|
||||||
|
return;
|
||||||
|
|
||||||
string steamid = command.GetArg(1);
|
string steamid = command.GetArg(1);
|
||||||
|
|
||||||
@@ -693,6 +698,7 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
_player.PrintToChat(sb.ToString());
|
_player.PrintToChat(sb.ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Config.DiscordWebhook.Length > 0 && _localizer != null)
|
if (Config.DiscordWebhook.Length > 0 && _localizer != null)
|
||||||
{
|
{
|
||||||
LocalizedString localizedMessage = _localizer["sa_admin_gag_message_perm", caller == null ? "Console" : caller.PlayerName, player.PlayerName, reason];
|
LocalizedString localizedMessage = _localizer["sa_admin_gag_message_perm", caller == null ? "Console" : caller.PlayerName, player.PlayerName, reason];
|
||||||
@@ -718,6 +724,7 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
_player.PrintToChat(sb.ToString());
|
_player.PrintToChat(sb.ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Config.DiscordWebhook.Length > 0 && _localizer != null)
|
if (Config.DiscordWebhook.Length > 0 && _localizer != null)
|
||||||
{
|
{
|
||||||
LocalizedString localizedMessage = _localizer["sa_admin_gag_message_time", caller == null ? "Console" : caller.PlayerName, player.PlayerName, reason, time];
|
LocalizedString localizedMessage = _localizer["sa_admin_gag_message_time", caller == null ? "Console" : caller.PlayerName, player.PlayerName, reason, time];
|
||||||
@@ -733,6 +740,7 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
gaggedPlayers.Add(player.Slot);
|
gaggedPlayers.Add(player.Slot);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_ = _muteManager.AddMuteBySteamid(steamid, adminInfo, reason, time, 0);
|
_ = _muteManager.AddMuteBySteamid(steamid, adminInfo, reason, time, 0);
|
||||||
command.ReplyToCommand($"Gagged player with steamid {steamid}.");
|
command.ReplyToCommand($"Gagged player with steamid {steamid}.");
|
||||||
}
|
}
|
||||||
@@ -742,7 +750,8 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
[CommandHelper(minArgs: 1, usage: "<steamid or name>", whoCanExecute: CommandUsage.CLIENT_AND_SERVER)]
|
[CommandHelper(minArgs: 1, usage: "<steamid or name>", whoCanExecute: CommandUsage.CLIENT_AND_SERVER)]
|
||||||
public void OnUngagCommand(CCSPlayerController? caller, CommandInfo command)
|
public void OnUngagCommand(CCSPlayerController? caller, CommandInfo command)
|
||||||
{
|
{
|
||||||
if (_database == null) return;
|
if (_database == null)
|
||||||
|
return;
|
||||||
|
|
||||||
if (command.GetArg(1).Length <= 1)
|
if (command.GetArg(1).Length <= 1)
|
||||||
{
|
{
|
||||||
@@ -797,6 +806,7 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (found)
|
if (found)
|
||||||
{
|
{
|
||||||
_ = _muteManager.UnmutePlayer(pattern, 0); // Unmute by type 0 (gag)
|
_ = _muteManager.UnmutePlayer(pattern, 0); // Unmute by type 0 (gag)
|
||||||
@@ -805,7 +815,8 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
}
|
}
|
||||||
|
|
||||||
TargetResult? targets = GetTarget(command);
|
TargetResult? targets = GetTarget(command);
|
||||||
if (targets == null) return;
|
if (targets == null)
|
||||||
|
return;
|
||||||
List<CCSPlayerController> playersToTarget = targets!.Players.Where(player => caller!.CanTarget(player) && player != null && player.IsValid).ToList();
|
List<CCSPlayerController> playersToTarget = targets!.Players.Where(player => caller!.CanTarget(player) && player != null && player.IsValid).ToList();
|
||||||
|
|
||||||
if (playersToTarget.Count > 1 && Config.DisableDangerousCommands || playersToTarget.Count == 0)
|
if (playersToTarget.Count > 1 && Config.DisableDangerousCommands || playersToTarget.Count == 0)
|
||||||
@@ -841,13 +852,15 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
[CommandHelper(minArgs: 1, usage: "<#userid or name> [time in minutes/0 perm] [reason]", whoCanExecute: CommandUsage.CLIENT_AND_SERVER)]
|
[CommandHelper(minArgs: 1, usage: "<#userid or name> [time in minutes/0 perm] [reason]", whoCanExecute: CommandUsage.CLIENT_AND_SERVER)]
|
||||||
public void OnMuteCommand(CCSPlayerController? caller, CommandInfo command)
|
public void OnMuteCommand(CCSPlayerController? caller, CommandInfo command)
|
||||||
{
|
{
|
||||||
if (_database == null) return;
|
if (_database == null)
|
||||||
|
return;
|
||||||
|
|
||||||
int time = 0;
|
int time = 0;
|
||||||
string reason = "Unknown";
|
string reason = "Unknown";
|
||||||
|
|
||||||
TargetResult? targets = GetTarget(command);
|
TargetResult? targets = GetTarget(command);
|
||||||
if (targets == null) return;
|
if (targets == null)
|
||||||
|
return;
|
||||||
List<CCSPlayerController> playersToTarget = targets!.Players.Where(player => caller!.CanTarget(player) && player != null && player.IsValid).ToList();
|
List<CCSPlayerController> playersToTarget = targets!.Players.Where(player => caller!.CanTarget(player) && player != null && player.IsValid).ToList();
|
||||||
|
|
||||||
if (playersToTarget.Count > 1 && Config.DisableDangerousCommands || playersToTarget.Count == 0)
|
if (playersToTarget.Count > 1 && Config.DisableDangerousCommands || playersToTarget.Count == 0)
|
||||||
@@ -917,6 +930,7 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
_player.PrintToChat(sb.ToString());
|
_player.PrintToChat(sb.ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Config.DiscordWebhook.Length > 0 && _localizer != null)
|
if (Config.DiscordWebhook.Length > 0 && _localizer != null)
|
||||||
{
|
{
|
||||||
LocalizedString localizedMessage = _localizer["sa_admin_mute_message_perm", caller == null ? "Console" : caller.PlayerName, player.PlayerName, reason];
|
LocalizedString localizedMessage = _localizer["sa_admin_mute_message_perm", caller == null ? "Console" : caller.PlayerName, player.PlayerName, reason];
|
||||||
@@ -930,6 +944,7 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
{
|
{
|
||||||
player!.PrintToCenter(_localizer!["sa_player_mute_message_time", reason, time, caller == null ? "Console" : caller.PlayerName]);
|
player!.PrintToCenter(_localizer!["sa_player_mute_message_time", reason, time, caller == null ? "Console" : caller.PlayerName]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (caller == null || caller != null && !silentPlayers.Contains(caller.Slot))
|
if (caller == null || caller != null && !silentPlayers.Contains(caller.Slot))
|
||||||
{
|
{
|
||||||
foreach (CCSPlayerController _player in Utilities.GetPlayers().Where(p => p != null && p.IsValid && p.Connected == PlayerConnectedState.PlayerConnected && !p.IsBot && !p.IsHLTV))
|
foreach (CCSPlayerController _player in Utilities.GetPlayers().Where(p => p != null && p.IsValid && p.Connected == PlayerConnectedState.PlayerConnected && !p.IsBot && !p.IsHLTV))
|
||||||
@@ -941,6 +956,7 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
_player.PrintToChat(sb.ToString());
|
_player.PrintToChat(sb.ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Config.DiscordWebhook.Length > 0 && _localizer != null)
|
if (Config.DiscordWebhook.Length > 0 && _localizer != null)
|
||||||
{
|
{
|
||||||
LocalizedString localizedMessage = _localizer["sa_admin_mute_message_time", caller == null ? "Console" : caller.PlayerName, player.PlayerName, reason, time];
|
LocalizedString localizedMessage = _localizer["sa_admin_mute_message_time", caller == null ? "Console" : caller.PlayerName, player.PlayerName, reason, time];
|
||||||
@@ -949,19 +965,19 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
[ConsoleCommand("css_addmute")]
|
[ConsoleCommand("css_addmute")]
|
||||||
[RequiresPermissions("@css/chat")]
|
[RequiresPermissions("@css/chat")]
|
||||||
[CommandHelper(minArgs: 1, usage: "<steamid> [time in minutes/0 perm] [reason]", whoCanExecute: CommandUsage.CLIENT_AND_SERVER)]
|
[CommandHelper(minArgs: 1, usage: "<steamid> [time in minutes/0 perm] [reason]", whoCanExecute: CommandUsage.CLIENT_AND_SERVER)]
|
||||||
public void OnAddMuteCommand(CCSPlayerController? caller, CommandInfo command)
|
public void OnAddMuteCommand(CCSPlayerController? caller, CommandInfo command)
|
||||||
{
|
{
|
||||||
if (_database == null) return;
|
if (_database == null)
|
||||||
|
return;
|
||||||
|
|
||||||
if (command.ArgCount < 2)
|
if (command.ArgCount < 2)
|
||||||
return;
|
return;
|
||||||
if (string.IsNullOrEmpty(command.GetArg(1))) return;
|
if (string.IsNullOrEmpty(command.GetArg(1)))
|
||||||
|
return;
|
||||||
|
|
||||||
string steamid = command.GetArg(1);
|
string steamid = command.GetArg(1);
|
||||||
|
|
||||||
@@ -1006,6 +1022,7 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
{
|
{
|
||||||
player!.PrintToCenter(_localizer!["sa_player_mute_message_perm", reason, caller == null ? "Console" : caller.PlayerName]);
|
player!.PrintToCenter(_localizer!["sa_player_mute_message_perm", reason, caller == null ? "Console" : caller.PlayerName]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (caller == null || caller != null && !silentPlayers.Contains(caller.Slot))
|
if (caller == null || caller != null && !silentPlayers.Contains(caller.Slot))
|
||||||
{
|
{
|
||||||
foreach (CCSPlayerController _player in Utilities.GetPlayers().Where(p => p != null && p.IsValid && p.Connected == PlayerConnectedState.PlayerConnected && !p.IsBot && !p.IsHLTV))
|
foreach (CCSPlayerController _player in Utilities.GetPlayers().Where(p => p != null && p.IsValid && p.Connected == PlayerConnectedState.PlayerConnected && !p.IsBot && !p.IsHLTV))
|
||||||
@@ -1017,6 +1034,7 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
_player.PrintToChat(sb.ToString());
|
_player.PrintToChat(sb.ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Config.DiscordWebhook.Length > 0 && _localizer != null)
|
if (Config.DiscordWebhook.Length > 0 && _localizer != null)
|
||||||
{
|
{
|
||||||
LocalizedString localizedMessage = _localizer["sa_admin_mute_message_perm", caller == null ? "Console" : caller.PlayerName, player.PlayerName, reason];
|
LocalizedString localizedMessage = _localizer["sa_admin_mute_message_perm", caller == null ? "Console" : caller.PlayerName, player.PlayerName, reason];
|
||||||
@@ -1030,6 +1048,7 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
{
|
{
|
||||||
player!.PrintToCenter(_localizer!["sa_player_mute_message_time", reason, time, caller == null ? "Console" : caller.PlayerName]);
|
player!.PrintToCenter(_localizer!["sa_player_mute_message_time", reason, time, caller == null ? "Console" : caller.PlayerName]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (caller == null || caller != null && !silentPlayers.Contains(caller.Slot))
|
if (caller == null || caller != null && !silentPlayers.Contains(caller.Slot))
|
||||||
{
|
{
|
||||||
foreach (CCSPlayerController _player in Utilities.GetPlayers().Where(p => p != null && p.IsValid && p.Connected == PlayerConnectedState.PlayerConnected && !p.IsBot && !p.IsHLTV))
|
foreach (CCSPlayerController _player in Utilities.GetPlayers().Where(p => p != null && p.IsValid && p.Connected == PlayerConnectedState.PlayerConnected && !p.IsBot && !p.IsHLTV))
|
||||||
@@ -1041,6 +1060,7 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
_player.PrintToChat(sb.ToString());
|
_player.PrintToChat(sb.ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Config.DiscordWebhook.Length > 0 && _localizer != null)
|
if (Config.DiscordWebhook.Length > 0 && _localizer != null)
|
||||||
{
|
{
|
||||||
LocalizedString localizedMessage = _localizer["sa_admin_mute_message_time", caller == null ? "Console" : caller.PlayerName, player.PlayerName, reason, time];
|
LocalizedString localizedMessage = _localizer["sa_admin_mute_message_time", caller == null ? "Console" : caller.PlayerName, player.PlayerName, reason, time];
|
||||||
@@ -1055,6 +1075,7 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_ = _muteManager.AddMuteBySteamid(steamid, adminInfo, reason, time, 1);
|
_ = _muteManager.AddMuteBySteamid(steamid, adminInfo, reason, time, 1);
|
||||||
command.ReplyToCommand($"Muted player with steamid {steamid}.");
|
command.ReplyToCommand($"Muted player with steamid {steamid}.");
|
||||||
}
|
}
|
||||||
@@ -1064,7 +1085,8 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
[CommandHelper(minArgs: 1, usage: "<steamid or name>", whoCanExecute: CommandUsage.CLIENT_AND_SERVER)]
|
[CommandHelper(minArgs: 1, usage: "<steamid or name>", whoCanExecute: CommandUsage.CLIENT_AND_SERVER)]
|
||||||
public void OnUnmuteCommand(CCSPlayerController? caller, CommandInfo command)
|
public void OnUnmuteCommand(CCSPlayerController? caller, CommandInfo command)
|
||||||
{
|
{
|
||||||
if (_database == null) return;
|
if (_database == null)
|
||||||
|
return;
|
||||||
|
|
||||||
if (command.GetArg(1).Length <= 1)
|
if (command.GetArg(1).Length <= 1)
|
||||||
{
|
{
|
||||||
@@ -1178,7 +1200,8 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
string reason = "Unknown";
|
string reason = "Unknown";
|
||||||
|
|
||||||
TargetResult? targets = GetTarget(command);
|
TargetResult? targets = GetTarget(command);
|
||||||
if (targets == null) return;
|
if (targets == null)
|
||||||
|
return;
|
||||||
List<CCSPlayerController> playersToTarget = targets!.Players.Where(player => caller!.CanTarget(player) && player != null && player.IsValid).ToList();
|
List<CCSPlayerController> playersToTarget = targets!.Players.Where(player => caller!.CanTarget(player) && player != null && player.IsValid).ToList();
|
||||||
|
|
||||||
if (playersToTarget.Count > 1 && Config.DisableDangerousCommands || playersToTarget.Count == 0)
|
if (playersToTarget.Count > 1 && Config.DisableDangerousCommands || playersToTarget.Count == 0)
|
||||||
@@ -1256,6 +1279,7 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
_player.PrintToChat(sb.ToString());
|
_player.PrintToChat(sb.ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Config.DiscordWebhook.Length > 0 && _localizer != null)
|
if (Config.DiscordWebhook.Length > 0 && _localizer != null)
|
||||||
{
|
{
|
||||||
LocalizedString localizedMessage = _localizer["sa_admin_ban_message_perm", caller == null ? "Console" : caller.PlayerName, player.PlayerName, reason];
|
LocalizedString localizedMessage = _localizer["sa_admin_ban_message_perm", caller == null ? "Console" : caller.PlayerName, player.PlayerName, reason];
|
||||||
@@ -1269,6 +1293,7 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
{
|
{
|
||||||
player!.PrintToCenter(_localizer!["sa_player_ban_message_time", reason, time, caller == null ? "Console" : caller.PlayerName]);
|
player!.PrintToCenter(_localizer!["sa_player_ban_message_time", reason, time, caller == null ? "Console" : caller.PlayerName]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (caller == null || caller != null && !silentPlayers.Contains(caller.Slot))
|
if (caller == null || caller != null && !silentPlayers.Contains(caller.Slot))
|
||||||
{
|
{
|
||||||
foreach (CCSPlayerController _player in Utilities.GetPlayers().Where(p => p != null && p.IsValid && p.Connected == PlayerConnectedState.PlayerConnected && !p.IsBot && !p.IsHLTV))
|
foreach (CCSPlayerController _player in Utilities.GetPlayers().Where(p => p != null && p.IsValid && p.Connected == PlayerConnectedState.PlayerConnected && !p.IsBot && !p.IsHLTV))
|
||||||
@@ -1280,6 +1305,7 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
_player.PrintToChat(sb.ToString());
|
_player.PrintToChat(sb.ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Config.DiscordWebhook.Length > 0 && _localizer != null)
|
if (Config.DiscordWebhook.Length > 0 && _localizer != null)
|
||||||
{
|
{
|
||||||
LocalizedString localizedMessage = _localizer["sa_admin_ban_message_time", caller == null ? "Console" : caller.PlayerName, player.PlayerName, reason, time];
|
LocalizedString localizedMessage = _localizer["sa_admin_ban_message_time", caller == null ? "Console" : caller.PlayerName, player.PlayerName, reason, time];
|
||||||
@@ -1288,8 +1314,6 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
[ConsoleCommand("css_addban")]
|
[ConsoleCommand("css_addban")]
|
||||||
[RequiresPermissions("@css/ban")]
|
[RequiresPermissions("@css/ban")]
|
||||||
@@ -1298,7 +1322,8 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
{
|
{
|
||||||
if (command.ArgCount < 2)
|
if (command.ArgCount < 2)
|
||||||
return;
|
return;
|
||||||
if (string.IsNullOrEmpty(command.GetArg(1))) return;
|
if (string.IsNullOrEmpty(command.GetArg(1)))
|
||||||
|
return;
|
||||||
|
|
||||||
string steamid = command.GetArg(1);
|
string steamid = command.GetArg(1);
|
||||||
|
|
||||||
@@ -1348,6 +1373,7 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
{
|
{
|
||||||
player!.PrintToCenter(_localizer!["sa_player_ban_message_perm", reason, caller == null ? "Console" : caller.PlayerName]);
|
player!.PrintToCenter(_localizer!["sa_player_ban_message_perm", reason, caller == null ? "Console" : caller.PlayerName]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (caller == null || caller != null && !silentPlayers.Contains(caller.Slot))
|
if (caller == null || caller != null && !silentPlayers.Contains(caller.Slot))
|
||||||
{
|
{
|
||||||
foreach (CCSPlayerController _player in Utilities.GetPlayers().Where(p => p != null && p.IsValid && p.Connected == PlayerConnectedState.PlayerConnected && !p.IsBot && !p.IsHLTV))
|
foreach (CCSPlayerController _player in Utilities.GetPlayers().Where(p => p != null && p.IsValid && p.Connected == PlayerConnectedState.PlayerConnected && !p.IsBot && !p.IsHLTV))
|
||||||
@@ -1359,6 +1385,7 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
_player.PrintToChat(sb.ToString());
|
_player.PrintToChat(sb.ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Config.DiscordWebhook.Length > 0 && _localizer != null)
|
if (Config.DiscordWebhook.Length > 0 && _localizer != null)
|
||||||
{
|
{
|
||||||
LocalizedString localizedMessage = _localizer["sa_admin_ban_message_perm", caller == null ? "Console" : caller.PlayerName, player.PlayerName, reason];
|
LocalizedString localizedMessage = _localizer["sa_admin_ban_message_perm", caller == null ? "Console" : caller.PlayerName, player.PlayerName, reason];
|
||||||
@@ -1384,6 +1411,7 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
_player.PrintToChat(sb.ToString());
|
_player.PrintToChat(sb.ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Config.DiscordWebhook.Length > 0 && _localizer != null)
|
if (Config.DiscordWebhook.Length > 0 && _localizer != null)
|
||||||
{
|
{
|
||||||
LocalizedString localizedMessage = _localizer["sa_admin_ban_message_time", caller == null ? "Console" : caller.PlayerName, player.PlayerName, reason, time];
|
LocalizedString localizedMessage = _localizer["sa_admin_ban_message_time", caller == null ? "Console" : caller.PlayerName, player.PlayerName, reason, time];
|
||||||
@@ -1412,7 +1440,8 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
{
|
{
|
||||||
if (command.ArgCount < 2)
|
if (command.ArgCount < 2)
|
||||||
return;
|
return;
|
||||||
if (string.IsNullOrEmpty(command.GetArg(1))) return;
|
if (string.IsNullOrEmpty(command.GetArg(1)))
|
||||||
|
return;
|
||||||
|
|
||||||
string ipAddress = command.GetArg(1);
|
string ipAddress = command.GetArg(1);
|
||||||
|
|
||||||
@@ -1469,6 +1498,7 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
_player.PrintToChat(sb.ToString());
|
_player.PrintToChat(sb.ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Config.DiscordWebhook.Length > 0 && _localizer != null)
|
if (Config.DiscordWebhook.Length > 0 && _localizer != null)
|
||||||
{
|
{
|
||||||
LocalizedString localizedMessage = _localizer["sa_admin_ban_message_perm", caller == null ? "Console" : caller.PlayerName, player.PlayerName, reason];
|
LocalizedString localizedMessage = _localizer["sa_admin_ban_message_perm", caller == null ? "Console" : caller.PlayerName, player.PlayerName, reason];
|
||||||
@@ -1482,6 +1512,7 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
{
|
{
|
||||||
player!.PrintToCenter(_localizer!["sa_player_ban_message_time", reason, time, caller == null ? "Console" : caller.PlayerName]);
|
player!.PrintToCenter(_localizer!["sa_player_ban_message_time", reason, time, caller == null ? "Console" : caller.PlayerName]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (caller == null || caller != null && !silentPlayers.Contains(caller.Slot))
|
if (caller == null || caller != null && !silentPlayers.Contains(caller.Slot))
|
||||||
{
|
{
|
||||||
foreach (CCSPlayerController _player in Utilities.GetPlayers().Where(p => p != null && p.IsValid && p.Connected == PlayerConnectedState.PlayerConnected && !p.IsBot && !p.IsHLTV))
|
foreach (CCSPlayerController _player in Utilities.GetPlayers().Where(p => p != null && p.IsValid && p.Connected == PlayerConnectedState.PlayerConnected && !p.IsBot && !p.IsHLTV))
|
||||||
@@ -1493,6 +1524,7 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
_player.PrintToChat(sb.ToString());
|
_player.PrintToChat(sb.ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Config.DiscordWebhook.Length > 0 && _localizer != null)
|
if (Config.DiscordWebhook.Length > 0 && _localizer != null)
|
||||||
{
|
{
|
||||||
LocalizedString localizedMessage = _localizer["sa_admin_ban_message_time", caller == null ? "Console" : caller.PlayerName, player.PlayerName, reason, time];
|
LocalizedString localizedMessage = _localizer["sa_admin_ban_message_time", caller == null ? "Console" : caller.PlayerName, player.PlayerName, reason, time];
|
||||||
@@ -1546,13 +1578,11 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
public void OnSlayCommand(CCSPlayerController? caller, CommandInfo command)
|
public void OnSlayCommand(CCSPlayerController? caller, CommandInfo command)
|
||||||
{
|
{
|
||||||
TargetResult? targets = GetTarget(command);
|
TargetResult? targets = GetTarget(command);
|
||||||
if (targets == null) return;
|
if (targets == null)
|
||||||
|
return;
|
||||||
List<CCSPlayerController> playersToTarget = targets!.Players.Where(player => caller!.CanTarget(player) && player != null && player.IsValid && player.PawnIsAlive).ToList();
|
List<CCSPlayerController> playersToTarget = targets!.Players.Where(player => caller!.CanTarget(player) && player != null && player.IsValid && player.PawnIsAlive).ToList();
|
||||||
|
|
||||||
playersToTarget.ForEach(player =>
|
playersToTarget.ForEach(player => { Slay(caller, player); });
|
||||||
{
|
|
||||||
Slay(caller, player);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Slay(CCSPlayerController? caller, CCSPlayerController player)
|
public void Slay(CCSPlayerController? caller, CCSPlayerController player)
|
||||||
@@ -1565,19 +1595,18 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
{
|
{
|
||||||
using (new WithTemporaryCulture(_player.GetLanguage()))
|
using (new WithTemporaryCulture(_player.GetLanguage()))
|
||||||
{
|
{
|
||||||
|
|
||||||
StringBuilder sb = new(_localizer!["sa_prefix"]);
|
StringBuilder sb = new(_localizer!["sa_prefix"]);
|
||||||
sb.Append(_localizer["sa_admin_slay_message", caller == null ? "Console" : caller.PlayerName, player.PlayerName]);
|
sb.Append(_localizer["sa_admin_slay_message", caller == null ? "Console" : caller.PlayerName, player.PlayerName]);
|
||||||
_player.PrintToChat(sb.ToString());
|
_player.PrintToChat(sb.ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Config.DiscordWebhook.Length > 0 && _localizer != null)
|
if (Config.DiscordWebhook.Length > 0 && _localizer != null)
|
||||||
{
|
{
|
||||||
LocalizedString localizedMessage = _localizer["sa_admin_slay_message", caller == null ? "Console" : caller.PlayerName, player.PlayerName];
|
LocalizedString localizedMessage = _localizer["sa_admin_slay_message", caller == null ? "Console" : caller.PlayerName, player.PlayerName];
|
||||||
_ = SendWebhookMessage(localizedMessage.ToString().Replace("", "").Replace("", ""));
|
_ = SendWebhookMessage(localizedMessage.ToString().Replace("", "").Replace("", ""));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[ConsoleCommand("css_give")]
|
[ConsoleCommand("css_give")]
|
||||||
@@ -1586,7 +1615,8 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
public void OnGiveCommand(CCSPlayerController? caller, CommandInfo command)
|
public void OnGiveCommand(CCSPlayerController? caller, CommandInfo command)
|
||||||
{
|
{
|
||||||
TargetResult? targets = GetTarget(command);
|
TargetResult? targets = GetTarget(command);
|
||||||
if (targets == null) return;
|
if (targets == null)
|
||||||
|
return;
|
||||||
List<CCSPlayerController> playersToTarget = targets!.Players.Where(player => caller!.CanTarget(player) && player != null && player.IsValid && player.PawnIsAlive).ToList();
|
List<CCSPlayerController> playersToTarget = targets!.Players.Where(player => caller!.CanTarget(player) && player != null && player.IsValid && player.PawnIsAlive).ToList();
|
||||||
|
|
||||||
string weaponName = command.GetArg(2);
|
string weaponName = command.GetArg(2);
|
||||||
@@ -1630,6 +1660,7 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
_player.PrintToChat(sb.ToString());
|
_player.PrintToChat(sb.ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Config.DiscordWebhook.Length > 0 && _localizer != null)
|
if (Config.DiscordWebhook.Length > 0 && _localizer != null)
|
||||||
{
|
{
|
||||||
LocalizedString localizedMessage = _localizer["sa_admin_give_message", caller == null ? "Console" : caller.PlayerName, player.PlayerName, weaponName];
|
LocalizedString localizedMessage = _localizer["sa_admin_give_message", caller == null ? "Console" : caller.PlayerName, player.PlayerName, weaponName];
|
||||||
@@ -1645,7 +1676,8 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
public void OnStripCommand(CCSPlayerController? caller, CommandInfo command)
|
public void OnStripCommand(CCSPlayerController? caller, CommandInfo command)
|
||||||
{
|
{
|
||||||
TargetResult? targets = GetTarget(command);
|
TargetResult? targets = GetTarget(command);
|
||||||
if (targets == null) return;
|
if (targets == null)
|
||||||
|
return;
|
||||||
List<CCSPlayerController> playersToTarget = targets!.Players.Where(player => caller!.CanTarget(player) && player != null && player.IsValid && player.PawnIsAlive).ToList();
|
List<CCSPlayerController> playersToTarget = targets!.Players.Where(player => caller!.CanTarget(player) && player != null && player.IsValid && player.PawnIsAlive).ToList();
|
||||||
|
|
||||||
playersToTarget.ForEach(player =>
|
playersToTarget.ForEach(player =>
|
||||||
@@ -1666,6 +1698,7 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
_player.PrintToChat(sb.ToString());
|
_player.PrintToChat(sb.ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Config.DiscordWebhook.Length > 0 && _localizer != null)
|
if (Config.DiscordWebhook.Length > 0 && _localizer != null)
|
||||||
{
|
{
|
||||||
LocalizedString localizedMessage = _localizer["sa_admin_strip_message", caller == null ? "Console" : caller.PlayerName, player.PlayerName];
|
LocalizedString localizedMessage = _localizer["sa_admin_strip_message", caller == null ? "Console" : caller.PlayerName, player.PlayerName];
|
||||||
@@ -1685,7 +1718,8 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
int.TryParse(command.GetArg(2), out health);
|
int.TryParse(command.GetArg(2), out health);
|
||||||
|
|
||||||
TargetResult? targets = GetTarget(command);
|
TargetResult? targets = GetTarget(command);
|
||||||
if (targets == null) return;
|
if (targets == null)
|
||||||
|
return;
|
||||||
List<CCSPlayerController> playersToTarget = targets!.Players.Where(player => caller!.CanTarget(player) && player != null && player.IsValid && player.PawnIsAlive).ToList();
|
List<CCSPlayerController> playersToTarget = targets!.Players.Where(player => caller!.CanTarget(player) && player != null && player.IsValid && player.PawnIsAlive).ToList();
|
||||||
|
|
||||||
playersToTarget.ForEach(player =>
|
playersToTarget.ForEach(player =>
|
||||||
@@ -1706,6 +1740,7 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
_player.PrintToChat(sb.ToString());
|
_player.PrintToChat(sb.ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Config.DiscordWebhook.Length > 0 && _localizer != null)
|
if (Config.DiscordWebhook.Length > 0 && _localizer != null)
|
||||||
{
|
{
|
||||||
LocalizedString localizedMessage = _localizer["sa_admin_hp_message", caller == null ? "Console" : caller.PlayerName, player.PlayerName];
|
LocalizedString localizedMessage = _localizer["sa_admin_hp_message", caller == null ? "Console" : caller.PlayerName, player.PlayerName];
|
||||||
@@ -1725,7 +1760,8 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
double.TryParse(command.GetArg(2), out speed);
|
double.TryParse(command.GetArg(2), out speed);
|
||||||
|
|
||||||
TargetResult? targets = GetTarget(command);
|
TargetResult? targets = GetTarget(command);
|
||||||
if (targets == null) return;
|
if (targets == null)
|
||||||
|
return;
|
||||||
List<CCSPlayerController> playersToTarget = targets!.Players.Where(player => caller!.CanTarget(player) && player != null && player.IsValid && player.PawnIsAlive).ToList();
|
List<CCSPlayerController> playersToTarget = targets!.Players.Where(player => caller!.CanTarget(player) && player != null && player.IsValid && player.PawnIsAlive).ToList();
|
||||||
|
|
||||||
playersToTarget.ForEach(player =>
|
playersToTarget.ForEach(player =>
|
||||||
@@ -1750,6 +1786,7 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
_player.PrintToChat(sb.ToString());
|
_player.PrintToChat(sb.ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Config.DiscordWebhook.Length > 0 && _localizer != null)
|
if (Config.DiscordWebhook.Length > 0 && _localizer != null)
|
||||||
{
|
{
|
||||||
LocalizedString localizedMessage = _localizer["sa_admin_speed_message", caller == null ? "Console" : caller.PlayerName, player.PlayerName];
|
LocalizedString localizedMessage = _localizer["sa_admin_speed_message", caller == null ? "Console" : caller.PlayerName, player.PlayerName];
|
||||||
@@ -1766,7 +1803,8 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
public void OnGodCommand(CCSPlayerController? caller, CommandInfo command)
|
public void OnGodCommand(CCSPlayerController? caller, CommandInfo command)
|
||||||
{
|
{
|
||||||
TargetResult? targets = GetTarget(command);
|
TargetResult? targets = GetTarget(command);
|
||||||
if (targets == null) return;
|
if (targets == null)
|
||||||
|
return;
|
||||||
List<CCSPlayerController> playersToTarget = targets!.Players.Where(player => caller!.CanTarget(player) && player != null && player.IsValid && player.PawnIsAlive).ToList();
|
List<CCSPlayerController> playersToTarget = targets!.Players.Where(player => caller!.CanTarget(player) && player != null && player.IsValid && player.PawnIsAlive).ToList();
|
||||||
|
|
||||||
playersToTarget.ForEach(player =>
|
playersToTarget.ForEach(player =>
|
||||||
@@ -1796,6 +1834,7 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
_player.PrintToChat(sb.ToString());
|
_player.PrintToChat(sb.ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Config.DiscordWebhook.Length > 0 && _localizer != null)
|
if (Config.DiscordWebhook.Length > 0 && _localizer != null)
|
||||||
{
|
{
|
||||||
LocalizedString localizedMessage = _localizer["sa_admin_god_message", caller == null ? "Console" : caller.PlayerName, player.PlayerName];
|
LocalizedString localizedMessage = _localizer["sa_admin_god_message", caller == null ? "Console" : caller.PlayerName, player.PlayerName];
|
||||||
@@ -1815,7 +1854,8 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
int damage = 0;
|
int damage = 0;
|
||||||
|
|
||||||
TargetResult? targets = GetTarget(command);
|
TargetResult? targets = GetTarget(command);
|
||||||
if (targets == null) return;
|
if (targets == null)
|
||||||
|
return;
|
||||||
List<CCSPlayerController> playersToTarget = targets!.Players.Where(player => caller!.CanTarget(player) && player != null && player.IsValid && player.PawnIsAlive).ToList();
|
List<CCSPlayerController> playersToTarget = targets!.Players.Where(player => caller!.CanTarget(player) && player != null && player.IsValid && player.PawnIsAlive).ToList();
|
||||||
|
|
||||||
if (command.ArgCount >= 2)
|
if (command.ArgCount >= 2)
|
||||||
@@ -1826,6 +1866,13 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
playersToTarget.ForEach(player =>
|
playersToTarget.ForEach(player =>
|
||||||
{
|
{
|
||||||
if (caller!.CanTarget(player))
|
if (caller!.CanTarget(player))
|
||||||
|
{
|
||||||
|
Slap(caller, player, damage);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Slap(CCSPlayerController caller, CCSPlayerController player, int damage = 0)
|
||||||
{
|
{
|
||||||
player!.Pawn.Value!.Slap(damage);
|
player!.Pawn.Value!.Slap(damage);
|
||||||
|
|
||||||
@@ -1840,6 +1887,7 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
_player.PrintToChat(sb.ToString());
|
_player.PrintToChat(sb.ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Config.DiscordWebhook.Length > 0 && _localizer != null)
|
if (Config.DiscordWebhook.Length > 0 && _localizer != null)
|
||||||
{
|
{
|
||||||
LocalizedString localizedMessage = _localizer["sa_admin_slap_message", caller == null ? "Console" : caller.PlayerName, player.PlayerName];
|
LocalizedString localizedMessage = _localizer["sa_admin_slap_message", caller == null ? "Console" : caller.PlayerName, player.PlayerName];
|
||||||
@@ -1847,8 +1895,6 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
[ConsoleCommand("css_team")]
|
[ConsoleCommand("css_team")]
|
||||||
[RequiresPermissions("@css/kick")]
|
[RequiresPermissions("@css/kick")]
|
||||||
@@ -1860,7 +1906,8 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
CsTeam teamNum = CsTeam.Spectator;
|
CsTeam teamNum = CsTeam.Spectator;
|
||||||
|
|
||||||
TargetResult? targets = GetTarget(command);
|
TargetResult? targets = GetTarget(command);
|
||||||
if (targets == null) return;
|
if (targets == null)
|
||||||
|
return;
|
||||||
List<CCSPlayerController> playersToTarget = targets!.Players.Where(player => caller!.CanTarget(player) && player != null && player.IsValid).ToList();
|
List<CCSPlayerController> playersToTarget = targets!.Players.Where(player => caller!.CanTarget(player) && player != null && player.IsValid).ToList();
|
||||||
|
|
||||||
switch (teamName)
|
switch (teamName)
|
||||||
@@ -1927,6 +1974,7 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
_player.PrintToChat(sb.ToString());
|
_player.PrintToChat(sb.ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Config.DiscordWebhook.Length > 0 && _localizer != null)
|
if (Config.DiscordWebhook.Length > 0 && _localizer != null)
|
||||||
{
|
{
|
||||||
LocalizedString localizedMessage = _localizer["sa_admin_team_message", caller == null ? "Console" : caller.PlayerName, player.PlayerName, _teamName];
|
LocalizedString localizedMessage = _localizer["sa_admin_team_message", caller == null ? "Console" : caller.PlayerName, player.PlayerName, _teamName];
|
||||||
@@ -1967,6 +2015,7 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
{
|
{
|
||||||
voteMenu.AddMenuOption(command.GetArg(i), Helper.handleVotes);
|
voteMenu.AddMenuOption(command.GetArg(i), Helper.handleVotes);
|
||||||
}
|
}
|
||||||
|
|
||||||
Helper.PrintToCenterAll(_localizer!["sa_admin_vote_message", caller == null ? "Console" : caller.PlayerName, question]);
|
Helper.PrintToCenterAll(_localizer!["sa_admin_vote_message", caller == null ? "Console" : caller.PlayerName, question]);
|
||||||
StringBuilder sb = new(_localizer!["sa_prefix"]);
|
StringBuilder sb = new(_localizer!["sa_prefix"]);
|
||||||
sb.Append(_localizer["sa_admin_vote_message", caller == null ? "Console" : caller.PlayerName, question]);
|
sb.Append(_localizer["sa_admin_vote_message", caller == null ? "Console" : caller.PlayerName, question]);
|
||||||
@@ -1979,6 +2028,7 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
LocalizedString localizedMessage = _localizer["sa_admin_vote_message", caller == null ? "Console" : caller.PlayerName, question];
|
LocalizedString localizedMessage = _localizer["sa_admin_vote_message", caller == null ? "Console" : caller.PlayerName, question];
|
||||||
_ = SendWebhookMessage(localizedMessage.ToString().Replace("", "").Replace("", ""));
|
_ = SendWebhookMessage(localizedMessage.ToString().Replace("", "").Replace("", ""));
|
||||||
}
|
}
|
||||||
|
|
||||||
voteInProgress = true;
|
voteInProgress = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1995,6 +2045,7 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
_player.PrintToChat(sb.ToString());
|
_player.PrintToChat(sb.ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Config.DiscordWebhook.Length > 0 && _localizer != null)
|
if (Config.DiscordWebhook.Length > 0 && _localizer != null)
|
||||||
{
|
{
|
||||||
LocalizedString localizedMessage = _localizer["sa_admin_vote_message_results", question];
|
LocalizedString localizedMessage = _localizer["sa_admin_vote_message_results", question];
|
||||||
@@ -2012,12 +2063,14 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
_player.PrintToChat(sb.ToString());
|
_player.PrintToChat(sb.ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Config.DiscordWebhook.Length > 0 && _localizer != null)
|
if (Config.DiscordWebhook.Length > 0 && _localizer != null)
|
||||||
{
|
{
|
||||||
LocalizedString localizedMessage = _localizer["sa_admin_vote_message_results_answer", kvp.Key, kvp.Value];
|
LocalizedString localizedMessage = _localizer["sa_admin_vote_message_results_answer", kvp.Key, kvp.Value];
|
||||||
_ = SendWebhookMessage(localizedMessage.ToString().Replace("", "").Replace("", ""));
|
_ = SendWebhookMessage(localizedMessage.ToString().Replace("", "").Replace("", ""));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
voteAnswers.Clear();
|
voteAnswers.Clear();
|
||||||
votePlayers.Clear();
|
votePlayers.Clear();
|
||||||
voteInProgress = false;
|
voteInProgress = false;
|
||||||
@@ -2045,10 +2098,7 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
_command = $"ds_workshop_changelevel {map.Replace("ws:", "")}";
|
_command = $"ds_workshop_changelevel {map.Replace("ws:", "")}";
|
||||||
}
|
}
|
||||||
|
|
||||||
AddTimer(2.0f, () =>
|
AddTimer(2.0f, () => { Server.ExecuteCommand(_command); }, CounterStrikeSharp.API.Modules.Timers.TimerFlags.STOP_ON_MAPCHANGE);
|
||||||
{
|
|
||||||
Server.ExecuteCommand(_command);
|
|
||||||
}, CounterStrikeSharp.API.Modules.Timers.TimerFlags.STOP_ON_MAPCHANGE);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -2070,6 +2120,7 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
_player.PrintToChat(sb.ToString());
|
_player.PrintToChat(sb.ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Config.DiscordWebhook.Length > 0 && _localizer != null)
|
if (Config.DiscordWebhook.Length > 0 && _localizer != null)
|
||||||
{
|
{
|
||||||
LocalizedString localizedMessage = _localizer["sa_admin_changemap_message", caller == null ? "Console" : caller.PlayerName, map];
|
LocalizedString localizedMessage = _localizer["sa_admin_changemap_message", caller == null ? "Console" : caller.PlayerName, map];
|
||||||
@@ -2079,10 +2130,7 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
|
|
||||||
if (!map.StartsWith("ws:"))
|
if (!map.StartsWith("ws:"))
|
||||||
{
|
{
|
||||||
AddTimer(2.0f, () =>
|
AddTimer(2.0f, () => { Server.ExecuteCommand($"changelevel {map}"); }, CounterStrikeSharp.API.Modules.Timers.TimerFlags.STOP_ON_MAPCHANGE);
|
||||||
{
|
|
||||||
Server.ExecuteCommand($"changelevel {map}");
|
|
||||||
}, CounterStrikeSharp.API.Modules.Timers.TimerFlags.STOP_ON_MAPCHANGE);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2116,6 +2164,7 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
_player.PrintToChat(sb.ToString());
|
_player.PrintToChat(sb.ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Config.DiscordWebhook.Length > 0 && _localizer != null)
|
if (Config.DiscordWebhook.Length > 0 && _localizer != null)
|
||||||
{
|
{
|
||||||
LocalizedString localizedMessage = _localizer["sa_admin_changemap_message", caller == null ? "Console" : caller.PlayerName, map];
|
LocalizedString localizedMessage = _localizer["sa_admin_changemap_message", caller == null ? "Console" : caller.PlayerName, map];
|
||||||
@@ -2123,10 +2172,7 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
AddTimer(2.0f, () =>
|
AddTimer(2.0f, () => { Server.ExecuteCommand(_command); }, CounterStrikeSharp.API.Modules.Timers.TimerFlags.STOP_ON_MAPCHANGE);
|
||||||
{
|
|
||||||
Server.ExecuteCommand(_command);
|
|
||||||
}, CounterStrikeSharp.API.Modules.Timers.TimerFlags.STOP_ON_MAPCHANGE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[ConsoleCommand("css_asay", "Say to all admins.")]
|
[ConsoleCommand("css_asay", "Say to all admins.")]
|
||||||
@@ -2134,7 +2180,8 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
[RequiresPermissions("@css/chat")]
|
[RequiresPermissions("@css/chat")]
|
||||||
public void OnAdminToAdminSayCommand(CCSPlayerController? caller, CommandInfo command)
|
public void OnAdminToAdminSayCommand(CCSPlayerController? caller, CommandInfo command)
|
||||||
{
|
{
|
||||||
if (caller == null || !caller.IsValid || command.GetCommandString[command.GetCommandString.IndexOf(' ')..].Length == 0) return;
|
if (caller == null || !caller.IsValid || command.GetCommandString[command.GetCommandString.IndexOf(' ')..].Length == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
byte[] utf8BytesString = Encoding.UTF8.GetBytes(command.GetCommandString[command.GetCommandString.IndexOf(' ')..]);
|
byte[] utf8BytesString = Encoding.UTF8.GetBytes(command.GetCommandString[command.GetCommandString.IndexOf(' ')..]);
|
||||||
string utf8String = Encoding.UTF8.GetString(utf8BytesString);
|
string utf8String = Encoding.UTF8.GetString(utf8BytesString);
|
||||||
@@ -2158,7 +2205,8 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
[RequiresPermissions("@css/chat")]
|
[RequiresPermissions("@css/chat")]
|
||||||
public void OnAdminSayCommand(CCSPlayerController? caller, CommandInfo command)
|
public void OnAdminSayCommand(CCSPlayerController? caller, CommandInfo command)
|
||||||
{
|
{
|
||||||
if (command.GetCommandString[command.GetCommandString.IndexOf(' ')..].Length == 0) return;
|
if (command.GetCommandString[command.GetCommandString.IndexOf(' ')..].Length == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
byte[] utf8BytesString = Encoding.UTF8.GetBytes(command.GetCommandString[command.GetCommandString.IndexOf(' ')..]);
|
byte[] utf8BytesString = Encoding.UTF8.GetBytes(command.GetCommandString[command.GetCommandString.IndexOf(' ')..]);
|
||||||
string utf8String = Encoding.UTF8.GetString(utf8BytesString);
|
string utf8String = Encoding.UTF8.GetString(utf8BytesString);
|
||||||
@@ -2172,6 +2220,7 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
_player.PrintToChat(sb.ToString());
|
_player.PrintToChat(sb.ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Config.DiscordWebhook.Length > 0 && _localizer != null)
|
if (Config.DiscordWebhook.Length > 0 && _localizer != null)
|
||||||
_ = SendWebhookMessage($"ASAY: {caller!.PlayerName}: {utf8String}");
|
_ = SendWebhookMessage($"ASAY: {caller!.PlayerName}: {utf8String}");
|
||||||
}
|
}
|
||||||
@@ -2182,7 +2231,8 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
public void OnAdminPrivateSayCommand(CCSPlayerController? caller, CommandInfo command)
|
public void OnAdminPrivateSayCommand(CCSPlayerController? caller, CommandInfo command)
|
||||||
{
|
{
|
||||||
TargetResult? targets = GetTarget(command);
|
TargetResult? targets = GetTarget(command);
|
||||||
if (targets == null) return;
|
if (targets == null)
|
||||||
|
return;
|
||||||
List<CCSPlayerController> playersToTarget = targets!.Players.Where(player => player != null && player.IsValid).ToList();
|
List<CCSPlayerController> playersToTarget = targets!.Players.Where(player => player != null && player.IsValid).ToList();
|
||||||
|
|
||||||
int range = command.GetArg(0).Length + command.GetArg(1).Length + 2;
|
int range = command.GetArg(0).Length + command.GetArg(1).Length + 2;
|
||||||
@@ -2222,8 +2272,7 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
byte[] utf8BytesString = Encoding.UTF8.GetBytes(command.GetCommandString[command.GetCommandString.IndexOf(' ')..]);
|
byte[] utf8BytesString = Encoding.UTF8.GetBytes(command.GetCommandString[command.GetCommandString.IndexOf(' ')..]);
|
||||||
string utf8String = Encoding.UTF8.GetString(utf8BytesString);
|
string utf8String = Encoding.UTF8.GetString(utf8BytesString);
|
||||||
|
|
||||||
VirtualFunctions.ClientPrintAll(
|
VirtualFunctions.ClientPrintAll(HudDestination.Alert,
|
||||||
HudDestination.Alert,
|
|
||||||
Helper.ReplaceTags(utf8String),
|
Helper.ReplaceTags(utf8String),
|
||||||
0, 0, 0, 0);
|
0, 0, 0, 0);
|
||||||
|
|
||||||
@@ -2256,6 +2305,7 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
_player.PrintToChat(sb.ToString());
|
_player.PrintToChat(sb.ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Config.DiscordWebhook.Length > 0 && _localizer != null)
|
if (Config.DiscordWebhook.Length > 0 && _localizer != null)
|
||||||
{
|
{
|
||||||
LocalizedString localizedMessage = _localizer["sa_admin_noclip_message", caller == null ? "Console" : caller.PlayerName, player.PlayerName];
|
LocalizedString localizedMessage = _localizer["sa_admin_noclip_message", caller == null ? "Console" : caller.PlayerName, player.PlayerName];
|
||||||
@@ -2297,6 +2347,7 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
_player.PrintToChat(sb.ToString());
|
_player.PrintToChat(sb.ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Config.DiscordWebhook.Length > 0 && _localizer != null)
|
if (Config.DiscordWebhook.Length > 0 && _localizer != null)
|
||||||
{
|
{
|
||||||
LocalizedString localizedMessage = _localizer["sa_admin_freeze_message", caller == null ? "Console" : caller.PlayerName, player.PlayerName];
|
LocalizedString localizedMessage = _localizer["sa_admin_freeze_message", caller == null ? "Console" : caller.PlayerName, player.PlayerName];
|
||||||
@@ -2330,6 +2381,7 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
_player.PrintToChat(sb.ToString());
|
_player.PrintToChat(sb.ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Config.DiscordWebhook.Length > 0 && _localizer != null)
|
if (Config.DiscordWebhook.Length > 0 && _localizer != null)
|
||||||
{
|
{
|
||||||
LocalizedString localizedMessage = _localizer["sa_admin_unfreeze_message", caller == null ? "Console" : caller.PlayerName, player.PlayerName];
|
LocalizedString localizedMessage = _localizer["sa_admin_unfreeze_message", caller == null ? "Console" : caller.PlayerName, player.PlayerName];
|
||||||
@@ -2351,9 +2403,10 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
{
|
{
|
||||||
if (caller!.CanTarget(player))
|
if (caller!.CanTarget(player))
|
||||||
{
|
{
|
||||||
if (CBasePlayerController_SetPawnFunc == null || player.PlayerPawn.Value == null || !player.PlayerPawn.IsValid) return;
|
if (CBasePlayerController_SetPawnFunc == null || player.PlayerPawn.Value == null || !player.PlayerPawn.IsValid)
|
||||||
|
return;
|
||||||
|
|
||||||
var playerPawn = player.PlayerPawn.Value;
|
CCSPlayerPawn? playerPawn = player.PlayerPawn.Value;
|
||||||
CBasePlayerController_SetPawnFunc.Invoke(player, playerPawn, true, false);
|
CBasePlayerController_SetPawnFunc.Invoke(player, playerPawn, true, false);
|
||||||
VirtualFunction.CreateVoid<CCSPlayerController>(player.Handle,
|
VirtualFunction.CreateVoid<CCSPlayerController>(player.Handle,
|
||||||
GameData.GetOffset("CCSPlayerController_Respawn"))(player);
|
GameData.GetOffset("CCSPlayerController_Respawn"))(player);
|
||||||
@@ -2385,7 +2438,7 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
[RequiresPermissions("@css/cvar")]
|
[RequiresPermissions("@css/cvar")]
|
||||||
public void OnCvarCommand(CCSPlayerController? caller, CommandInfo command)
|
public void OnCvarCommand(CCSPlayerController? caller, CommandInfo command)
|
||||||
{
|
{
|
||||||
var cvar = ConVar.Find(command.GetArg(1));
|
ConVar? cvar = ConVar.Find(command.GetArg(1));
|
||||||
string playerName = caller == null ? "Console" : caller.PlayerName;
|
string playerName = caller == null ? "Console" : caller.PlayerName;
|
||||||
|
|
||||||
if (cvar == null)
|
if (cvar == null)
|
||||||
@@ -2400,7 +2453,7 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var value = command.GetArg(2);
|
string value = command.GetArg(2);
|
||||||
|
|
||||||
Server.ExecuteCommand($"{cvar.Name} {value}");
|
Server.ExecuteCommand($"{cvar.Name} {value}");
|
||||||
|
|
||||||
@@ -2445,17 +2498,17 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
|
|
||||||
public async Task SendWebhookMessage(string message)
|
public async Task SendWebhookMessage(string message)
|
||||||
{
|
{
|
||||||
using (var httpClient = new HttpClient())
|
using (HttpClient httpClient = new HttpClient())
|
||||||
{
|
{
|
||||||
var payload = new
|
var payload = new
|
||||||
{
|
{
|
||||||
content = message
|
content = message
|
||||||
};
|
};
|
||||||
|
|
||||||
var jsonPayload = JsonConvert.SerializeObject(payload);
|
string jsonPayload = JsonConvert.SerializeObject(payload);
|
||||||
var content = new StringContent(jsonPayload, Encoding.UTF8, "application/json");
|
StringContent content = new StringContent(jsonPayload, Encoding.UTF8, "application/json");
|
||||||
|
|
||||||
var response = await httpClient.PostAsync(Config.DiscordWebhook, content);
|
HttpResponseMessage response = await httpClient.PostAsync(Config.DiscordWebhook, content);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -95,9 +95,9 @@ namespace CS2_SimpleAdmin.Menus
|
|||||||
MenuManager.OpenCenterHtmlMenu(CS2_SimpleAdmin.Instance, admin, menu);
|
MenuManager.OpenCenterHtmlMenu(CS2_SimpleAdmin.Instance, admin, menu);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void ApplySlapAndKeepMenu(CCSPlayerController admin, CCSPlayerController player, int i)
|
private static void ApplySlapAndKeepMenu(CCSPlayerController admin, CCSPlayerController player, int damage)
|
||||||
{
|
{
|
||||||
CS2_SimpleAdmin.Instance.Slap(admin, player, i);
|
CS2_SimpleAdmin.Instance.Slap(admin, player, damage);
|
||||||
SlapMenu(admin, player);
|
SlapMenu(admin, player);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user