🆕  **What's new and what's changed:**
```diff
+ Added `css_hidecomms` command - Disable showing penalties when player connect
+ Added customizable commands in `Commands.json` file in plugin config directory
  - U can disable command by removing aliases or rename/add more aliases (remember to not remove key, edit only Aliases)
+ Added missing `Console` translation `sa_console`
+ Added `LogCommand` to api
```
This commit is contained in:
Dawid Bepierszcz
2024-09-29 18:29:04 +02:00
parent 702a0315b8
commit 32520c7e84
19 changed files with 361 additions and 207 deletions

View File

@@ -1,5 +1,6 @@
using System.Diagnostics;
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Modules.Commands;
using CounterStrikeSharp.API.Modules.Entities;
using CS2_SimpleAdmin.Managers;
using CS2_SimpleAdminApi;
@@ -72,4 +73,14 @@ public class CS2_SimpleAdminApi : ICS2_SimpleAdminApi
throw new ArgumentOutOfRangeException(nameof(penaltyType), penaltyType, null);
}
}
public void LogCommand(CCSPlayerController? caller, string command)
{
Helper.LogCommand(caller, command);
}
public void LogCommand(CCSPlayerController? caller, CommandInfo command)
{
Helper.LogCommand(caller, command);
}
}

View File

@@ -1,6 +1,7 @@
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Core.Attributes;
using CounterStrikeSharp.API.Core.Capabilities;
using CounterStrikeSharp.API.Core.Commands;
using CounterStrikeSharp.API.Modules.Commands;
using CounterStrikeSharp.API.Modules.Commands.Targeting;
using CounterStrikeSharp.API.Modules.Memory.DynamicFunctions;
@@ -20,7 +21,7 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
public override string ModuleName => "CS2-SimpleAdmin" + (Helper.IsDebugBuild ? " (DEBUG)" : " (RELEASE)");
public override string ModuleDescription => "Simple admin plugin for Counter-Strike 2 :)";
public override string ModuleAuthor => "daffyy & Dliix66";
public override string ModuleVersion => "1.6.0a";
public override string ModuleVersion => "1.6.1a";
public CS2_SimpleAdminConfig Config { get; set; } = new();
@@ -60,6 +61,8 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
MenuApi = MenuCapability.Get();
if (MenuApi == null)
Logger.LogError("MenuManager Core not found...");
RegisterCommands.InitializeCommands();
}
public void OnConfigParsed(CS2_SimpleAdminConfig config)
@@ -71,7 +74,7 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
Instance = this;
_logger = Logger;
MySqlConnectionStringBuilder builder = new()
{
Server = config.DatabaseHost,
@@ -112,9 +115,6 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
PluginInfo.ShowAd(ModuleVersion);
if (Config.EnableUpdateCheck)
Task.Run(async () => await PluginInfo.CheckVersion(ModuleVersion, _logger));
AddCommand($"css_last{Config.OtherSettings.DisconnectedPlayersHistoryCount}",
"Show last x disconnected players", OnDisconnectedCommand);
}
private static TargetResult? GetTarget(CommandInfo command)

View File

@@ -0,0 +1,208 @@
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Modules.Commands;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
namespace CS2_SimpleAdmin;
public static class RegisterCommands
{
private delegate void CommandCallback(CCSPlayerController? caller, CommandInfo.CommandCallback callback);
private static readonly string CommandsPath = Path.Combine(CS2_SimpleAdmin.ConfigDirectory, "Commands.json");
private static readonly List<CommandMapping> CommandMappings =
[
new CommandMapping("css_ban", CS2_SimpleAdmin.Instance.OnBanCommand),
new CommandMapping("css_addban", CS2_SimpleAdmin.Instance.OnAddBanCommand),
new CommandMapping("css_banip", CS2_SimpleAdmin.Instance.OnBanIpCommand),
new CommandMapping("css_unban", CS2_SimpleAdmin.Instance.OnUnbanCommand),
new CommandMapping("css_warn", CS2_SimpleAdmin.Instance.OnWarnCommand),
new CommandMapping("css_unwarn", CS2_SimpleAdmin.Instance.OnUnwarnCommand),
new CommandMapping("css_asay", CS2_SimpleAdmin.Instance.OnAdminToAdminSayCommand),
new CommandMapping("css_cssay", CS2_SimpleAdmin.Instance.OnAdminCustomSayCommand),
new CommandMapping("css_say", CS2_SimpleAdmin.Instance.OnAdminSayCommand),
new CommandMapping("css_psay", CS2_SimpleAdmin.Instance.OnAdminPrivateSayCommand),
new CommandMapping("css_csay", CS2_SimpleAdmin.Instance.OnAdminCenterSayCommand),
new CommandMapping("css_hsay", CS2_SimpleAdmin.Instance.OnAdminHudSayCommand),
new CommandMapping("css_penalties", CS2_SimpleAdmin.Instance.OnPenaltiesCommand),
new CommandMapping("css_admin", CS2_SimpleAdmin.Instance.OnAdminCommand),
new CommandMapping("css_adminhelp", CS2_SimpleAdmin.Instance.OnAdminHelpCommand),
new CommandMapping("css_addadmin", CS2_SimpleAdmin.Instance.OnAddAdminCommand),
new CommandMapping("css_deladmin", CS2_SimpleAdmin.Instance.OnDelAdminCommand),
new CommandMapping("css_addgroup", CS2_SimpleAdmin.Instance.OnAddGroup),
new CommandMapping("css_delgroup", CS2_SimpleAdmin.Instance.OnDelGroupCommand),
new CommandMapping("css_reloadadmins", CS2_SimpleAdmin.Instance.OnRelAdminCommand),
new CommandMapping("css_hide", CS2_SimpleAdmin.Instance.OnHideCommand),
new CommandMapping("css_hidecomms", CS2_SimpleAdmin.Instance.OnHideCommsCommand),
new CommandMapping("css_who", CS2_SimpleAdmin.Instance.OnWhoCommand),
new CommandMapping("css_disconnected", CS2_SimpleAdmin.Instance.OnDisconnectedCommand),
new CommandMapping("css_warns", CS2_SimpleAdmin.Instance.OnWarnsCommand),
new CommandMapping("css_players", CS2_SimpleAdmin.Instance.OnPlayersCommand),
new CommandMapping("css_kick", CS2_SimpleAdmin.Instance.OnKickCommand),
new CommandMapping("css_map", CS2_SimpleAdmin.Instance.OnMapCommand),
new CommandMapping("css_wsmap", CS2_SimpleAdmin.Instance.OnWorkshopMapCommand),
new CommandMapping("css_cvar", CS2_SimpleAdmin.Instance.OnCvarCommand),
new CommandMapping("css_rcon", CS2_SimpleAdmin.Instance.OnRconCommand),
new CommandMapping("css_rr", CS2_SimpleAdmin.Instance.OnRestartCommand),
new CommandMapping("css_gag", CS2_SimpleAdmin.Instance.OnGagCommand),
new CommandMapping("css_addgag", CS2_SimpleAdmin.Instance.OnAddGagCommand),
new CommandMapping("css_ungag", CS2_SimpleAdmin.Instance.OnUngagCommand),
new CommandMapping("css_mute", CS2_SimpleAdmin.Instance.OnMuteCommand),
new CommandMapping("css_addmute", CS2_SimpleAdmin.Instance.OnAddMuteCommand),
new CommandMapping("css_unmute", CS2_SimpleAdmin.Instance.OnUnmuteCommand),
new CommandMapping("css_silence", CS2_SimpleAdmin.Instance.OnSilenceCommand),
new CommandMapping("css_addsilence", CS2_SimpleAdmin.Instance.OnAddSilenceCommand),
new CommandMapping("css_unsilence", CS2_SimpleAdmin.Instance.OnUnsilenceCommand),
new CommandMapping("css_vote", CS2_SimpleAdmin.Instance.OnVoteCommand),
new CommandMapping("css_noclip", CS2_SimpleAdmin.Instance.OnNoclipCommand),
new CommandMapping("css_freeze", CS2_SimpleAdmin.Instance.OnFreezeCommand),
new CommandMapping("css_unfreeze", CS2_SimpleAdmin.Instance.OnUnfreezeCommand),
new CommandMapping("css_godmode", CS2_SimpleAdmin.Instance.OnGodCommand),
new CommandMapping("css_slay", CS2_SimpleAdmin.Instance.OnSlayCommand),
new CommandMapping("css_slap", CS2_SimpleAdmin.Instance.OnSlapCommand),
new CommandMapping("css_give", CS2_SimpleAdmin.Instance.OnGiveCommand),
new CommandMapping("css_strip", CS2_SimpleAdmin.Instance.OnStripCommand),
new CommandMapping("css_hp", CS2_SimpleAdmin.Instance.OnHpCommand),
new CommandMapping("css_speed", CS2_SimpleAdmin.Instance.OnSpeedCommand),
new CommandMapping("css_gravity", CS2_SimpleAdmin.Instance.OnGravityCommand),
new CommandMapping("css_money", CS2_SimpleAdmin.Instance.OnMoneyCommand),
new CommandMapping("css_team", CS2_SimpleAdmin.Instance.OnTeamCommand),
new CommandMapping("css_rename", CS2_SimpleAdmin.Instance.OnRenameCommand),
new CommandMapping("css_prename", CS2_SimpleAdmin.Instance.OnPrenameCommand),
new CommandMapping("css_respawn", CS2_SimpleAdmin.Instance.OnRespawnCommand),
new CommandMapping("css_tp", CS2_SimpleAdmin.Instance.OnGotoCommand),
new CommandMapping("css_bring", CS2_SimpleAdmin.Instance.OnBringCommand)
];
public static void InitializeCommands()
{
if (!File.Exists(CommandsPath))
{
CreateConfig();
InitializeCommands();
}
else
{
Register();
}
}
private static void CreateConfig()
{
var commands = new CommandsConfig
{
Commands = new Dictionary<string, Command>
{
{ "css_ban", new Command { Aliases = ["css_ban"] } },
{ "css_addban", new Command { Aliases = ["css_addban"] } },
{ "css_banip", new Command { Aliases = ["css_banip"] } },
{ "css_unban", new Command { Aliases = ["css_unban"] } },
{ "css_warn", new Command { Aliases = ["css_warn"] } },
{ "css_unwarn", new Command { Aliases = ["css_unwarn"] } },
{ "css_asay", new Command { Aliases = ["css_asay"] } },
{ "css_cssay", new Command { Aliases = ["css_cssay"] } },
{ "css_say", new Command { Aliases = ["css_say"] } },
{ "css_psay", new Command { Aliases = ["css_psay"] } },
{ "css_csay", new Command { Aliases = ["css_csay"] } },
{ "css_hsay", new Command { Aliases = ["css_hsay"] } },
{ "css_penalties", new Command { Aliases = ["css_penalties", "css_mypenalties", "css_comms"] } },
{ "css_admin", new Command { Aliases = ["css_admin"] } },
{ "css_adminhelp", new Command { Aliases = ["css_adminhelp"] } },
{ "css_addadmin", new Command { Aliases = ["css_addadmin"] } },
{ "css_deladmin", new Command { Aliases = ["css_deladmin"] } },
{ "css_addgroup", new Command { Aliases = ["css_addgroup"] } },
{ "css_delgroup", new Command { Aliases = ["css_delgroup"] } },
{ "css_reloadadmins", new Command { Aliases = ["css_reloadadmins"] } },
{ "css_hide", new Command { Aliases = ["css_hide", "css_stealth"] } },
{ "css_hidecomms", new Command { Aliases = ["css_hidecomms"] } },
{ "css_who", new Command { Aliases = ["css_who"] } },
{ "css_disconnected", new Command { Aliases = ["css_disconnected", "css_last"] } },
{ "css_warns", new Command { Aliases = ["css_warns"] } },
{ "css_players", new Command { Aliases = ["css_players"] } },
{ "css_kick", new Command { Aliases = ["css_kick"] } },
{ "css_map", new Command { Aliases = ["css_map", "css_changemap"] } },
{ "css_wsmap", new Command { Aliases = ["css_wsmap", "css_changewsmap", "css_workshop"] } },
{ "css_cvar", new Command { Aliases = ["css_cvar"] } },
{ "css_rcon", new Command { Aliases = ["css_rcon"] } },
{ "css_rr", new Command { Aliases = ["css_rr", "css_rg", "css_restart", "css_restartgame"] } },
{ "css_gag", new Command { Aliases = ["css_gag"] } },
{ "css_addgag", new Command { Aliases = ["css_addgag"] } },
{ "css_ungag", new Command { Aliases = ["css_ungag"] } },
{ "css_mute", new Command { Aliases = ["css_mute"] } },
{ "css_addmute", new Command { Aliases = ["css_addmute"] } },
{ "css_unmute", new Command { Aliases = ["css_unmute"] } },
{ "css_silence", new Command { Aliases = ["css_silence"] } },
{ "css_addsilence", new Command { Aliases = ["css_addsilence"] } },
{ "css_unsilence", new Command { Aliases = ["css_unsilence"] } },
{ "css_vote", new Command { Aliases = ["css_vote"] } },
{ "css_noclip", new Command { Aliases = ["css_noclip"] } },
{ "css_freeze", new Command { Aliases = ["css_freeze"] } },
{ "css_unfreeze", new Command { Aliases = ["css_unfreeze"] } },
{ "css_godmode", new Command { Aliases = ["css_godmode"] } },
{ "css_slay", new Command { Aliases = ["css_slay"] } },
{ "css_slap", new Command { Aliases = ["css_slap"] } },
{ "css_give", new Command { Aliases = ["css_give"] } },
{ "css_strip", new Command { Aliases = ["css_strip"] } },
{ "css_hp", new Command { Aliases = ["css_hp"] } },
{ "css_speed", new Command { Aliases = ["css_speed"] } },
{ "css_gravity", new Command { Aliases = ["css_gravity"] } },
{ "css_money", new Command { Aliases = ["css_money"] } },
{ "css_team", new Command { Aliases = ["css_team"] } },
{ "css_rename", new Command { Aliases = ["css_rename"] } },
{ "css_prename", new Command { Aliases = ["css_prename"] } },
{ "css_respawn", new Command { Aliases = ["css_respawn"] } },
{ "css_tp", new Command { Aliases = ["css_tp", "css_tpto", "css_goto"] } },
{ "css_bring", new Command { Aliases = ["css_bring", "css_tphere"] } }
}
};
var json = JsonConvert.SerializeObject(commands, Formatting.Indented);
File.WriteAllText(CommandsPath, json);
}
private static void Register()
{
var json = File.ReadAllText(CommandsPath);
var commandsConfig = JsonConvert.DeserializeObject<CommandsConfig>(json);
if (commandsConfig?.Commands == null) return;
foreach (var command in commandsConfig.Commands)
{
if (command.Value.Aliases == null) continue;
CS2_SimpleAdmin._logger?.LogInformation(
$"Registering command: `{command.Key}` with aliases: `{string.Join(", ", command.Value.Aliases)}`");
var mapping = CommandMappings.FirstOrDefault(m => m.CommandKey == command.Key);
if (mapping == null || command.Value.Aliases.Length == 0) continue;
foreach (var alias in command.Value.Aliases)
{
CS2_SimpleAdmin.Instance.AddCommand(alias, "", mapping.Callback);
}
}
}
private class CommandsConfig
{
public Dictionary<string, Command>? Commands { get; init; }
}
private class Command
{
public string[]? Aliases { get; init; }
}
private class CommandMapping(string commandKey, CommandInfo.CommandCallback callback)
{
public string CommandKey { get; } = commandKey;
public CommandInfo.CommandCallback Callback { get; } = callback;
}
}

