diff --git a/CS2-SimpleAdmin.cs b/CS2-SimpleAdmin.cs index 0254e9f..0b1df24 100644 --- a/CS2-SimpleAdmin.cs +++ b/CS2-SimpleAdmin.cs @@ -11,7 +11,7 @@ using System.Collections.Concurrent; namespace CS2_SimpleAdmin; -[MinimumApiVersion(228)] +[MinimumApiVersion(246)] public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig { public static CS2_SimpleAdmin Instance { get; private set; } = new(); @@ -39,7 +39,7 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig "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.4.7a"; + public override string ModuleVersion => "1.4.8a"; public CS2_SimpleAdminConfig Config { get; set; } = new(); diff --git a/CS2-SimpleAdmin.csproj b/CS2-SimpleAdmin.csproj index 8205265..4d2466c 100644 --- a/CS2-SimpleAdmin.csproj +++ b/CS2-SimpleAdmin.csproj @@ -10,9 +10,9 @@ - + - + diff --git a/Commands/basecommands.cs b/Commands/basecommands.cs index 5c30bfa..e744d3c 100644 --- a/Commands/basecommands.cs +++ b/Commands/basecommands.cs @@ -522,7 +522,7 @@ namespace CS2_SimpleAdmin playersToTarget.ForEach(player => { - if (!player.IsBot && player.SteamID.ToString().Length != 17) + if (player == null || !player.IsValid) return; if (caller!.CanTarget(player)) diff --git a/Commands/basevotes.cs b/Commands/basevotes.cs index c414986..aa5c260 100644 --- a/Commands/basevotes.cs +++ b/Commands/basevotes.cs @@ -53,9 +53,9 @@ namespace CS2_SimpleAdmin StringBuilder sb = new(_localizer["sa_prefix"]); sb.Append(_localizer["sa_admin_vote_message", caller == null ? "Console" : caller.PlayerName, question]); player.PrintToChat(sb.ToString()); - - voteMenu.OpenToAll(); - + + voteMenu.Open(player); + //MenuManager.OpenChatMenu(player, voteMenu); } } diff --git a/Commands/funcommands.cs b/Commands/funcommands.cs index bb69de2..f114b2f 100644 --- a/Commands/funcommands.cs +++ b/Commands/funcommands.cs @@ -69,9 +69,6 @@ namespace CS2_SimpleAdmin playersToTarget.ForEach(player => { - if (!player.IsBot && player.Connected == PlayerConnectedState.PlayerConnected) - return; - if (caller!.CanTarget(player)) { Freeze(caller, player, time, callerName); @@ -115,9 +112,6 @@ namespace CS2_SimpleAdmin playersToTarget.ForEach(player => { - if (!player.IsBot && player.Connected == PlayerConnectedState.PlayerConnected) - return; - Unfreeze(caller, player, callerName, command); }); } diff --git a/Commands/playercommands.cs b/Commands/playercommands.cs index 6375bcb..5b580c1 100644 --- a/Commands/playercommands.cs +++ b/Commands/playercommands.cs @@ -207,7 +207,7 @@ namespace CS2_SimpleAdmin public void SetHp(CCSPlayerController? caller, CCSPlayerController? player, int health, CommandInfo? command = null) { - if (player != null && !player.IsBot && player.Connected == PlayerConnectedState.PlayerConnected) + if (player == null || !player.IsValid || player.IsHLTV) return; var callerName = caller == null ? "Console" : caller.PlayerName; diff --git a/Config.cs b/Config.cs index 509f49b..159116e 100644 --- a/Config.cs +++ b/Config.cs @@ -170,7 +170,7 @@ namespace CS2_SimpleAdmin public List DefaultMaps { get; set; } = new(); [JsonPropertyName("WorkshopMaps")] - public List WorkshopMaps { get; set; } = new(); + public Dictionary WorkshopMaps { get; set; } = new(); [JsonPropertyName("CustomServerCommands")] public List CustomServerCommands { get; set; } = new(); diff --git a/Events.cs b/Events.cs index bcb34f7..ec21683 100644 --- a/Events.cs +++ b/Events.cs @@ -31,8 +31,6 @@ public partial class CS2_SimpleAdmin if (string.IsNullOrEmpty(ipAddress) || ipAddress.StartsWith("0.0.0")) { ipAddress = Helper.GetServerIp(); - Logger.LogError("Unable to get server ip, Check that you have added the correct start parameter \"-ip \""); - Logger.LogError($"Using alternative method... Server IP {ipAddress}"); } if (string.IsNullOrEmpty(ipAddress) || ipAddress.StartsWith("0.0.0")) @@ -188,7 +186,7 @@ public partial class CS2_SimpleAdmin { // Add player's IP and SteamID to bannedPlayers list if not already present if (Config.BanType > 0 && playerInfo.IpAddress != null && - !BannedPlayers.Contains(playerInfo.IpAddress)) + !BannedPlayers.Contains(playerInfo.IpAddress)) { BannedPlayers.Add(playerInfo.IpAddress); } @@ -202,7 +200,7 @@ public partial class CS2_SimpleAdmin await Server.NextFrameAsync(() => { var victim = Utilities.GetPlayerFromUserid(playerInfo.UserId); - + if (victim?.UserId != null) { if (UnlockedCommands) @@ -365,8 +363,6 @@ public partial class CS2_SimpleAdmin { return; ipAddress = Helper.GetServerIp(); - Logger.LogError("Unable to get server ip, Check that you have added the correct start parameter \"-ip \""); - Logger.LogError($"Using alternative method... Server IP {ipAddress}"); } var address = $"{ipAddress}:{ConVar.Find("hostport")?.GetPrimitiveValue()}"; diff --git a/Menus/ManageServerMenu.cs b/Menus/ManageServerMenu.cs index 3fd6321..7638de6 100644 --- a/Menus/ManageServerMenu.cs +++ b/Menus/ManageServerMenu.cs @@ -53,7 +53,7 @@ namespace CS2_SimpleAdmin.Menus options.AddRange(maps.Select(map => new ChatMenuOptionData(map, () => ExecuteChangeMap(admin, map, false)))); var wsMaps = CS2_SimpleAdmin.Instance.Config.WorkshopMaps; - options.AddRange(wsMaps.Select(map => new ChatMenuOptionData($"{map} (WS)", () => ExecuteChangeMap(admin, map, true)))); + options.AddRange(wsMaps.Select(map => new ChatMenuOptionData($"{map.Key} (WS)", () => ExecuteChangeMap(admin, map.Value?.ToString() ?? map.Key, true)))); foreach (var menuOptionData in options) {