From e401fe7c8bd9c17bad5c96fd3bc05692d42f0e0b Mon Sep 17 00:00:00 2001 From: Dawid Bepierszcz <41084667+daffyyyy@users.noreply.github.com> Date: Fri, 9 Feb 2024 21:54:55 +0100 Subject: [PATCH] 1.3.0d - Fixed noclip - Fixed freeze - Fixed vote --- CS2-SimpleAdmin.cs | 13 +++++++------ Helper.cs | 6 ++---- PlayerUtils.cs | 16 +++++++++++++++- 3 files changed, 24 insertions(+), 11 deletions(-) diff --git a/CS2-SimpleAdmin.cs b/CS2-SimpleAdmin.cs index c6baa13..e4260b5 100644 --- a/CS2-SimpleAdmin.cs +++ b/CS2-SimpleAdmin.cs @@ -31,6 +31,7 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig votePlayers = new HashSet(); public static ConcurrentBag godPlayers = new ConcurrentBag(); public static ConcurrentBag gaggedPlayers = new ConcurrentBag(); + public static ConcurrentBag commsPlayers = new ConcurrentBag(); public static ConcurrentBag silentPlayers = new ConcurrentBag(); public static ConcurrentBag bannedPlayers = new ConcurrentBag(); public static bool TagsDetected = false; @@ -46,7 +47,7 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig "CS2-SimpleAdmin"; public override string ModuleDescription => "Simple admin plugin for Counter-Strike 2 :)"; public override string ModuleAuthor => "daffyy"; - public override string ModuleVersion => "1.3.0c"; + public override string ModuleVersion => "1.3.0d"; public CS2_SimpleAdminConfig Config { get; set; } = new(); @@ -1885,22 +1886,21 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig p != null && p.IsValid && p.Connected == PlayerConnectedState.PlayerConnected && !p.IsBot && !p.IsHLTV)) { + using (new WithTemporaryCulture(_player.GetLanguage())) { - MenuManager.OpenChatMenu(_player, voteMenu); - for (int i = 2; i <= answersCount - 1; i++) - { - voteMenu.AddMenuOption(command.GetArg(i), Helper.handleVotes); - } Helper.PrintToCenterAll(_localizer!["sa_admin_vote_message", caller == null ? "Console" : caller.PlayerName, question]); StringBuilder sb = new(_localizer!["sa_prefix"]); sb.Append(_localizer["sa_admin_vote_message", caller == null ? "Console" : caller.PlayerName, question]); _player.PrintToChat(sb.ToString()); } + + MenuManager.OpenChatMenu(_player, voteMenu); } if (Config.DiscordWebhook.Length > 0 && _localizer != null) @@ -1908,6 +1908,7 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig GetPlayerFromSteamid64(string steamid) { return Utilities.GetPlayers().FindAll(x => - x.AuthorizedSteamID != null && - x.AuthorizedSteamID.SteamId64.ToString().Equals(steamid, StringComparison.OrdinalIgnoreCase) + x.SteamID.ToString().Equals(steamid, StringComparison.OrdinalIgnoreCase) ); } @@ -60,7 +59,6 @@ namespace CS2_SimpleAdmin //Console.WriteLine($"Setting immunity for SteamID {steamid} to {immunity}"); - if (flags != null) { //Console.WriteLine($"Applying flags to SteamID {steamid}:"); @@ -150,9 +148,9 @@ namespace CS2_SimpleAdmin { if (CS2_SimpleAdmin.voteInProgress && !CS2_SimpleAdmin.votePlayers.Contains(player.Slot)) { + option.Disabled = true; CS2_SimpleAdmin.votePlayers.Add(player.Slot); CS2_SimpleAdmin.voteAnswers[option.Text]++; - option.Disabled = true; } } } diff --git a/PlayerUtils.cs b/PlayerUtils.cs index 539512e..d802ff0 100644 --- a/PlayerUtils.cs +++ b/PlayerUtils.cs @@ -1,5 +1,7 @@ -using CounterStrikeSharp.API.Core; +using CounterStrikeSharp.API; +using CounterStrikeSharp.API.Core; using CounterStrikeSharp.API.Modules.Admin; +using CounterStrikeSharp.API.Modules.Memory; using CounterStrikeSharp.API.Modules.Utils; using System.Text; @@ -80,19 +82,31 @@ public static class PlayerUtils public static void Freeze(this CBasePlayerPawn pawn) { pawn.MoveType = MoveType_t.MOVETYPE_OBSOLETE; + Schema.SetSchemaValue(pawn.Handle, "CBaseEntity", "m_nActualMoveType", 1); // obsolete + Utilities.SetStateChanged(pawn, "CBaseEntity", "m_MoveType"); } public static void Unfreeze(this CBasePlayerPawn pawn) { pawn.MoveType = MoveType_t.MOVETYPE_WALK; + Schema.SetSchemaValue(pawn.Handle, "CBaseEntity", "m_nActualMoveType", 2); // walk + Utilities.SetStateChanged(pawn, "CBaseEntity", "m_MoveType"); } public static void ToggleNoclip(this CBasePlayerPawn pawn) { if (pawn.MoveType == MoveType_t.MOVETYPE_NOCLIP) + { pawn.MoveType = MoveType_t.MOVETYPE_WALK; + Schema.SetSchemaValue(pawn.Handle, "CBaseEntity", "m_nActualMoveType", 2); // walk + Utilities.SetStateChanged(pawn, "CBaseEntity", "m_MoveType"); + } else + { pawn.MoveType = MoveType_t.MOVETYPE_NOCLIP; + Schema.SetSchemaValue(pawn.Handle, "CBaseEntity", "m_nActualMoveType", 8); // noclip + Utilities.SetStateChanged(pawn, "CBaseEntity", "m_MoveType"); + } } private static void PerformSlap(CBasePlayerPawn pawn, int damage = 0)