Skip to content

Commit

Permalink
1.3.0d
Browse files Browse the repository at this point in the history
- Fixed noclip
- Fixed freeze
- Fixed vote
  • Loading branch information
daffyyyy committed Feb 9, 2024
1 parent fbed647 commit e401fe7
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 11 deletions.
13 changes: 7 additions & 6 deletions CS2-SimpleAdmin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
public static HashSet<int> votePlayers = new HashSet<int>();
public static ConcurrentBag<int> godPlayers = new ConcurrentBag<int>();
public static ConcurrentBag<int> gaggedPlayers = new ConcurrentBag<int>();
public static ConcurrentBag<int> commsPlayers = new ConcurrentBag<int>();
public static ConcurrentBag<int> silentPlayers = new ConcurrentBag<int>();
public static ConcurrentBag<string> bannedPlayers = new ConcurrentBag<string>();
public static bool TagsDetected = false;
Expand All @@ -46,7 +47,7 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
public override string ModuleName => "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();

Expand Down Expand Up @@ -1885,29 +1886,29 @@ public void OnVoteCommand(CCSPlayerController? caller, CommandInfo command)
for (int i = 2; i <= answersCount - 1; i++)
{
voteAnswers.Add(command.GetArg(i), 0);
voteMenu.AddMenuOption(command.GetArg(i), Helper.handleVotes);
}

foreach (CCSPlayerController _player in Utilities.GetPlayers().Where(p => 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)
{
LocalizedString localizedMessage = _localizer["sa_admin_vote_message", caller == null ? "Console" : caller.PlayerName, question];
_ = SendWebhookMessage(localizedMessage.ToString().Replace("", "").Replace("", ""));
}

voteInProgress = true;
}

Expand Down
6 changes: 2 additions & 4 deletions Helper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ public static List<CCSPlayerController> GetPlayerFromName(string name)
public static List<CCSPlayerController> 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)
);
}

Expand Down Expand Up @@ -60,7 +59,6 @@ public static void GivePlayerFlags(SteamID? steamid, List<string>? flags = null,

//Console.WriteLine($"Setting immunity for SteamID {steamid} to {immunity}");


if (flags != null)
{
//Console.WriteLine($"Applying flags to SteamID {steamid}:");
Expand Down Expand Up @@ -150,9 +148,9 @@ internal static void handleVotes(CCSPlayerController player, ChatMenuOption opti
{
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;
}
}
}
Expand Down
16 changes: 15 additions & 1 deletion PlayerUtils.cs
Original file line number Diff line number Diff line change
@@ -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;

Expand Down Expand Up @@ -80,19 +82,31 @@ public static void Unbury(this CBasePlayerPawn pawn, float depth = 15f)
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)
Expand Down

0 comments on commit e401fe7

Please sign in to comment.