View File

@@ -12,12 +12,11 @@ namespace CS2_SimpleAdmin;
public partial class CS2_SimpleAdmin
{
[ConsoleCommand("css_ban")]
[RequiresPermissions("@css/ban")]
[CommandHelper(minArgs: 1, usage: "<#userid or name> [time in minutes/0 perm] [reason]", whoCanExecute: CommandUsage.CLIENT_AND_SERVER)]
public void OnBanCommand(CCSPlayerController? caller, CommandInfo command)
{
var callerName = caller == null ? "Console" : caller.PlayerName;
var callerName = caller == null ? _localizer?["sa_console"] ?? "Console" : caller.PlayerName;
if (command.ArgCount < 2)
return;
@@ -56,7 +55,7 @@ public partial class CS2_SimpleAdmin
if (!CheckValidBan(caller, time)) return;
// Set default caller name if not provided
callerName ??= "Console";
callerName ??= _localizer?["sa_console"] ?? "Console";
// Freeze player pawn if alive
if (player.PawnIsAlive)
@@ -128,13 +127,12 @@ public partial class CS2_SimpleAdmin
SimpleAdminApi?.OnPlayerPenaltiedEvent(playerInfo, adminInfo, PenaltyType.Ban, reason, time);
}
[ConsoleCommand("css_addban")]
[RequiresPermissions("@css/ban")]
[CommandHelper(minArgs: 1, usage: "<steamid> [time in minutes/0 perm] [reason]", whoCanExecute: CommandUsage.CLIENT_AND_SERVER)]
public void OnAddBanCommand(CCSPlayerController? caller, CommandInfo command)
{
if (Database == null) return;
var callerName = caller?.PlayerName ?? "Console";
var callerName = caller?.PlayerName ?? _localizer?["sa_console"] ?? "Console";
if (command.ArgCount < 2 || string.IsNullOrEmpty(command.GetArg(1))) return;
if (!Helper.ValidateSteamId(command.GetArg(1), out var steamId) || steamId == null)
{
@@ -185,13 +183,12 @@ public partial class CS2_SimpleAdmin
SimpleAdminApi?.OnPlayerPenaltiedAddedEvent(steamId, adminInfo, PenaltyType.Ban, reason, time);
}
[ConsoleCommand("css_banip")]
[RequiresPermissions("@css/ban")]
[CommandHelper(minArgs: 1, usage: "<ip> [time in minutes/0 perm] [reason]", whoCanExecute: CommandUsage.CLIENT_AND_SERVER)]
public void OnBanIpCommand(CCSPlayerController? caller, CommandInfo command)
{
if (Database == null) return;
var callerName = caller?.PlayerName ?? "Console";
var callerName = caller?.PlayerName ?? _localizer?["sa_console"] ?? "Console";
if (command.ArgCount < 2 || string.IsNullOrEmpty(command.GetArg(1))) return;
var ipAddress = command.GetArg(1);
@@ -255,14 +252,13 @@ public partial class CS2_SimpleAdmin
return false;
}
[ConsoleCommand("css_unban")]
[RequiresPermissions("@css/unban")]
[CommandHelper(minArgs: 1, usage: "<steamid or name or ip> [reason]", whoCanExecute: CommandUsage.CLIENT_AND_SERVER)]
public void OnUnbanCommand(CCSPlayerController? caller, CommandInfo command)
{
if (Database == null) return;
var callerSteamId = caller?.SteamID.ToString() ?? "Console";
var callerSteamId = caller?.SteamID.ToString() ?? _localizer?["sa_console"] ?? "Console";
if (command.GetArg(1).Length <= 1)
{
@@ -281,14 +277,13 @@ public partial class CS2_SimpleAdmin
command.ReplyToCommand($"Unbanned player with pattern {pattern}.");
}
[ConsoleCommand("css_warn")]
[RequiresPermissions("@css/kick")]
[CommandHelper(minArgs: 1, usage: "<#userid or name> [time in minutes/0 perm] [reason]", whoCanExecute: CommandUsage.CLIENT_AND_SERVER)]
public void OnWarnCommand(CCSPlayerController? caller, CommandInfo command)
{
if (Database == null)
return;
var callerName = caller == null ? "Console" : caller.PlayerName;
var callerName = caller == null ? _localizer?["sa_console"] ?? "Console" : caller.PlayerName;
if (command.ArgCount < 2)
return;
@@ -326,7 +321,7 @@ public partial class CS2_SimpleAdmin
if (!CheckValidBan(caller, time)) return;
// Set default caller name if not provided
callerName ??= "Console";
callerName ??= _localizer?["sa_console"] ?? "Console";
// Freeze player pawn if alive
if (player.PawnIsAlive)
@@ -395,14 +390,13 @@ public partial class CS2_SimpleAdmin
SimpleAdminApi?.OnPlayerPenaltiedEvent(playerInfo, adminInfo, PenaltyType.Warn, reason, time);
}
[ConsoleCommand("css_unwarn")]
[RequiresPermissions("@css/kick")]
[CommandHelper(minArgs: 1, usage: "<steamid or name or ip>", whoCanExecute: CommandUsage.CLIENT_AND_SERVER)]
public void OnUnwarnCommand(CCSPlayerController? caller, CommandInfo command)
{
if (Database == null) return;
var callerSteamId = caller?.SteamID.ToString() ?? "Console";
var callerSteamId = caller?.SteamID.ToString() ?? _localizer?["sa_console"] ?? "Console";
if (command.GetArg(1).Length <= 1)
{

View File

@@ -11,7 +11,6 @@ namespace CS2_SimpleAdmin;
public partial class CS2_SimpleAdmin
{
[ConsoleCommand("css_asay", "Say to all admins.")]
[CommandHelper(1, "<message>")]
[RequiresPermissions("@css/chat")]
public void OnAdminToAdminSayCommand(CCSPlayerController? caller, CommandInfo command)
@@ -26,12 +25,11 @@ public partial class CS2_SimpleAdmin
{
if (_localizer != null)
player.PrintToChat(_localizer["sa_adminchat_template_admin",
caller == null ? "Console" : caller.PlayerName,
caller == null ? _localizer?["sa_console"] ?? "Console" : caller.PlayerName,
utf8String]);
}
}
[ConsoleCommand("css_cssay", "Say custom text to all players - u can use color tags.")]
[CommandHelper(1, "<message>")]
[RequiresPermissions("@css/chat")]
public void OnAdminCustomSayCommand(CCSPlayerController? caller, CommandInfo command)
@@ -49,7 +47,6 @@ public partial class CS2_SimpleAdmin
}
}
[ConsoleCommand("css_say", "Say to all players.")]
[CommandHelper(1, "<message>")]
[RequiresPermissions("@css/chat")]
public void OnAdminSayCommand(CCSPlayerController? caller, CommandInfo command)
@@ -69,12 +66,11 @@ public partial class CS2_SimpleAdmin
}
}
[ConsoleCommand("css_psay", "Private message a player.")]
[CommandHelper(2, "<#userid or name> <message>")]
[RequiresPermissions("@css/chat")]
public void OnAdminPrivateSayCommand(CCSPlayerController? caller, CommandInfo command)
{
var callerName = caller == null ? "Console" : caller.PlayerName;
var callerName = caller == null ? _localizer?["sa_console"] ?? "Console" : caller.PlayerName;
var targets = GetTarget(command);
if (targets == null) return;
@@ -96,7 +92,6 @@ public partial class CS2_SimpleAdmin
command.ReplyToCommand($" Private message sent!");
}
[ConsoleCommand("css_csay", "Say to all players (in center).")]
[CommandHelper(1, "<message>")]
[RequiresPermissions("@css/chat")]
public void OnAdminCenterSayCommand(CCSPlayerController? caller, CommandInfo command)
@@ -109,7 +104,6 @@ public partial class CS2_SimpleAdmin
Helper.PrintToCenterAll(utf8String.ReplaceColorTags());
}
[ConsoleCommand("css_hsay", "Say to all players (in hud).")]
[CommandHelper(1, "<message>")]
[RequiresPermissions("@css/chat")]
public void OnAdminHudSayCommand(CCSPlayerController? caller, CommandInfo command)

