mirror of
https://github.com/daffyyyy/CS2-SimpleAdmin.git
synced 2026-02-18 10:43:23 +00:00
1.6.6a
```diff + Reapply gravity/speed with timer + Added shake effect for slap + Fixed css_gravity and css_speed command + Fixed css_give command, for example weapon_knife returns weapon_knife instead of weapon_knife and weapon_knife_t + Small code improvements ```
This commit is contained in:
@@ -19,7 +19,7 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
public override string ModuleName => "CS2-SimpleAdmin" + (Helper.IsDebugBuild ? " (DEBUG)" : " (RELEASE)");
|
public override string ModuleName => "CS2-SimpleAdmin" + (Helper.IsDebugBuild ? " (DEBUG)" : " (RELEASE)");
|
||||||
public override string ModuleDescription => "Simple admin plugin for Counter-Strike 2 :)";
|
public override string ModuleDescription => "Simple admin plugin for Counter-Strike 2 :)";
|
||||||
public override string ModuleAuthor => "daffyy & Dliix66";
|
public override string ModuleAuthor => "daffyy & Dliix66";
|
||||||
public override string ModuleVersion => "1.6.5a";
|
public override string ModuleVersion => "1.6.6a";
|
||||||
|
|
||||||
public override void Load(bool hotReload)
|
public override void Load(bool hotReload)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="CounterStrikeSharp.API" Version="1.0.276" />
|
<PackageReference Include="CounterStrikeSharp.API" Version="1.0.284" />
|
||||||
<PackageReference Include="Dapper" Version="2.1.35" />
|
<PackageReference Include="Dapper" Version="2.1.35" />
|
||||||
<PackageReference Include="MySqlConnector" Version="2.3.7" />
|
<PackageReference Include="MySqlConnector" Version="2.3.7" />
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="*" />
|
<PackageReference Include="Newtonsoft.Json" Version="*" />
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
|
using System.Globalization;
|
||||||
using CounterStrikeSharp.API.Core;
|
using CounterStrikeSharp.API.Core;
|
||||||
using CounterStrikeSharp.API.Core.Attributes.Registration;
|
|
||||||
using CounterStrikeSharp.API.Modules.Admin;
|
using CounterStrikeSharp.API.Modules.Admin;
|
||||||
using CounterStrikeSharp.API.Modules.Commands;
|
using CounterStrikeSharp.API.Modules.Commands;
|
||||||
using CounterStrikeSharp.API.Modules.Entities.Constants;
|
using CounterStrikeSharp.API.Modules.Entities.Constants;
|
||||||
@@ -10,6 +10,9 @@ namespace CS2_SimpleAdmin;
|
|||||||
|
|
||||||
public partial class CS2_SimpleAdmin
|
public partial class CS2_SimpleAdmin
|
||||||
{
|
{
|
||||||
|
internal static readonly Dictionary<int, float> SpeedPlayers = [];
|
||||||
|
internal static readonly Dictionary<CCSPlayerController, float> GravityPlayers = [];
|
||||||
|
|
||||||
[RequiresPermissions("@css/slay")]
|
[RequiresPermissions("@css/slay")]
|
||||||
[CommandHelper(minArgs: 1, usage: "<#userid or name>", whoCanExecute: CommandUsage.CLIENT_AND_SERVER)]
|
[CommandHelper(minArgs: 1, usage: "<#userid or name>", whoCanExecute: CommandUsage.CLIENT_AND_SERVER)]
|
||||||
public void OnSlayCommand(CCSPlayerController? caller, CommandInfo command)
|
public void OnSlayCommand(CCSPlayerController? caller, CommandInfo command)
|
||||||
@@ -265,8 +268,7 @@ public partial class CS2_SimpleAdmin
|
|||||||
[CommandHelper(minArgs: 1, usage: "<#userid or name> <speed>", whoCanExecute: CommandUsage.CLIENT_AND_SERVER)]
|
[CommandHelper(minArgs: 1, usage: "<#userid or name> <speed>", whoCanExecute: CommandUsage.CLIENT_AND_SERVER)]
|
||||||
public void OnSpeedCommand(CCSPlayerController? caller, CommandInfo command)
|
public void OnSpeedCommand(CCSPlayerController? caller, CommandInfo command)
|
||||||
{
|
{
|
||||||
var callerName = caller == null ? _localizer?["sa_console"] ?? "Console" : caller.PlayerName;
|
float.TryParse(command.GetArg(2), NumberStyles.Float, CultureInfo.InvariantCulture, out var speed);
|
||||||
float.TryParse(command.GetArg(2), out var speed);
|
|
||||||
|
|
||||||
var targets = GetTarget(command);
|
var targets = GetTarget(command);
|
||||||
if (targets == null) return;
|
if (targets == null) return;
|
||||||
@@ -295,6 +297,11 @@ public partial class CS2_SimpleAdmin
|
|||||||
// Set player's speed
|
// Set player's speed
|
||||||
player.SetSpeed(speed);
|
player.SetSpeed(speed);
|
||||||
|
|
||||||
|
if (speed == 1f)
|
||||||
|
SpeedPlayers.Remove(player.Slot);
|
||||||
|
else
|
||||||
|
SpeedPlayers[player.Slot] = speed;
|
||||||
|
|
||||||
// Log the command
|
// Log the command
|
||||||
if (command == null)
|
if (command == null)
|
||||||
Helper.LogCommand(caller, $"css_speed {(string.IsNullOrEmpty(player.PlayerName) ? player.SteamID.ToString() : player.PlayerName)} {speed}");
|
Helper.LogCommand(caller, $"css_speed {(string.IsNullOrEmpty(player.PlayerName) ? player.SteamID.ToString() : player.PlayerName)} {speed}");
|
||||||
@@ -313,13 +320,11 @@ public partial class CS2_SimpleAdmin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[ConsoleCommand("css_gravity")]
|
|
||||||
[RequiresPermissions("@css/slay")]
|
[RequiresPermissions("@css/slay")]
|
||||||
[CommandHelper(minArgs: 1, usage: "<#userid or name> <gravity>", whoCanExecute: CommandUsage.CLIENT_AND_SERVER)]
|
[CommandHelper(minArgs: 1, usage: "<#userid or name> <gravity>", whoCanExecute: CommandUsage.CLIENT_AND_SERVER)]
|
||||||
public void OnGravityCommand(CCSPlayerController? caller, CommandInfo command)
|
public void OnGravityCommand(CCSPlayerController? caller, CommandInfo command)
|
||||||
{
|
{
|
||||||
var callerName = caller == null ? _localizer?["sa_console"] ?? "Console" : caller.PlayerName;
|
float.TryParse(command.GetArg(2), NumberStyles.Float, CultureInfo.InvariantCulture, out var gravity);
|
||||||
float.TryParse(command.GetArg(2), out var gravity);
|
|
||||||
|
|
||||||
var targets = GetTarget(command);
|
var targets = GetTarget(command);
|
||||||
if (targets == null) return;
|
if (targets == null) return;
|
||||||
@@ -348,6 +353,11 @@ public partial class CS2_SimpleAdmin
|
|||||||
// Set player's gravity
|
// Set player's gravity
|
||||||
player.SetGravity(gravity);
|
player.SetGravity(gravity);
|
||||||
|
|
||||||
|
if (gravity == 1f)
|
||||||
|
GravityPlayers.Remove(player);
|
||||||
|
else
|
||||||
|
GravityPlayers[player] = gravity;
|
||||||
|
|
||||||
// Log the command
|
// Log the command
|
||||||
if (command == null)
|
if (command == null)
|
||||||
Helper.LogCommand(caller, $"css_gravity {(string.IsNullOrEmpty(player.PlayerName) ? player.SteamID.ToString() : player.PlayerName)} {gravity}");
|
Helper.LogCommand(caller, $"css_gravity {(string.IsNullOrEmpty(player.PlayerName) ? player.SteamID.ToString() : player.PlayerName)} {gravity}");
|
||||||
|
|||||||
@@ -221,6 +221,9 @@ public class OtherSettings
|
|||||||
|
|
||||||
[JsonPropertyName("ShowBanMenuIfNoTime")]
|
[JsonPropertyName("ShowBanMenuIfNoTime")]
|
||||||
public bool ShowBanMenuIfNoTime { get; set; } = true;
|
public bool ShowBanMenuIfNoTime { get; set; } = true;
|
||||||
|
|
||||||
|
[JsonPropertyName("UserMessageGagChatType")]
|
||||||
|
public bool UserMessageGagChatType { get; set; } = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public class CS2_SimpleAdminConfig : BasePluginConfig
|
public class CS2_SimpleAdminConfig : BasePluginConfig
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ using CS2_SimpleAdminApi;
|
|||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using CounterStrikeSharp.API.Modules.Admin;
|
using CounterStrikeSharp.API.Modules.Admin;
|
||||||
|
using CounterStrikeSharp.API.Modules.UserMessages;
|
||||||
|
|
||||||
namespace CS2_SimpleAdmin;
|
namespace CS2_SimpleAdmin;
|
||||||
|
|
||||||
@@ -17,31 +18,33 @@ public partial class CS2_SimpleAdmin
|
|||||||
{
|
{
|
||||||
private void RegisterEvents()
|
private void RegisterEvents()
|
||||||
{
|
{
|
||||||
RegisterListener<Listeners.OnMapStart>(OnMapStart);
|
|
||||||
RegisterListener<Listeners.OnMapStart>(OnMapStart);
|
RegisterListener<Listeners.OnMapStart>(OnMapStart);
|
||||||
RegisterListener<Listeners.OnGameServerSteamAPIActivated>(OnGameServerSteamAPIActivated);
|
RegisterListener<Listeners.OnGameServerSteamAPIActivated>(OnGameServerSteamAPIActivated);
|
||||||
AddCommandListener(null, OnCommandSayNew);
|
if (Config.OtherSettings.UserMessageGagChatType)
|
||||||
AddCommandListener("callvote", OnCommandCallVote);
|
HookUserMessage(118, HookUmChat);
|
||||||
|
|
||||||
|
AddCommandListener(null, ComamndListenerHandler);
|
||||||
|
// AddCommandListener("callvote", OnCommandCallVote);
|
||||||
// AddCommandListener("say", OnCommandSay);
|
// AddCommandListener("say", OnCommandSay);
|
||||||
// AddCommandListener("say_team", OnCommandTeamSay);
|
// AddCommandListener("say_team", OnCommandTeamSay);
|
||||||
}
|
}
|
||||||
|
|
||||||
private HookResult OnCommandCallVote(CCSPlayerController? caller, CommandInfo info)
|
// private HookResult OnCommandCallVote(CCSPlayerController? caller, CommandInfo info)
|
||||||
{
|
// {
|
||||||
var voteType = info.GetArg(1).ToLower();
|
// var voteType = info.GetArg(1).ToLower();
|
||||||
|
//
|
||||||
if (voteType != "kick")
|
// if (voteType != "kick")
|
||||||
return HookResult.Continue;
|
// return HookResult.Continue;
|
||||||
|
//
|
||||||
var target = int.TryParse(info.GetArg(2), out var userId)
|
// var target = int.TryParse(info.GetArg(2), out var userId)
|
||||||
? Utilities.GetPlayerFromUserid(userId)
|
// ? Utilities.GetPlayerFromUserid(userId)
|
||||||
: null;
|
// : null;
|
||||||
|
//
|
||||||
if (target == null || !target.IsValid || target.Connected != PlayerConnectedState.PlayerConnected)
|
// if (target == null || !target.IsValid || target.Connected != PlayerConnectedState.PlayerConnected)
|
||||||
return HookResult.Continue;
|
// return HookResult.Continue;
|
||||||
|
//
|
||||||
return !AdminManager.CanPlayerTarget(caller, target) ? HookResult.Stop : HookResult.Continue;
|
// return !AdminManager.CanPlayerTarget(caller, target) ? HookResult.Stop : HookResult.Continue;
|
||||||
}
|
// }
|
||||||
|
|
||||||
private void OnGameServerSteamAPIActivated()
|
private void OnGameServerSteamAPIActivated()
|
||||||
{
|
{
|
||||||
@@ -88,6 +91,8 @@ public partial class CS2_SimpleAdmin
|
|||||||
|
|
||||||
SilentPlayers.Remove(player.Slot);
|
SilentPlayers.Remove(player.Slot);
|
||||||
GodPlayers.Remove(player.Slot);
|
GodPlayers.Remove(player.Slot);
|
||||||
|
SpeedPlayers.Remove(player.Slot);
|
||||||
|
GravityPlayers.Remove(player);
|
||||||
|
|
||||||
if (player.UserId.HasValue)
|
if (player.UserId.HasValue)
|
||||||
PlayersInfo.Remove(player.UserId.Value);
|
PlayersInfo.Remove(player.UserId.Value);
|
||||||
@@ -123,13 +128,16 @@ public partial class CS2_SimpleAdmin
|
|||||||
}
|
}
|
||||||
|
|
||||||
[GameEventHandler]
|
[GameEventHandler]
|
||||||
public HookResult OnRoundEnd(EventRoundStart @event, GameEventInfo info)
|
public HookResult OnRoundStart(EventRoundStart @event, GameEventInfo info)
|
||||||
{
|
{
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
Logger.LogCritical("[OnRoundEnd]");
|
Logger.LogCritical("[OnRoundEnd]");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
GodPlayers.Clear();
|
GodPlayers.Clear();
|
||||||
|
SpeedPlayers.Clear();
|
||||||
|
GravityPlayers.Clear();
|
||||||
|
|
||||||
foreach (var player in PlayersInfo.Values)
|
foreach (var player in PlayersInfo.Values)
|
||||||
{
|
{
|
||||||
player.DiePosition = null;
|
player.DiePosition = null;
|
||||||
@@ -154,22 +162,57 @@ public partial class CS2_SimpleAdmin
|
|||||||
return HookResult.Continue;
|
return HookResult.Continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
private HookResult OnCommandSayNew(CCSPlayerController? player, CommandInfo info)
|
private HookResult HookUmChat(UserMessage um)
|
||||||
|
{
|
||||||
|
var author = Utilities.GetPlayerFromIndex(um.ReadInt("entityindex"));
|
||||||
|
if (author == null || !author.IsValid || author.IsBot)
|
||||||
|
return HookResult.Continue;
|
||||||
|
|
||||||
|
if (PlayerPenaltyManager.IsPenalized(author.Slot, PenaltyType.Gag) || PlayerPenaltyManager.IsPenalized(author.Slot, PenaltyType.Silence))
|
||||||
|
return HookResult.Stop;
|
||||||
|
|
||||||
|
// um.Recipients.Clear();
|
||||||
|
|
||||||
|
return HookResult.Continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
private HookResult ComamndListenerHandler(CCSPlayerController? player, CommandInfo info)
|
||||||
{
|
{
|
||||||
if (player == null || !player.IsValid || player.IsBot)
|
if (player == null || !player.IsValid || player.IsBot)
|
||||||
return HookResult.Continue;
|
return HookResult.Continue;
|
||||||
|
|
||||||
var command = info.GetArg(0).ToLower();
|
var command = info.GetArg(0).ToLower();
|
||||||
|
|
||||||
if (command == "css_admins_reload")
|
switch (command)
|
||||||
{
|
{
|
||||||
|
case "css_admins_reload":
|
||||||
AddTimer(1.0f, () => ReloadAdmins(null));
|
AddTimer(1.0f, () => ReloadAdmins(null));
|
||||||
return HookResult.Continue;
|
return HookResult.Continue;
|
||||||
|
case "callvote":
|
||||||
|
{
|
||||||
|
var voteType = info.GetArg(1).ToLower();
|
||||||
|
|
||||||
|
if (voteType != "kick")
|
||||||
|
return HookResult.Continue;
|
||||||
|
|
||||||
|
var target = int.TryParse(info.GetArg(2), out var userId)
|
||||||
|
? Utilities.GetPlayerFromUserid(userId)
|
||||||
|
: null;
|
||||||
|
|
||||||
|
if (target == null || !target.IsValid || target.Connected != PlayerConnectedState.PlayerConnected)
|
||||||
|
return HookResult.Continue;
|
||||||
|
|
||||||
|
return !AdminManager.CanPlayerTarget(player, target) ? HookResult.Stop : HookResult.Continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!command.Contains("say"))
|
if (!command.Contains("say"))
|
||||||
return HookResult.Continue;
|
return HookResult.Continue;
|
||||||
|
|
||||||
|
if (!Config.OtherSettings.UserMessageGagChatType)
|
||||||
|
if (PlayerPenaltyManager.IsPenalized(player.Slot, PenaltyType.Gag) || PlayerPenaltyManager.IsPenalized(player.Slot, PenaltyType.Silence))
|
||||||
|
return HookResult.Stop;
|
||||||
|
|
||||||
if (info.GetArg(1).StartsWith($"/")
|
if (info.GetArg(1).StartsWith($"/")
|
||||||
|| info.GetArg(1).StartsWith($"!"))
|
|| info.GetArg(1).StartsWith($"!"))
|
||||||
return HookResult.Continue;
|
return HookResult.Continue;
|
||||||
@@ -177,9 +220,6 @@ public partial class CS2_SimpleAdmin
|
|||||||
if (info.GetArg(1).Length == 0)
|
if (info.GetArg(1).Length == 0)
|
||||||
return HookResult.Stop;
|
return HookResult.Stop;
|
||||||
|
|
||||||
if (PlayerPenaltyManager.IsPenalized(player.Slot, PenaltyType.Gag) || PlayerPenaltyManager.IsPenalized(player.Slot, PenaltyType.Silence))
|
|
||||||
return HookResult.Stop;
|
|
||||||
|
|
||||||
if (command == "say" && info.GetArg(1).StartsWith($"@") &&
|
if (command == "say" && info.GetArg(1).StartsWith($"@") &&
|
||||||
AdminManager.PlayerHasPermissions(player, "@css/chat"))
|
AdminManager.PlayerHasPermissions(player, "@css/chat"))
|
||||||
{
|
{
|
||||||
@@ -282,6 +322,8 @@ public partial class CS2_SimpleAdmin
|
|||||||
|
|
||||||
GodPlayers.Clear();
|
GodPlayers.Clear();
|
||||||
SilentPlayers.Clear();
|
SilentPlayers.Clear();
|
||||||
|
SpeedPlayers.Clear();
|
||||||
|
GravityPlayers.Clear();
|
||||||
|
|
||||||
PlayerPenaltyManager.RemoveAllPenalties();
|
PlayerPenaltyManager.RemoveAllPenalties();
|
||||||
}
|
}
|
||||||
@@ -294,6 +336,9 @@ public partial class CS2_SimpleAdmin
|
|||||||
if (player is null || @event.Attacker is null || !player.PawnIsAlive || player.PlayerPawn.Value == null)
|
if (player is null || @event.Attacker is null || !player.PawnIsAlive || player.PlayerPawn.Value == null)
|
||||||
return HookResult.Continue;
|
return HookResult.Continue;
|
||||||
|
|
||||||
|
if (SpeedPlayers.TryGetValue(player.Slot, out var speedPlayer))
|
||||||
|
player.SetSpeed(speedPlayer);
|
||||||
|
|
||||||
if (!GodPlayers.Contains(player.Slot)) return HookResult.Continue;
|
if (!GodPlayers.Contains(player.Slot)) return HookResult.Continue;
|
||||||
|
|
||||||
player.PlayerPawn.Value.Health = player.PlayerPawn.Value.MaxHealth;
|
player.PlayerPawn.Value.Health = player.PlayerPawn.Value.MaxHealth;
|
||||||
@@ -310,6 +355,9 @@ public partial class CS2_SimpleAdmin
|
|||||||
if (player?.UserId == null || player.IsBot || player.Connected != PlayerConnectedState.PlayerConnected)
|
if (player?.UserId == null || player.IsBot || player.Connected != PlayerConnectedState.PlayerConnected)
|
||||||
return HookResult.Continue;
|
return HookResult.Continue;
|
||||||
|
|
||||||
|
SpeedPlayers.Remove(player.Slot);
|
||||||
|
GravityPlayers.Remove(player);
|
||||||
|
|
||||||
PlayersInfo[player.UserId.Value].DiePosition =
|
PlayersInfo[player.UserId.Value].DiePosition =
|
||||||
new DiePosition(
|
new DiePosition(
|
||||||
new Vector(player.PlayerPawn.Value?.AbsOrigin?.X, player.PlayerPawn.Value?.AbsOrigin?.Y,
|
new Vector(player.PlayerPawn.Value?.AbsOrigin?.X, player.PlayerPawn.Value?.AbsOrigin?.Y,
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ using CounterStrikeSharp.API.Modules.Entities;
|
|||||||
using CounterStrikeSharp.API.Modules.Memory;
|
using CounterStrikeSharp.API.Modules.Memory;
|
||||||
using Microsoft.Extensions.Localization;
|
using Microsoft.Extensions.Localization;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using CounterStrikeSharp.API.Modules.UserMessages;
|
||||||
using Vector = CounterStrikeSharp.API.Modules.Utils.Vector;
|
using Vector = CounterStrikeSharp.API.Modules.Utils.Vector;
|
||||||
|
|
||||||
namespace CS2_SimpleAdmin;
|
namespace CS2_SimpleAdmin;
|
||||||
@@ -93,8 +94,8 @@ public static class PlayerExtensions
|
|||||||
|
|
||||||
public static void Freeze(this CBasePlayerPawn pawn)
|
public static void Freeze(this CBasePlayerPawn pawn)
|
||||||
{
|
{
|
||||||
pawn.MoveType = MoveType_t.MOVETYPE_OBSOLETE;
|
pawn.MoveType = MoveType_t.MOVETYPE_INVALID;
|
||||||
Schema.SetSchemaValue(pawn.Handle, "CBaseEntity", "m_nActualMoveType", 1); // obsolete
|
Schema.SetSchemaValue(pawn.Handle, "CBaseEntity", "m_nActualMoveType", 11); // invalid
|
||||||
Utilities.SetStateChanged(pawn, "CBaseEntity", "m_MoveType");
|
Utilities.SetStateChanged(pawn, "CBaseEntity", "m_MoveType");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -171,6 +172,8 @@ public static class PlayerExtensions
|
|||||||
if (pawn.LifeState != (int)LifeState_t.LIFE_ALIVE)
|
if (pawn.LifeState != (int)LifeState_t.LIFE_ALIVE)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
var controller = pawn.Controller.Value?.As<CCSPlayerController>();
|
||||||
|
|
||||||
/* Teleport in a random direction - thank you, Mani!*/
|
/* Teleport in a random direction - thank you, Mani!*/
|
||||||
/* Thank you AM & al!*/
|
/* Thank you AM & al!*/
|
||||||
var random = new Random();
|
var random = new Random();
|
||||||
@@ -184,6 +187,17 @@ public static class PlayerExtensions
|
|||||||
pawn.AbsVelocity.Y = vel.Y;
|
pawn.AbsVelocity.Y = vel.Y;
|
||||||
pawn.AbsVelocity.Z = vel.Z;
|
pawn.AbsVelocity.Z = vel.Z;
|
||||||
|
|
||||||
|
if (controller != null && controller.IsValid)
|
||||||
|
{
|
||||||
|
var shakeMessage = UserMessage.FromPartialName("Shake");
|
||||||
|
shakeMessage.SetFloat("duration", 1);
|
||||||
|
shakeMessage.SetFloat("amplitude", 10);
|
||||||
|
shakeMessage.SetFloat("frequency", 1f);
|
||||||
|
shakeMessage.SetInt("command", 0);
|
||||||
|
shakeMessage.Recipients.Add(controller);
|
||||||
|
shakeMessage.Send();
|
||||||
|
}
|
||||||
|
|
||||||
if (damage <= 0)
|
if (damage <= 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|||||||
@@ -690,11 +690,30 @@ public static class WeaponHelper
|
|||||||
|
|
||||||
public static List<(string EnumMemberValue, CsItem EnumValue)> GetWeaponsByPartialName(string input)
|
public static List<(string EnumMemberValue, CsItem EnumValue)> GetWeaponsByPartialName(string input)
|
||||||
{
|
{
|
||||||
|
// Normalize input for case-insensitive comparison
|
||||||
|
var normalizedInput = input.ToLowerInvariant();
|
||||||
|
|
||||||
|
// Find all matching weapons based on the input
|
||||||
var matchingWeapons = WeaponsEnumCache.Value
|
var matchingWeapons = WeaponsEnumCache.Value
|
||||||
.Where(kvp => kvp.Key.Contains(input))
|
.Where(kvp => kvp.Key.Contains(normalizedInput, StringComparison.InvariantCultureIgnoreCase))
|
||||||
.Select(kvp => (kvp.Key, kvp.Value))
|
.Select(kvp => (EnumMemberValue: kvp.Key, EnumValue: kvp.Value))
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
return matchingWeapons;
|
// Check for an exact match first
|
||||||
|
var exactMatch = matchingWeapons
|
||||||
|
.FirstOrDefault(m => m.EnumMemberValue.Equals(input, StringComparison.OrdinalIgnoreCase));
|
||||||
|
|
||||||
|
if (exactMatch.EnumMemberValue != null)
|
||||||
|
{
|
||||||
|
// Return a list containing only the exact match
|
||||||
|
return [exactMatch];
|
||||||
|
}
|
||||||
|
|
||||||
|
// If no exact match, get all matches that start with the input
|
||||||
|
var filteredWeapons = matchingWeapons
|
||||||
|
.Where(m => m.EnumMemberValue.StartsWith(normalizedInput, StringComparison.InvariantCultureIgnoreCase))
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
return filteredWeapons; // Return all relevant matches for the partial input
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ using CounterStrikeSharp.API;
|
|||||||
using CounterStrikeSharp.API.Core;
|
using CounterStrikeSharp.API.Core;
|
||||||
using CounterStrikeSharp.API.Modules.Admin;
|
using CounterStrikeSharp.API.Modules.Admin;
|
||||||
using CounterStrikeSharp.API.Modules.Entities;
|
using CounterStrikeSharp.API.Modules.Entities;
|
||||||
|
using CounterStrikeSharp.API.Modules.Timers;
|
||||||
using CounterStrikeSharp.API.ValveConstants.Protobuf;
|
using CounterStrikeSharp.API.ValveConstants.Protobuf;
|
||||||
using CS2_SimpleAdminApi;
|
using CS2_SimpleAdminApi;
|
||||||
using Dapper;
|
using Dapper;
|
||||||
@@ -205,6 +206,20 @@ public class PlayerManager
|
|||||||
|
|
||||||
public void CheckPlayersTimer()
|
public void CheckPlayersTimer()
|
||||||
{
|
{
|
||||||
|
CS2_SimpleAdmin.Instance.AddTimer(0.1f, () =>
|
||||||
|
{
|
||||||
|
if (CS2_SimpleAdmin.GravityPlayers.Count <= 0) return;
|
||||||
|
|
||||||
|
foreach (var value in CS2_SimpleAdmin.GravityPlayers)
|
||||||
|
{
|
||||||
|
if (value.Key is not
|
||||||
|
{ IsValid: true, Connected: PlayerConnectedState.PlayerConnected, PawnIsAlive: true })
|
||||||
|
continue;
|
||||||
|
|
||||||
|
value.Key.SetGravity(value.Value);
|
||||||
|
}
|
||||||
|
}, TimerFlags.REPEAT);
|
||||||
|
|
||||||
CS2_SimpleAdmin.Instance.AddTimer(61.0f, () =>
|
CS2_SimpleAdmin.Instance.AddTimer(61.0f, () =>
|
||||||
{
|
{
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
@@ -214,23 +229,50 @@ public class PlayerManager
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
var players = Helper.GetValidPlayers();
|
var players = Helper.GetValidPlayers();
|
||||||
var onlinePlayers = players
|
var onlinePlayers = new List<(string? IpAddress, ulong SteamID, int? UserId, int Slot)>();
|
||||||
.Where(player => player.IpAddress != null)
|
// var onlinePlayers = players
|
||||||
.Select(player => (player.IpAddress, player.SteamID, player.UserId, player.Slot))
|
// .Where(player => player.IpAddress != null)
|
||||||
.ToList();
|
// .Select(player => (player.IpAddress, player.SteamID, player.UserId, player.Slot))
|
||||||
|
// .ToList();
|
||||||
|
|
||||||
Task.Run(async () =>
|
foreach (var player in players)
|
||||||
{
|
{
|
||||||
await CS2_SimpleAdmin.Instance.MuteManager.ExpireOldMutes();
|
if (player.IpAddress != null)
|
||||||
await CS2_SimpleAdmin.Instance.BanManager.ExpireOldBans();
|
onlinePlayers.Add((player.IpAddress, player.SteamID, player.UserId, player.Slot));
|
||||||
await CS2_SimpleAdmin.Instance.WarnManager.ExpireOldWarns();
|
}
|
||||||
await CS2_SimpleAdmin.Instance.PermissionManager.DeleteOldAdmins();
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var expireTasks = new[]
|
||||||
|
{
|
||||||
|
CS2_SimpleAdmin.Instance.BanManager.ExpireOldBans(),
|
||||||
|
CS2_SimpleAdmin.Instance.MuteManager.ExpireOldMutes(),
|
||||||
|
CS2_SimpleAdmin.Instance.WarnManager.ExpireOldWarns(),
|
||||||
|
CS2_SimpleAdmin.Instance.PermissionManager.DeleteOldAdmins()
|
||||||
|
};
|
||||||
|
|
||||||
|
Task.WhenAll(expireTasks).ContinueWith(t =>
|
||||||
|
{
|
||||||
|
if (t is not { IsFaulted: true, Exception: not null }) return;
|
||||||
|
|
||||||
|
foreach (var ex in t.Exception.InnerExceptions)
|
||||||
|
{
|
||||||
|
CS2_SimpleAdmin._logger?.LogError($"Error expiring penalties: {ex.Message}");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
CS2_SimpleAdmin._logger?.LogError($"Unexpected error: {ex.Message}");
|
||||||
|
}
|
||||||
|
|
||||||
CS2_SimpleAdmin.BannedPlayers.Clear();
|
CS2_SimpleAdmin.BannedPlayers.Clear();
|
||||||
|
|
||||||
if (onlinePlayers.Count > 0)
|
if (onlinePlayers.Count > 0)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
{
|
||||||
|
Task.Run(async () =>
|
||||||
{
|
{
|
||||||
await CS2_SimpleAdmin.Instance.BanManager.CheckOnlinePlayers(onlinePlayers);
|
await CS2_SimpleAdmin.Instance.BanManager.CheckOnlinePlayers(onlinePlayers);
|
||||||
|
|
||||||
@@ -238,39 +280,54 @@ public class PlayerManager
|
|||||||
{
|
{
|
||||||
await CS2_SimpleAdmin.Instance.MuteManager.CheckOnlineModeMutes(onlinePlayers);
|
await CS2_SimpleAdmin.Instance.MuteManager.CheckOnlineModeMutes(onlinePlayers);
|
||||||
}
|
}
|
||||||
}
|
}).ContinueWith(t =>
|
||||||
catch (Exception)
|
|
||||||
{
|
{
|
||||||
CS2_SimpleAdmin._logger?.LogError("Unable to check bans for online players");
|
if (t is not { IsFaulted: true, Exception: not null }) return;
|
||||||
|
|
||||||
|
foreach (var ex in t.Exception.InnerExceptions)
|
||||||
|
{
|
||||||
|
CS2_SimpleAdmin._logger?.LogError($"Error checking online players: {ex.Message}");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
CS2_SimpleAdmin._logger?.LogError($"Unexpected error: {ex.Message}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
await Server.NextFrameAsync(() =>
|
if (onlinePlayers.Count <= 0) return;
|
||||||
{
|
|
||||||
if (onlinePlayers.Count > 0)
|
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
foreach (var player in players.Where(player => PlayerPenaltyManager.IsSlotInPenalties(player.Slot)))
|
var penalizedSlots = players
|
||||||
|
.Where(player => PlayerPenaltyManager.IsSlotInPenalties(player.Slot))
|
||||||
|
.Select(player => new
|
||||||
{
|
{
|
||||||
if (!PlayerPenaltyManager.IsPenalized(player.Slot, PenaltyType.Mute) && !PlayerPenaltyManager.IsPenalized(player.Slot, PenaltyType.Silence))
|
Player = player,
|
||||||
player.VoiceFlags = VoiceFlags.Normal;
|
IsMuted = PlayerPenaltyManager.IsPenalized(player.Slot, PenaltyType.Mute),
|
||||||
|
IsSilenced = PlayerPenaltyManager.IsPenalized(player.Slot, PenaltyType.Silence),
|
||||||
|
IsGagged = PlayerPenaltyManager.IsPenalized(player.Slot, PenaltyType.Gag)
|
||||||
|
});
|
||||||
|
|
||||||
if (PlayerPenaltyManager.IsPenalized(player.Slot, PenaltyType.Silence) ||
|
foreach (var entry in penalizedSlots)
|
||||||
PlayerPenaltyManager.IsPenalized(player.Slot, PenaltyType.Mute) ||
|
{
|
||||||
PlayerPenaltyManager.IsPenalized(player.Slot, PenaltyType.Gag)) continue;
|
// If the player is not muted or silenced, set voice flags to normal
|
||||||
player.VoiceFlags = VoiceFlags.Normal;
|
if (!entry.IsMuted && !entry.IsSilenced)
|
||||||
|
{
|
||||||
|
entry.Player.VoiceFlags = VoiceFlags.Normal;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PlayerPenaltyManager.RemoveExpiredPenalties();
|
PlayerPenaltyManager.RemoveExpiredPenalties();
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
CS2_SimpleAdmin._logger?.LogError("Unable to remove old penalties");
|
CS2_SimpleAdmin._logger?.LogError($"Unable to remove old penalties: {ex.Message}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
|
||||||
});
|
|
||||||
}, CounterStrikeSharp.API.Modules.Timers.TimerFlags.REPEAT);
|
}, CounterStrikeSharp.API.Modules.Timers.TimerFlags.REPEAT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -7,7 +7,7 @@ namespace CS2_SimpleAdmin.Managers;
|
|||||||
|
|
||||||
public class ServerManager
|
public class ServerManager
|
||||||
{
|
{
|
||||||
private int _getIpTryCount = 0;
|
private int _getIpTryCount;
|
||||||
|
|
||||||
public void LoadServerData()
|
public void LoadServerData()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
1.6.5a
|
1.6.6a
|
||||||
@@ -8,7 +8,7 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="CounterStrikeSharp.API" Version="1.0.276" />
|
<PackageReference Include="CounterStrikeSharp.API" Version="1.0.284" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ public class PlayerInfo(
|
|||||||
public DiePosition? DiePosition { get; set; }
|
public DiePosition? DiePosition { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class DiePosition(Vector? position = null, QAngle? angle = null)
|
public struct DiePosition(Vector? position = null, QAngle? angle = null)
|
||||||
{
|
{
|
||||||
public Vector? Position { get; set; } = position;
|
public Vector? Position { get; set; } = position;
|
||||||
public QAngle? Angle { get; set; } = angle;
|
public QAngle? Angle { get; set; } = angle;
|
||||||
|
|||||||
Reference in New Issue
Block a user