View File

@@ -19,9 +19,6 @@ namespace CS2_SimpleAdmin;
public partial class CS2_SimpleAdmin
{
[ConsoleCommand("css_penalties")]
[ConsoleCommand("css_mypenalties")]
[ConsoleCommand("css_comms")]
[CommandHelper(whoCanExecute: CommandUsage.CLIENT_ONLY)]
public void OnPenaltiesCommand(CCSPlayerController? caller, CommandInfo command)
{
@@ -128,7 +125,6 @@ public partial class CS2_SimpleAdmin
});
}
[ConsoleCommand("css_admin")]
[RequiresPermissions("@css/generic")]
[CommandHelper(whoCanExecute: CommandUsage.CLIENT_ONLY)]
public void OnAdminCommand(CCSPlayerController? caller, CommandInfo command)
@@ -139,7 +135,6 @@ public partial class CS2_SimpleAdmin
AdminMenu.OpenMenu(caller);
}
[ConsoleCommand("css_adminhelp")]
[RequiresPermissions("@css/generic")]
public void OnAdminHelpCommand(CCSPlayerController? caller, CommandInfo command)
{
@@ -151,7 +146,6 @@ public partial class CS2_SimpleAdmin
}
}
[ConsoleCommand("css_addadmin")]
[CommandHelper(minArgs: 4, usage: "<steamid> <name> <flags/groups> <immunity> <duration>", whoCanExecute: CommandUsage.CLIENT_AND_SERVER)]
[RequiresPermissions("@css/root")]
public void OnAddAdminCommand(CCSPlayerController? caller, CommandInfo command)
@@ -207,7 +201,6 @@ public partial class CS2_SimpleAdmin
Server.PrintToConsole(msg);
}
[ConsoleCommand("css_deladmin")]
[CommandHelper(minArgs: 1, usage: "<steamid>", whoCanExecute: CommandUsage.CLIENT_AND_SERVER)]
[RequiresPermissions("@css/root")]
public void OnDelAdminCommand(CCSPlayerController? caller, CommandInfo command)
@@ -255,7 +248,6 @@ public partial class CS2_SimpleAdmin
Server.PrintToConsole(msg);
}
[ConsoleCommand("css_addgroup")]
[CommandHelper(minArgs: 3, usage: "<group_name> <flags> <immunity>", whoCanExecute: CommandUsage.CLIENT_AND_SERVER)]
[RequiresPermissions("@css/root")]
public void OnAddGroup(CCSPlayerController? caller, CommandInfo command)
@@ -301,7 +293,6 @@ public partial class CS2_SimpleAdmin
Server.PrintToConsole(msg);
}
[ConsoleCommand("css_delgroup")]
[CommandHelper(minArgs: 1, usage: "<group_name>", whoCanExecute: CommandUsage.CLIENT_AND_SERVER)]
[RequiresPermissions("@css/root")]
public void OnDelGroupCommand(CCSPlayerController? caller, CommandInfo command)
@@ -341,7 +332,6 @@ public partial class CS2_SimpleAdmin
Server.PrintToConsole(msg);
}
[ConsoleCommand("css_reloadadmins")]
[CommandHelper(whoCanExecute: CommandUsage.CLIENT_AND_SERVER)]
[RequiresPermissions("@css/root")]
public void OnRelAdminCommand(CCSPlayerController? caller, CommandInfo command)
@@ -391,8 +381,6 @@ public partial class CS2_SimpleAdmin
//_ = _adminManager.GiveAllFlags();
}
[ConsoleCommand("css_stealth")]
[ConsoleCommand("css_hide")]
[CommandHelper(whoCanExecute: CommandUsage.CLIENT_ONLY)]
[RequiresPermissions("@css/kick")]
public void OnHideCommand(CCSPlayerController? caller, CommandInfo command)
@@ -421,7 +409,25 @@ public partial class CS2_SimpleAdmin
}
}
[ConsoleCommand("css_who")]
[CommandHelper(whoCanExecute: CommandUsage.CLIENT_ONLY)]
[RequiresPermissions("@css/kick")]
public void OnHideCommsCommand(CCSPlayerController? caller, CommandInfo command)
{
if (caller == null)
return;
if (!AdminDisabledJoinComms.Add(caller.SteamID))
{
AdminDisabledJoinComms.Remove(caller.SteamID);
command.ReplyToCommand("From now on, you'll see penalty notifications");
}
else
{
AdminDisabledJoinComms.Add(caller.SteamID);
command.ReplyToCommand($"You don't see penalty notifications now");
}
}
[CommandHelper(minArgs: 1, usage: "<#userid or name>", whoCanExecute: CommandUsage.CLIENT_AND_SERVER)]
[RequiresPermissions("@css/generic")]
public void OnWhoCommand(CCSPlayerController? caller, CommandInfo command)
@@ -476,8 +482,6 @@ public partial class CS2_SimpleAdmin
});
}
[ConsoleCommand("css_disconnected")]
[ConsoleCommand("css_last")]
[CommandHelper(whoCanExecute: CommandUsage.CLIENT_ONLY)]
[RequiresPermissions("@css/kick")]
public void OnDisconnectedCommand(CCSPlayerController? caller, CommandInfo command)
@@ -494,7 +498,7 @@ public partial class CS2_SimpleAdmin
disconnectedMenuAction?.AddMenuOption(_localizer["sa_ban"], (_, _) =>
{
DurationMenu.OpenMenu(caller, _localizer["sa_ban"], player, (_, _, duration) =>
ReasonMenu.OpenMenu(caller, PenaltyType.Ban, "Powód", player, (_, _, reason) =>
ReasonMenu.OpenMenu(caller, PenaltyType.Ban, _localizer["sa_reason"], player, (_, _, reason) =>
{
caller.ExecuteClientCommandFromServer($"css_addban {player.SteamId.SteamId64} {duration} \"{reason}\"");
}));
@@ -502,7 +506,7 @@ public partial class CS2_SimpleAdmin
disconnectedMenuAction?.AddMenuOption(_localizer["sa_mute"], (_, _) =>
{
DurationMenu.OpenMenu(caller, _localizer["sa_mute"], player, (_, _, duration) =>
ReasonMenu.OpenMenu(caller, PenaltyType.Mute, "Powód", player, (_, _, reason) =>
ReasonMenu.OpenMenu(caller, PenaltyType.Mute, _localizer["sa_reason"], player, (_, _, reason) =>
{
caller.ExecuteClientCommandFromServer($"css_addmute {player.SteamId.SteamId64} {duration} \"{reason}\"");
}));
@@ -510,7 +514,7 @@ public partial class CS2_SimpleAdmin
disconnectedMenuAction?.AddMenuOption(_localizer["sa_gag"], (_, _) =>
{
DurationMenu.OpenMenu(caller, _localizer["sa_gag"], player, (_, _, duration) =>
ReasonMenu.OpenMenu(caller, PenaltyType.Mute, "Powód", player, (_, _, reason) =>
ReasonMenu.OpenMenu(caller, PenaltyType.Mute, _localizer["sa_reason"], player, (_, _, reason) =>
{
caller.ExecuteClientCommandFromServer($"css_addgag {player.SteamId.SteamId64} {duration} \"{reason}\"");
}));
@@ -518,7 +522,7 @@ public partial class CS2_SimpleAdmin
disconnectedMenuAction?.AddMenuOption(_localizer["sa_silence"], (_, _) =>
{
DurationMenu.OpenMenu(caller, _localizer["sa_silence"], player, (_, _, duration) =>
ReasonMenu.OpenMenu(caller, PenaltyType.Mute, "Powód", player, (_, _, reason) =>
ReasonMenu.OpenMenu(caller, PenaltyType.Mute, _localizer["sa_reason"], player, (_, _, reason) =>
{
caller.ExecuteClientCommandFromServer($"css_addsilence {player.SteamId.SteamId64} {duration} \"{reason}\"");
}));
@@ -531,7 +535,6 @@ public partial class CS2_SimpleAdmin
disconnectedMenu?.Open(caller);
}
[ConsoleCommand("css_warns")]
[CommandHelper(minArgs: 1, usage: "<#userid or name>", whoCanExecute: CommandUsage.CLIENT_ONLY)]
[RequiresPermissions("@css/kick")]
public void OnWarnsCommand(CCSPlayerController? caller, CommandInfo command)
@@ -586,7 +589,6 @@ public partial class CS2_SimpleAdmin
});
}
[ConsoleCommand("css_players")]
[CommandHelper(whoCanExecute: CommandUsage.CLIENT_AND_SERVER)]
[RequiresPermissions("@css/generic")]
public void OnPlayersCommand(CCSPlayerController? caller, CommandInfo command)
@@ -654,12 +656,11 @@ public partial class CS2_SimpleAdmin
}
}
[ConsoleCommand("css_kick")]
[RequiresPermissions("@css/kick")]
[CommandHelper(minArgs: 1, usage: "<#userid or name> [reason]", whoCanExecute: CommandUsage.CLIENT_AND_SERVER)]
public void OnKickCommand(CCSPlayerController? caller, CommandInfo command)
{
var callerName = caller == null ? "Console" : caller.PlayerName;
var callerName = caller == null ? _localizer?["sa_console"] ?? "Console" : caller.PlayerName;
var reason = _localizer?["sa_unknown"] ?? "Unknown";
var targets = GetTarget(command);
@@ -695,7 +696,7 @@ public partial class CS2_SimpleAdmin
if (!player.UserId.HasValue) return;
// Set default caller name if not provided
callerName ??= caller != null ? caller.PlayerName : "Console";
callerName ??= caller != null ? caller.PlayerName : _localizer?["sa_console"] ?? "Console";
reason ??= _localizer?["sa_unknown"] ?? "Unknown";
var playerInfo = PlayersInfo[player.UserId.Value];
@@ -743,8 +744,6 @@ public partial class CS2_SimpleAdmin
SimpleAdminApi?.OnPlayerPenaltiedEvent(playerInfo, adminInfo, PenaltyType.Kick, reason);
}
[ConsoleCommand("css_changemap")]
[ConsoleCommand("css_map")]
[RequiresPermissions("@css/changemap")]
[CommandHelper(minArgs: 1, usage: "<mapname>", whoCanExecute: CommandUsage.CLIENT_AND_SERVER)]
public void OnMapCommand(CCSPlayerController? caller, CommandInfo command)
@@ -755,7 +754,7 @@ public partial class CS2_SimpleAdmin
public void ChangeMap(CCSPlayerController? caller, string map, CommandInfo? command = null)
{
var callerName = caller != null ? caller.PlayerName : "Console";
var callerName = caller != null ? caller.PlayerName : _localizer?["sa_console"] ?? "Console";
map = map.ToLower();
if (map.StartsWith("ws:"))
@@ -802,9 +801,6 @@ public partial class CS2_SimpleAdmin
Helper.LogCommand(caller, command?.GetCommandString ?? $"css_map {map}");
}
[ConsoleCommand("css_changewsmap", "Change workshop map.")]
[ConsoleCommand("css_wsmap", "Change workshop map.")]
[ConsoleCommand("css_workshop", "Change workshop map.")]
[CommandHelper(1, "<name or id>")]
[RequiresPermissions("@css/changemap")]
public void OnWorkshopMapCommand(CCSPlayerController? caller, CommandInfo command)
@@ -816,7 +812,7 @@ public partial class CS2_SimpleAdmin
public void ChangeWorkshopMap(CCSPlayerController? caller, string map, CommandInfo? command = null)
{
map = map.ToLower();
var callerName = caller != null ? caller.PlayerName : "Console";
var callerName = caller != null ? caller.PlayerName : _localizer?["sa_console"] ?? "Console";
// Determine the workshop command
var issuedCommand = long.TryParse(map, out var mapId)
@@ -842,13 +838,12 @@ public partial class CS2_SimpleAdmin
Helper.LogCommand(caller, command?.GetCommandString ?? $"css_wsmap {map}");
}
[ConsoleCommand("css_cvar", "Change a cvar.")]
[CommandHelper(2, "<cvar> <value>")]
[RequiresPermissions("@css/cvar")]
public void OnCvarCommand(CCSPlayerController? caller, CommandInfo command)
{
var cvar = ConVar.Find(command.GetArg(1));
var callerName = caller == null ? "Console" : caller.PlayerName;
var callerName = caller == null ? _localizer?["sa_console"] ?? "Console" : caller.PlayerName;
if (cvar == null)
{
@@ -872,12 +867,11 @@ public partial class CS2_SimpleAdmin
Logger.LogInformation($"{callerName} changed cvar {cvar.Name} to {value}.");
}
[ConsoleCommand("css_rcon", "Run a server console command.")]
[CommandHelper(1, "<command>")]
[RequiresPermissions("@css/rcon")]
public void OnRconCommand(CCSPlayerController? caller, CommandInfo command)
{
var callerName = caller == null ? "Console" : caller.PlayerName;
var callerName = caller == null ? _localizer?["sa_console"] ?? "Console" : caller.PlayerName;
Helper.LogCommand(caller, command);
@@ -886,10 +880,6 @@ public partial class CS2_SimpleAdmin
Logger.LogInformation($"{callerName} executed command ({command.ArgString}).");
}
[ConsoleCommand("css_rr")]
[ConsoleCommand("css_rg")]
[ConsoleCommand("css_restart")]
[ConsoleCommand("css_restartgame")]
[RequiresPermissions("@css/generic")]
[CommandHelper(minArgs: 0, usage: "", whoCanExecute: CommandUsage.CLIENT_AND_SERVER)]
public void OnRestartCommand(CCSPlayerController? caller, CommandInfo command)
@@ -902,7 +892,7 @@ public partial class CS2_SimpleAdmin
Helper.LogCommand(admin, "css_restartgame");
// TODO: Localize
var name = admin == null ? "Console" : admin.PlayerName;
var name = admin == null ? _localizer?["sa_console"] ?? "Console" : admin.PlayerName;
Server.PrintToChatAll($"[SA] {name}: Restarting game...");
Server.ExecuteCommand("mp_restartgame 2");
}

View File

@@ -10,13 +10,12 @@ namespace CS2_SimpleAdmin;
public partial class CS2_SimpleAdmin
{
[ConsoleCommand("css_gag")]
[RequiresPermissions("@css/chat")]
[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)
{
if (Database == null) return;
var callerName = caller == null ? "Console" : caller.PlayerName;
var callerName = caller == null ? _localizer?["sa_console"] ?? "Console" : caller.PlayerName;
var reason = _localizer?["sa_unknown"] ?? "Unknown";
@@ -51,7 +50,7 @@ public partial class CS2_SimpleAdmin
if (!caller.CanTarget(player)) return;
// Set default caller name if not provided
callerName ??= caller == null ? "Console" : caller.PlayerName;
callerName ??= caller == null ? _localizer?["sa_console"] ?? "Console" : caller.PlayerName;
muteManager ??= new MuteManager(Database);
// Get player and admin information
@@ -101,7 +100,6 @@ public partial class CS2_SimpleAdmin
SimpleAdminApi?.OnPlayerPenaltiedEvent(playerInfo, adminInfo, PenaltyType.Gag, reason, time);
}
[ConsoleCommand("css_addgag")]
[RequiresPermissions("@css/chat")]
[CommandHelper(minArgs: 1, usage: "<steamid> [time in minutes/0 perm] [reason]", whoCanExecute: CommandUsage.CLIENT_AND_SERVER)]
public void OnAddGagCommand(CCSPlayerController? caller, CommandInfo command)
@@ -109,7 +107,7 @@ public partial class CS2_SimpleAdmin
if (Database == null) return;
// Set caller name
var callerName = caller == null ? "Console" : caller.PlayerName;
var callerName = caller == null ? _localizer?["sa_console"] ?? "Console" : caller.PlayerName;
// Validate command arguments
if (command.ArgCount < 2 || string.IsNullOrEmpty(command.GetArg(1))) return;
@@ -160,14 +158,13 @@ public partial class CS2_SimpleAdmin
SimpleAdminApi?.OnPlayerPenaltiedAddedEvent(steamId, adminInfo, PenaltyType.Gag, reason, time);
}
[ConsoleCommand("css_ungag")]
[RequiresPermissions("@css/chat")]
[CommandHelper(minArgs: 1, usage: "<steamid or name> [reason]", whoCanExecute: CommandUsage.CLIENT_AND_SERVER)]
public void OnUngagCommand(CCSPlayerController? caller, CommandInfo command)
{
if (Database == null) return;
var callerSteamId = caller?.SteamID.ToString() ?? "Console";
var callerSteamId = caller?.SteamID.ToString() ?? _localizer?["sa_console"] ?? "Console";
var pattern = command.GetArg(1);
var reason = command.GetArg(2);
@@ -229,13 +226,12 @@ public partial class CS2_SimpleAdmin
}
}
[ConsoleCommand("css_mute")]
[RequiresPermissions("@css/chat")]
[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)
{
if (Database == null) return;
var callerName = caller == null ? "Console" : caller.PlayerName;
var callerName = caller == null ? _localizer?["sa_console"] ?? "Console" : caller.PlayerName;
var reason = _localizer?["sa_unknown"] ?? "Unknown";
@@ -270,7 +266,7 @@ public partial class CS2_SimpleAdmin
if (!caller.CanTarget(player)) return;
// Set default caller name if not provided
callerName ??= caller == null ? "Console" : caller.PlayerName;
callerName ??= caller == null ? _localizer?["sa_console"] ?? "Console" : caller.PlayerName;
muteManager ??= new MuteManager(Database);
// Get player and admin information
@@ -323,7 +319,6 @@ public partial class CS2_SimpleAdmin
SimpleAdminApi?.OnPlayerPenaltiedEvent(playerInfo, adminInfo, PenaltyType.Mute, reason, time);
}
[ConsoleCommand("css_addmute")]
[RequiresPermissions("@css/chat")]
[CommandHelper(minArgs: 1, usage: "<steamid> [time in minutes/0 perm] [reason]", whoCanExecute: CommandUsage.CLIENT_AND_SERVER)]
public void OnAddMuteCommand(CCSPlayerController? caller, CommandInfo command)
@@ -331,7 +326,7 @@ public partial class CS2_SimpleAdmin
if (Database == null) return;
// Set caller name
var callerName = caller == null ? "Console" : caller.PlayerName;
var callerName = caller == null ? _localizer?["sa_console"] ?? "Console" : caller.PlayerName;
// Validate command arguments
if (command.ArgCount < 2 || string.IsNullOrEmpty(command.GetArg(1))) return;
@@ -382,14 +377,13 @@ public partial class CS2_SimpleAdmin
SimpleAdminApi?.OnPlayerPenaltiedAddedEvent(steamId, adminInfo, PenaltyType.Mute, reason, time);
}
[ConsoleCommand("css_unmute")]
[RequiresPermissions("@css/chat")]
[CommandHelper(minArgs: 1, usage: "<steamid or name>", whoCanExecute: CommandUsage.CLIENT_AND_SERVER)]
public void OnUnmuteCommand(CCSPlayerController? caller, CommandInfo command)
{
if (Database == null) return;
var callerSteamId = caller?.SteamID.ToString() ?? "Console";
var callerSteamId = caller?.SteamID.ToString() ?? _localizer?["sa_console"] ?? "Console";
var pattern = command.GetArg(1);
var reason = command.GetArg(2);
@@ -453,13 +447,12 @@ public partial class CS2_SimpleAdmin
}
}
[ConsoleCommand("css_silence")]
[RequiresPermissions("@css/chat")]
[CommandHelper(minArgs: 1, usage: "<#userid or name> [time in minutes/0 perm] [reason]", whoCanExecute: CommandUsage.CLIENT_AND_SERVER)]
public void OnSilenceCommand(CCSPlayerController? caller, CommandInfo command)
{
if (Database == null) return;
var callerName = caller == null ? "Console" : caller.PlayerName;
var callerName = caller == null ? _localizer?["sa_console"] ?? "Console" : caller.PlayerName;
var reason = _localizer?["sa_unknown"] ?? "Unknown";
@@ -494,7 +487,7 @@ public partial class CS2_SimpleAdmin
if (!caller.CanTarget(player)) return;
// Set default caller name if not provided
callerName ??= caller == null ? "Console" : caller.PlayerName;
callerName ??= caller == null ? _localizer?["sa_console"] ?? "Console" : caller.PlayerName;
muteManager ??= new MuteManager(Database);
// Get player and admin information
@@ -544,7 +537,6 @@ public partial class CS2_SimpleAdmin
SimpleAdminApi?.OnPlayerPenaltiedEvent(playerInfo, adminInfo, PenaltyType.Silence, reason, time);
}
[ConsoleCommand("css_addsilence")]
[RequiresPermissions("@css/chat")]
[CommandHelper(minArgs: 1, usage: "<#userid or name> [time in minutes/0 perm] [reason]", whoCanExecute: CommandUsage.CLIENT_AND_SERVER)]
public void OnAddSilenceCommand(CCSPlayerController? caller, CommandInfo command)
@@ -552,7 +544,7 @@ public partial class CS2_SimpleAdmin
if (Database == null) return;
// Set caller name
var callerName = caller == null ? "Console" : caller.PlayerName;
var callerName = caller == null ? _localizer?["sa_console"] ?? "Console" : caller.PlayerName;
// Validate command arguments
if (command.ArgCount < 2 || string.IsNullOrEmpty(command.GetArg(1))) return;
@@ -603,14 +595,13 @@ public partial class CS2_SimpleAdmin
SimpleAdminApi?.OnPlayerPenaltiedAddedEvent(steamId, adminInfo, PenaltyType.Silence, reason, time);
}
[ConsoleCommand("css_unsilence")]
[RequiresPermissions("@css/chat")]
[CommandHelper(minArgs: 1, usage: "<steamid or name> [reason]", whoCanExecute: CommandUsage.CLIENT_AND_SERVER)]
public void OnUnsilenceCommand(CCSPlayerController? caller, CommandInfo command)
{
if (Database == null) return;
var callerSteamId = caller?.SteamID.ToString() ?? "Console";
var callerSteamId = caller?.SteamID.ToString() ?? _localizer?["sa_console"] ?? "Console";
var pattern = command.GetArg(1);
var reason = command.GetArg(2);

View File

@@ -9,7 +9,6 @@ namespace CS2_SimpleAdmin;
public partial class CS2_SimpleAdmin
{
[ConsoleCommand("css_vote")]
[RequiresPermissions("@css/generic")]
[CommandHelper(minArgs: 2, usage: "<question> [... options ...]", whoCanExecute: CommandUsage.CLIENT_AND_SERVER)]
public void OnVoteCommand(CCSPlayerController? caller, CommandInfo command)
@@ -47,11 +46,11 @@ public partial class CS2_SimpleAdmin
voteMenu.PostSelectAction = PostSelectAction.Close;
Helper.PrintToCenterAll(_localizer["sa_admin_vote_message", caller == null ? "Console" : caller.PlayerName, question]);
Helper.PrintToCenterAll(_localizer["sa_admin_vote_message", caller == null ? _localizer["sa_console"] : caller.PlayerName, question]);
player.SendLocalizedMessage(_localizer,
"sa_admin_vote_message",
caller == null ? "Console" : caller.PlayerName,
caller == null ? _localizer["sa_console"] : caller.PlayerName,
question);
voteMenu.Open(player);

View File

@@ -7,12 +7,11 @@ namespace CS2_SimpleAdmin;
public partial class CS2_SimpleAdmin
{
[ConsoleCommand("css_noclip", "Noclip a player.")]
[CommandHelper(1, "<#userid or name>")]
[RequiresPermissions("@css/cheats")]
public void OnNoclipCommand(CCSPlayerController? caller, CommandInfo command)
{
var callerName = caller == null ? "Console" : caller.PlayerName;
var callerName = caller == null ? _localizer?["sa_console"] ?? _localizer?["sa_console"] ?? "Console" : caller.PlayerName;
var targets = GetTarget(command);
if (targets == null) return;
@@ -35,7 +34,7 @@ public partial class CS2_SimpleAdmin
if (!caller.CanTarget(player)) return;
// Set default caller name if not provided
callerName ??= caller != null ? caller.PlayerName : "Console";
callerName ??= caller != null ? caller.PlayerName : _localizer?["sa_console"] ?? "Console";
// Toggle no-clip mode for the player
player.Pawn.Value?.ToggleNoclip();
@@ -62,12 +61,11 @@ public partial class CS2_SimpleAdmin
}
}
[ConsoleCommand("css_god")]
[RequiresPermissions("@css/cheats")]
[CommandHelper(minArgs: 1, usage: "<#userid or name>", whoCanExecute: CommandUsage.CLIENT_AND_SERVER)]
public void OnGodCommand(CCSPlayerController? caller, CommandInfo command)
{
var callerName = caller == null ? "Console" : caller.PlayerName;
var callerName = caller == null ? _localizer?["sa_console"] ?? "Console" : caller.PlayerName;
var targets = GetTarget(command);
if (targets == null) return;
@@ -90,7 +88,7 @@ public partial class CS2_SimpleAdmin
if (!caller.CanTarget(player)) return;
// Set default caller name if not provided
var callerName = caller != null ? caller.PlayerName : "Console";
var callerName = caller != null ? caller.PlayerName : _localizer?["sa_console"] ?? "Console";
// Toggle god mode for the player
if (!GodPlayers.Add(player.Slot))
@@ -116,12 +114,11 @@ public partial class CS2_SimpleAdmin
}
}
[ConsoleCommand("css_freeze", "Freeze a player.")]
[CommandHelper(1, "<#userid or name> [duration]")]
[RequiresPermissions("@css/slay")]
public void OnFreezeCommand(CCSPlayerController? caller, CommandInfo command)
{
var callerName = caller == null ? "Console" : caller.PlayerName;
var callerName = caller == null ? _localizer?["sa_console"] ?? "Console" : caller.PlayerName;
int.TryParse(command.GetArg(2), out var time);
var targets = GetTarget(command);
@@ -143,7 +140,7 @@ public partial class CS2_SimpleAdmin
if (!caller.CanTarget(player)) return;
// Set default caller name if not provided
callerName ??= caller != null ? caller.PlayerName : "Console";
callerName ??= caller != null ? caller.PlayerName : _localizer?["sa_console"] ?? "Console";
// Freeze player pawn
player.Pawn.Value?.Freeze();
@@ -172,12 +169,11 @@ public partial class CS2_SimpleAdmin
Helper.LogCommand(caller, command);
}
[ConsoleCommand("css_unfreeze", "Unfreeze a player.")]
[CommandHelper(1, "<#userid or name>")]
[RequiresPermissions("@css/slay")]
public void OnUnfreezeCommand(CCSPlayerController? caller, CommandInfo command)
{
var callerName = caller == null ? "Console" : caller.PlayerName;
var callerName = caller == null ? _localizer?["sa_console"] ?? "Console" : caller.PlayerName;
var targets = GetTarget(command);
if (targets == null) return;
@@ -195,7 +191,7 @@ public partial class CS2_SimpleAdmin
if (!caller.CanTarget(player)) return;
// Set default caller name if not provided
callerName ??= caller != null ? caller.PlayerName : "Console";
callerName ??= caller != null ? caller.PlayerName : _localizer?["sa_console"] ?? "Console";
// Unfreeze player pawn
player.Pawn.Value?.Unfreeze();

View File

@@ -10,12 +10,11 @@ namespace CS2_SimpleAdmin;
public partial class CS2_SimpleAdmin
{
[ConsoleCommand("css_slay")]
[RequiresPermissions("@css/slay")]
[CommandHelper(minArgs: 1, usage: "<#userid or name>", whoCanExecute: CommandUsage.CLIENT_AND_SERVER)]
public void OnSlayCommand(CCSPlayerController? caller, CommandInfo command)
{
var callerName = caller == null ? "Console" : caller.PlayerName;
var callerName = caller == null ? _localizer?["sa_console"] ?? "Console" : caller.PlayerName;
var targets = GetTarget(command);
if (targets == null) return;
@@ -33,7 +32,7 @@ public partial class CS2_SimpleAdmin
if (!caller.CanTarget(player)) return;
// Set default caller name if not provided
callerName ??= caller != null ? caller.PlayerName : "Console";
callerName ??= caller != null ? caller.PlayerName : _localizer?["sa_console"] ?? "Console";
// Make the player commit suicide
player.CommitSuicide(false, true);
@@ -56,12 +55,11 @@ public partial class CS2_SimpleAdmin
Helper.LogCommand(caller, command);
}
[ConsoleCommand("css_give")]
[RequiresPermissions("@css/cheats")]
[CommandHelper(minArgs: 2, usage: "<#userid or name> <weapon>", whoCanExecute: CommandUsage.CLIENT_AND_SERVER)]
public void OnGiveCommand(CCSPlayerController? caller, CommandInfo command)
{
var callerName = caller == null ? "Console" : caller.PlayerName;
var callerName = caller == null ? _localizer?["sa_console"] ?? "Console" : caller.PlayerName;
var targets = GetTarget(command);
if (targets == null) return;
@@ -106,7 +104,7 @@ public partial class CS2_SimpleAdmin
if (!caller.CanTarget(player)) return;
// Set default caller name if not provided
callerName ??= caller != null ? caller.PlayerName : "Console";
callerName ??= caller != null ? caller.PlayerName : _localizer?["sa_console"] ?? "Console";
// Give weapon to the player
player.GiveNamedItem(weaponName);
@@ -134,7 +132,7 @@ public partial class CS2_SimpleAdmin
if (!caller.CanTarget(player)) return;
// Set default caller name if not provided
callerName ??= caller != null ? caller.PlayerName : "Console";
callerName ??= caller != null ? caller.PlayerName : _localizer?["sa_console"] ?? "Console";
// Give weapon to the player
player.GiveNamedItem(weapon);
@@ -157,12 +155,11 @@ public partial class CS2_SimpleAdmin
}
}
[ConsoleCommand("css_strip")]
[RequiresPermissions("@css/slay")]
[CommandHelper(minArgs: 1, usage: "<#userid or name>", whoCanExecute: CommandUsage.CLIENT_AND_SERVER)]
public void OnStripCommand(CCSPlayerController? caller, CommandInfo command)
{
var callerName = caller == null ? "Console" : caller.PlayerName;
var callerName = caller == null ? _localizer?["sa_console"] ?? "Console" : caller.PlayerName;
var targets = GetTarget(command);
if (targets == null) return;
@@ -182,7 +179,7 @@ public partial class CS2_SimpleAdmin
if (!caller.CanTarget(player)) return;
// Set default caller name if not provided
callerName ??= caller != null ? caller.PlayerName : "Console";
callerName ??= caller != null ? caller.PlayerName : _localizer?["sa_console"] ?? "Console";
// Check if player is valid, alive, and connected
if (!player.IsValid || !player.PawnIsAlive || player.Connected != PlayerConnectedState.PlayerConnected)
@@ -209,7 +206,6 @@ public partial class CS2_SimpleAdmin
}
}
[ConsoleCommand("css_hp")]
[RequiresPermissions("@css/slay")]
[CommandHelper(minArgs: 1, usage: "<#userid or name> <health>", whoCanExecute: CommandUsage.CLIENT_AND_SERVER)]
public void OnHpCommand(CCSPlayerController? caller, CommandInfo command)
@@ -236,7 +232,7 @@ public partial class CS2_SimpleAdmin
if (!caller.CanTarget(player)) return;
// Set default caller name if not provided
var callerName = caller != null ? caller.PlayerName : "Console";
var callerName = caller != null ? caller.PlayerName : _localizer?["sa_console"] ?? "Console";
// Set player's health
player.SetHp(health);
@@ -259,12 +255,11 @@ public partial class CS2_SimpleAdmin
}
}
[ConsoleCommand("css_speed")]
[RequiresPermissions("@css/slay")]
[CommandHelper(minArgs: 1, usage: "<#userid or name> <speed>", whoCanExecute: CommandUsage.CLIENT_AND_SERVER)]
public void OnSpeedCommand(CCSPlayerController? caller, CommandInfo command)
{
var callerName = caller == null ? "Console" : caller.PlayerName;
var callerName = caller == null ? _localizer?["sa_console"] ?? "Console" : caller.PlayerName;
float.TryParse(command.GetArg(2), out var speed);
var targets = GetTarget(command);
@@ -289,7 +284,7 @@ public partial class CS2_SimpleAdmin
if (!caller.CanTarget(player)) return;
// Set default caller name if not provided
var callerName = caller != null ? caller.PlayerName : "Console";
var callerName = caller != null ? caller.PlayerName : _localizer?["sa_console"] ?? "Console";
// Set player's speed
player.SetSpeed(speed);
@@ -317,7 +312,7 @@ public partial class CS2_SimpleAdmin
[CommandHelper(minArgs: 1, usage: "<#userid or name> <gravity>", whoCanExecute: CommandUsage.CLIENT_AND_SERVER)]
public void OnGravityCommand(CCSPlayerController? caller, CommandInfo command)
{
var callerName = caller == null ? "Console" : caller.PlayerName;
var callerName = caller == null ? _localizer?["sa_console"] ?? "Console" : caller.PlayerName;
float.TryParse(command.GetArg(2), out var gravity);
var targets = GetTarget(command);
@@ -342,7 +337,7 @@ public partial class CS2_SimpleAdmin
if (!caller.CanTarget(player)) return;
// Set default caller name if not provided
var callerName = caller != null ? caller.PlayerName : "Console";
var callerName = caller != null ? caller.PlayerName : _localizer?["sa_console"] ?? "Console";
// Set player's gravity
player.SetGravity(gravity);
@@ -365,12 +360,11 @@ public partial class CS2_SimpleAdmin
}
}
[ConsoleCommand("css_money")]
[RequiresPermissions("@css/slay")]
[CommandHelper(minArgs: 1, usage: "<#userid or name> <money>", whoCanExecute: CommandUsage.CLIENT_AND_SERVER)]
public void OnMoneyCommand(CCSPlayerController? caller, CommandInfo command)
{
var callerName = caller == null ? "Console" : caller.PlayerName;
var callerName = caller == null ? _localizer?["sa_console"] ?? "Console" : caller.PlayerName;
int.TryParse(command.GetArg(2), out var money);
var targets = GetTarget(command);
@@ -395,7 +389,7 @@ public partial class CS2_SimpleAdmin
if (!caller.CanTarget(player)) return;
// Set default caller name if not provided
var callerName = caller != null ? caller.PlayerName : "Console";
var callerName = caller != null ? caller.PlayerName : _localizer?["sa_console"] ?? "Console";
// Set player's money
player.SetMoney(money);
@@ -418,7 +412,6 @@ public partial class CS2_SimpleAdmin
}
}
[ConsoleCommand("css_slap")]
[RequiresPermissions("@css/slay")]
[CommandHelper(minArgs: 1, usage: "<#userid or name> [damage]", whoCanExecute: CommandUsage.CLIENT_AND_SERVER)]
public void OnSlapCommand(CCSPlayerController? caller, CommandInfo command)
@@ -452,7 +445,7 @@ public partial class CS2_SimpleAdmin
if (!caller.CanTarget(player)) return;
// Set default caller name if not provided
var callerName = caller != null ? caller.PlayerName : "Console";
var callerName = caller != null ? caller.PlayerName : _localizer?["sa_console"] ?? "Console";
// Apply slap damage to the player
player.Pawn.Value?.Slap(damage);
@@ -477,14 +470,13 @@ public partial class CS2_SimpleAdmin
}
}
[ConsoleCommand("css_team")]
[RequiresPermissions("@css/kick")]
[CommandHelper(minArgs: 2, usage: "<#userid or name> [<ct/tt/spec>] [-k]", whoCanExecute: CommandUsage.CLIENT_AND_SERVER)]
public void OnTeamCommand(CCSPlayerController? caller, CommandInfo command)
{
var callerName = caller == null ? "Console" : caller.PlayerName;
var callerName = caller == null ? _localizer?["sa_console"] ?? "Console" : caller.PlayerName;
var teamName = command.GetArg(2).ToLower();
var _teamName = "SPEC";
string _teamName;
var teamNum = CsTeam.Spectator;
var targets = GetTarget(command);
@@ -535,7 +527,7 @@ public partial class CS2_SimpleAdmin
if (!caller.CanTarget(player)) return;
// Set default caller name if not provided
var callerName = caller != null ? caller.PlayerName : "Console";
var callerName = caller != null ? caller.PlayerName : _localizer?["sa_console"] ?? "Console";
// Change team based on the provided teamName and conditions
if (!teamName.Equals("swap", StringComparison.OrdinalIgnoreCase))
@@ -574,13 +566,12 @@ public partial class CS2_SimpleAdmin
Helper.ShowAdminActivity(activityMessageKey, callerName, adminActivityArgs);
}
[ConsoleCommand("css_rename", "Rename a player.")]
[CommandHelper(1, "<#userid or name> <new name>")]
[RequiresPermissions("@css/kick")]
public void OnRenameCommand(CCSPlayerController? caller, CommandInfo command)
{
// Set default caller name if not provided
var callerName = caller == null ? "Console" : caller.PlayerName;
var callerName = caller == null ? _localizer?["sa_console"] ?? "Console" : caller.PlayerName;
// Get the new name from the command arguments
var newName = command.GetArg(2);
@@ -620,13 +611,12 @@ public partial class CS2_SimpleAdmin
});
}
[ConsoleCommand("css_prename", "Permanent rename a player.")]
[CommandHelper(1, "<#userid or name> <new name>")]
[RequiresPermissions("@css/ban")]
public void OnPRenameCommand(CCSPlayerController? caller, CommandInfo command)
public void OnPrenameCommand(CCSPlayerController? caller, CommandInfo command)
{
// Set default caller name if not provided
var callerName = caller == null ? "Console" : caller.PlayerName;
var callerName = caller == null ? _localizer?["sa_console"] ?? "Console" : caller.PlayerName;
// Get the new name from the command arguments
var newName = command.GetArg(2);
@@ -670,12 +660,11 @@ public partial class CS2_SimpleAdmin
});
}
[ConsoleCommand("css_respawn", "Respawn a dead player.")]
[CommandHelper(1, "<#userid or name>")]
[RequiresPermissions("@css/cheats")]
public void OnRespawnCommand(CCSPlayerController? caller, CommandInfo command)
{
var callerName = caller == null ? "Console" : caller.PlayerName;
var callerName = caller == null ? _localizer?["sa_console"] ?? "Console" : caller.PlayerName;
var targets = GetTarget(command);
if (targets == null) return;
@@ -699,7 +688,7 @@ public partial class CS2_SimpleAdmin
if (!caller.CanTarget(player)) return;
// Set default caller name if not provided
callerName ??= caller == null ? "Console" : caller.PlayerName;
callerName ??= caller == null ? _localizer?["sa_console"] ?? "Console" : caller.PlayerName;
// Ensure the player's pawn is valid before attempting to respawn
if (_cBasePlayerControllerSetPawnFunc == null || player.PlayerPawn.Value == null || !player.PlayerPawn.IsValid) return;
@@ -728,9 +717,6 @@ public partial class CS2_SimpleAdmin
Helper.ShowAdminActivity(activityMessageKey, callerName, adminActivityArgs);
}
[ConsoleCommand("css_tp", "Teleport to a player.")]
[ConsoleCommand("css_tpto", "Teleport to a player.")]
[ConsoleCommand("css_goto", "Teleport to a player.")]
[CommandHelper(1, "<#userid or name>")]
[RequiresPermissions("@css/kick")]
public void OnGotoCommand(CCSPlayerController? caller, CommandInfo command)
@@ -764,7 +750,7 @@ public partial class CS2_SimpleAdmin
// Prepare message key and arguments for the teleport notification
var activityMessageKey = "sa_admin_tp_message";
var adminActivityArgs = new object[] { player.PlayerName };
var adminActivityArgs = new object[] { "CALLER", player.PlayerName };
// Show admin activity
if (!SilentPlayers.Contains(caller.Slot) && _localizer != null)
@@ -774,8 +760,6 @@ public partial class CS2_SimpleAdmin
}
}
[ConsoleCommand("css_bring", "Teleport a player to you.")]
[ConsoleCommand("css_tphere", "Teleport a player to you.")]
[CommandHelper(1, "<#userid or name>")]
[RequiresPermissions("@css/kick")]
public void OnBringCommand(CCSPlayerController? caller, CommandInfo command)
@@ -809,7 +793,7 @@ public partial class CS2_SimpleAdmin
// Prepare message key and arguments for the bring notification
var activityMessageKey = "sa_admin_bring_message";
var adminActivityArgs = new object[] { player.PlayerName };
var adminActivityArgs = new object[] { "CALLER", player.PlayerName };
// Show admin activity
if (!SilentPlayers.Contains(caller.Slot) && _localizer != null)

View File

@@ -33,8 +33,6 @@ internal static class Helper
private static CNetworkSystemUpdatePublicIp? _networkSystemUpdatePublicIp;
internal static CS2_SimpleAdminConfig? Config { get; set; }
public static bool IsDebugBuild
{
get
@@ -182,7 +180,7 @@ internal static class Helper
if (CS2_SimpleAdmin._localizer == null)
return;
var playerName = caller?.PlayerName ?? "Console";
var playerName = caller?.PlayerName ?? CS2_SimpleAdmin._localizer["sa_console"];
var hostname = ConVar.Find("hostname")?.StringValue ?? CS2_SimpleAdmin._localizer["sa_unknown"];
@@ -198,7 +196,7 @@ internal static class Helper
if (CS2_SimpleAdmin._localizer == null)
return;
var playerName = caller?.PlayerName ?? "Console";
var playerName = caller?.PlayerName ?? CS2_SimpleAdmin._localizer["sa_console"];
var hostnameCvar = ConVar.Find("hostname");
var hostname = hostnameCvar?.StringValue ?? CS2_SimpleAdmin._localizer["sa_unknown"];
@@ -246,7 +244,7 @@ internal static class Helper
if (discordWebhookClientLog == null || localizer == null) return;
var communityUrl = caller != null ? "<" + new SteamID(caller.SteamID).ToCommunityUrl() + ">" : "<https://steamcommunity.com/profiles/0>";
var callerName = caller != null ? caller.PlayerName : "Console";
var callerName = caller != null ? caller.PlayerName : CS2_SimpleAdmin._localizer?["sa_console"] ?? "Console";
discordWebhookClientLog.SendMessageAsync(Helper.GenerateMessageDiscord(localizer["sa_discord_log_command", $"[{callerName}]({communityUrl})", command.GetCommandString]));
}
@@ -255,7 +253,7 @@ internal static class Helper
if (discordWebhookClientLog == null || localizer == null) return;
var communityUrl = caller != null ? "<" + new SteamID(caller.SteamID).ToCommunityUrl() + ">" : "<https://steamcommunity.com/profiles/0>";
var callerName = caller != null ? caller.PlayerName : "Console";
var callerName = caller != null ? caller.PlayerName : CS2_SimpleAdmin._localizer?["sa_console"] ?? "Console";
discordWebhookClientLog.SendMessageAsync(GenerateMessageDiscord(localizer["sa_discord_log_command", $"[{callerName}]({communityUrl})", command]));
}
@@ -292,7 +290,7 @@ internal static class Helper
currentMessageArgs[i] = CS2_SimpleAdmin.Instance.Config.OtherSettings.ShowActivityType switch
{
1 => arg.Replace("CALLER", AdminManager.PlayerHasPermissions(controller, "@css/kick") || AdminManager.PlayerHasPermissions(controller, "@css/ban") ? callerName : CS2_SimpleAdmin._localizer["sa_admin"]),
2 => arg.Replace("CALLER", callerName ?? "Console"),
2 => arg.Replace("CALLER", callerName ?? CS2_SimpleAdmin._localizer["sa_console"]),
_ => arg
};
}
@@ -323,7 +321,7 @@ internal static class Helper
formattedMessageArgs[i] = CS2_SimpleAdmin.Instance.Config.OtherSettings.ShowActivityType switch
{
1 => arg.Replace("CALLER", CS2_SimpleAdmin._localizer["sa_admin"]),
2 => arg.Replace("CALLER", callerName ?? "Console"),
2 => arg.Replace("CALLER", callerName ?? CS2_SimpleAdmin._localizer["sa_console"]),
_ => arg
};
}
@@ -362,7 +360,7 @@ internal static class Helper
var callerCommunityUrl = caller != null ? "<" + new SteamID(caller.SteamID).ToCommunityUrl() + ">" : "<https://steamcommunity.com/profiles/0>";
var targetCommunityUrl = target != null ? "<" + new SteamID(target.SteamID).ToCommunityUrl() + ">" : "<https://steamcommunity.com/profiles/0>";
var callerName = caller != null ? caller.PlayerName : "Console";
var callerName = caller != null ? caller.PlayerName : CS2_SimpleAdmin._localizer?["sa_console"] ?? "Console";
var targetName = target != null ? target.PlayerName : localizer["sa_unknown"];
var targetSteamId = target != null ? new SteamID(target.SteamID).SteamId64.ToString() : localizer["sa_unknown"];
@@ -503,7 +501,7 @@ internal static class Helper
if (caller != null && caller.IsValid == false)
caller = null;
var callerName = caller == null ? "Console" : caller.PlayerName;
var callerName = caller == null ? CS2_SimpleAdmin._localizer["sa_console"] : caller.PlayerName;
var communityUrl = caller != null
? "<" + new SteamID(caller.SteamID).ToCommunityUrl() + ">"
: "<https://steamcommunity.com/profiles/0>";

View File

@@ -27,8 +27,8 @@ internal class BanManager(Database.Database database, CS2_SimpleAdminConfig conf
playerSteamid = player.SteamId.SteamId64.ToString(),
playerName = player.Name,
playerIp = config.OtherSettings.BanType == 1 ? player.IpAddress : null,
adminSteamid = issuer?.SteamId.SteamId64.ToString() ?? "Console",
adminName = issuer?.Name ?? "Console",
adminSteamid = issuer?.SteamId.SteamId64.ToString() ?? CS2_SimpleAdmin._localizer?["sa_console"] ?? "Console",
adminName = issuer?.Name ?? CS2_SimpleAdmin._localizer?["sa_console"] ?? "Console",
banReason = reason,
duration = time,
ends = futureTime,
@@ -56,8 +56,8 @@ internal class BanManager(Database.Database database, CS2_SimpleAdminConfig conf
await connection.ExecuteAsync(sql, new
{
playerSteamid = playerSteamId,
adminSteamid = issuer?.SteamId.SteamId64.ToString() ?? "Console",
adminName = issuer?.Name ?? "Console",
adminSteamid = issuer?.SteamId.SteamId64.ToString() ?? CS2_SimpleAdmin._localizer?["sa_console"] ?? "Console",
adminName = issuer?.Name ?? CS2_SimpleAdmin._localizer?["sa_console"] ?? "Console",
banReason = reason,
duration = time,
ends = futureTime,
@@ -85,8 +85,8 @@ internal class BanManager(Database.Database database, CS2_SimpleAdminConfig conf
await connection.ExecuteAsync(sql, new
{
playerIp,
adminSteamid = issuer?.SteamId.SteamId64.ToString() ?? "Console",
adminName = issuer?.Name ?? "Console",
adminSteamid = issuer?.SteamId.SteamId64.ToString() ?? CS2_SimpleAdmin._localizer?["sa_console"] ?? "Console",
adminName = issuer?.Name ?? CS2_SimpleAdmin._localizer?["sa_console"] ?? "Console",
banReason = reason,
duration = time,
ends = futureTime,

View File

@@ -29,8 +29,8 @@ internal class MuteManager(Database.Database database)
{
playerSteamid = player.SteamId.SteamId64.ToString(),
playerName = player.Name,
adminSteamid = issuer?.SteamId.SteamId64.ToString() ?? "Console",
adminName = issuer?.Name ?? "Console",
adminSteamid = issuer?.SteamId.SteamId64.ToString() ?? CS2_SimpleAdmin._localizer?["sa_console"] ?? "Console",
adminName = issuer?.Name ?? CS2_SimpleAdmin._localizer?["sa_console"] ?? "Console",
muteReason = reason,
duration = time,
ends = futureTime,
@@ -69,8 +69,8 @@ internal class MuteManager(Database.Database database)
await connection.ExecuteAsync(sql, new
{
playerSteamid = playerSteamId,
adminSteamid = issuer?.SteamId.SteamId64.ToString() ?? "Console",
adminName = issuer?.Name ?? "Console",
adminSteamid = issuer?.SteamId.SteamId64.ToString() ?? CS2_SimpleAdmin._localizer?["sa_console"] ?? "Console",
adminName = issuer?.Name ?? CS2_SimpleAdmin._localizer?["sa_console"] ?? "Console",
muteReason = reason,
duration = time,
ends = futureTime,

View File

@@ -180,43 +180,12 @@ public class PlayerManager
}
}
/*
if (CS2_SimpleAdmin._localizer != null)
{
if (mutesList[PenaltyType.Gag].Count == 0)
mutesList[PenaltyType.Gag].Add(CS2_SimpleAdmin._localizer["sa_player_penalty_info_no_active_gag"]);
if (mutesList[PenaltyType.Mute].Count == 0)
mutesList[PenaltyType.Mute].Add(CS2_SimpleAdmin._localizer["sa_player_penalty_info_no_active_mute"]);
if (mutesList[PenaltyType.Silence].Count == 0)
mutesList[PenaltyType.Silence].Add(CS2_SimpleAdmin._localizer["sa_player_penalty_info_no_active_silence"]);
}
*/
/*
await Server.NextFrameAsync(() =>
{
CS2_SimpleAdmin.Instance.AddTimer(3.0f, () =>
{
player.SendLocalizedMessage(CS2_SimpleAdmin._localizer, "sa_player_penalty_info",
[
player.PlayerName,
CS2_SimpleAdmin.PlayersInfo[userId].TotalBans,
CS2_SimpleAdmin.PlayersInfo[userId].TotalGags,
CS2_SimpleAdmin.PlayersInfo[userId].TotalMutes,
CS2_SimpleAdmin.PlayersInfo[userId].TotalSilences,
CS2_SimpleAdmin.PlayersInfo[userId].TotalWarns,
string.Join("\n", mutesList.SelectMany(kvp => kvp.Value)),
string.Join("\n", warnsList)
]);
});
*/
await Server.NextFrameAsync(() =>
{
foreach (var admin in Helper.GetValidPlayers()
.Where(p => (AdminManager.PlayerHasPermissions(p, "@css/kick") ||
AdminManager.PlayerHasPermissions(p, "@css/ban")) &&
p.Connected == PlayerConnectedState.PlayerConnected))
p.Connected == PlayerConnectedState.PlayerConnected && !CS2_SimpleAdmin.AdminDisabledJoinComms.Contains(p.SteamID)))
{
if (CS2_SimpleAdmin._localizer != null && admin != player)
admin.SendLocalizedMessage(CS2_SimpleAdmin._localizer, "sa_admin_penalty_info",

View File

@@ -22,8 +22,8 @@ internal class WarnManager(Database.Database database)
{
playerSteamid = player.SteamId.SteamId64.ToString(),
playerName = player.Name,
adminSteamid = issuer?.SteamId.SteamId64.ToString() ?? "Console",
adminName = issuer?.Name ?? "Console",
adminSteamid = issuer?.SteamId.SteamId64.ToString() ?? CS2_SimpleAdmin._localizer?["sa_console"] ?? "Console",
adminName = issuer?.Name ?? CS2_SimpleAdmin._localizer?["sa_console"] ?? "Console",
muteReason = reason,
duration = time,
ends = futureTime,
@@ -51,8 +51,8 @@ internal class WarnManager(Database.Database database)
await connection.ExecuteAsync(sql, new
{
playerSteamid = playerSteamId,
adminSteamid = issuer?.SteamId.ToString() ?? "Console",
adminName = issuer?.Name ?? "Console",
adminSteamid = issuer?.SteamId.ToString() ?? CS2_SimpleAdmin._localizer?["sa_console"] ?? "Console",
adminName = issuer?.Name ?? CS2_SimpleAdmin._localizer?["sa_console"] ?? "Console",
muteReason = reason,
duration = time,
ends = futureTime,

View File

@@ -1 +1 @@
1.6.0a
1.6.1a

View File

@@ -13,32 +13,48 @@ namespace CS2_SimpleAdmin;
public partial class CS2_SimpleAdmin
{
// Paths
internal static string ConfigDirectory = Path.Combine(Application.RootDirectory, "configs/plugins/CS2-SimpleAdmin");
// Localization
public static IStringLocalizer? _localizer;
// Voting System
public static readonly Dictionary<string, int> VoteAnswers = [];
public static bool VoteInProgress;
// Command and Server Settings
public static readonly bool UnlockedCommands = CoreConfig.UnlockConCommands;
internal static string IpAddress = string.Empty;
public static bool ServerLoaded;
public static int? ServerId = null;
internal static readonly HashSet<ulong> AdminDisabledJoinComms = [];
// Player Management
private static readonly HashSet<int> GodPlayers = [];
private static readonly HashSet<int> SilentPlayers = [];
internal static readonly ConcurrentBag<string?> BannedPlayers = [];
internal static readonly Dictionary<ulong, string> RenamedPlayers = [];
public static bool VoteInProgress;
public static int? ServerId = null;
public static readonly bool UnlockedCommands = CoreConfig.UnlockConCommands;
internal static readonly Dictionary<int, PlayerInfo> PlayersInfo = [];
private static readonly List<DisconnectedPlayer> DisconnectedPlayers = [];
// Discord Integration
internal static DiscordWebhookClient? DiscordWebhookClientLog;
// Database Settings
internal string DbConnectionString = string.Empty;
internal static Database.Database? Database;
internal static string IpAddress = string.Empty;
// Logger
internal static ILogger? _logger;
// Memory Function (Game-related)
private static MemoryFunctionVoid<CBasePlayerController, CCSPlayerPawn, bool, bool>? _cBasePlayerControllerSetPawnFunc;
// Menus
// Menu API and Capabilities
internal static IMenuApi? MenuApi;
private static readonly PluginCapability<IMenuApi> MenuCapability = new("menu:nfcore");
// Shared
// Shared API
private Api.CS2_SimpleAdminApi? SimpleAdminApi { get; set; }
}

View File

@@ -49,6 +49,7 @@
"sa_menu_disconnected_action_title": "Select action",
"sa_player": "Player",
"sa_console": "Console",
"sa_steamid": "SteamID",
"sa_duration": "Duration",
"sa_reason": "Reason",

View File

@@ -1,5 +1,6 @@
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Core.Capabilities;
using CounterStrikeSharp.API.Modules.Commands;
using CounterStrikeSharp.API.Modules.Entities;
namespace CS2_SimpleAdminApi;
@@ -20,4 +21,6 @@ public interface ICS2_SimpleAdminApi
public event Action<SteamID, PlayerInfo?, PenaltyType, string, int, int?>? OnPlayerPenaltiedAdded;
public void IssuePenalty(CCSPlayerController player, CCSPlayerController? admin, PenaltyType penaltyType, string reason, int duration = -1);
public void LogCommand(CCSPlayerController? caller, string command);
public void LogCommand(CCSPlayerController? caller, CommandInfo command);
}