mirror of
https://github.com/daffyyyy/CS2-SimpleAdmin.git
synced 2026-02-18 10:43:23 +00:00
AntiDLL Module Fix
Fixed banning when detecting a forbidden event
This commit is contained in:
@@ -585,7 +585,7 @@ internal static class Helper
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void SendDiscordPenaltyMessage(CCSPlayerController? caller, string steamId, string reason, int duration, PenaltyType penalty, IStringLocalizer? localizer)
|
public static void SendDiscordPenaltyMessage(CCSPlayerController? caller, string steamId, string reason, int duration, PenaltyType penalty, IStringLocalizer? localizer)
|
||||||
{
|
{
|
||||||
if (localizer == null) return;
|
if (localizer == null) return;
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
using CounterStrikeSharp.API.ValveConstants.Protobuf;
|
namespace AntiDLL_CS2_SimpleAdmin;
|
||||||
|
|
||||||
namespace AntiDLL_CS2_SimpleAdmin;
|
|
||||||
|
|
||||||
|
using CounterStrikeSharp.API.Core.Attributes.Registration;
|
||||||
|
using CounterStrikeSharp.API.ValveConstants.Protobuf;
|
||||||
using System.Text.Json.Serialization;
|
using System.Text.Json.Serialization;
|
||||||
using CounterStrikeSharp.API;
|
using CounterStrikeSharp.API;
|
||||||
using CounterStrikeSharp.API.Modules.Entities;
|
using CounterStrikeSharp.API.Modules.Entities;
|
||||||
@@ -9,7 +9,6 @@ using CS2_SimpleAdminApi;
|
|||||||
using CounterStrikeSharp.API.Core;
|
using CounterStrikeSharp.API.Core;
|
||||||
using CounterStrikeSharp.API.Core.Capabilities;
|
using CounterStrikeSharp.API.Core.Capabilities;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
using AntiDLL.API;
|
using AntiDLL.API;
|
||||||
|
|
||||||
public class PluginConfig : IBasePluginConfig
|
public class PluginConfig : IBasePluginConfig
|
||||||
@@ -23,16 +22,17 @@ public class PluginConfig : IBasePluginConfig
|
|||||||
|
|
||||||
public sealed class AntiDLL_CS2_SimpleAdmin : BasePlugin, IPluginConfig<PluginConfig>
|
public sealed class AntiDLL_CS2_SimpleAdmin : BasePlugin, IPluginConfig<PluginConfig>
|
||||||
{
|
{
|
||||||
|
private int _banType;
|
||||||
public PluginConfig Config { get; set; } = new();
|
public PluginConfig Config { get; set; } = new();
|
||||||
private readonly HashSet<int> _bannedPlayers = [];
|
private readonly HashSet<int> _bannedPlayers = [];
|
||||||
|
private readonly HashSet<int> _detections = [];
|
||||||
private static PluginCapability<IAntiDLL> AntiDll { get; } = new("AntiDLL");
|
private static PluginCapability<IAntiDLL> AntiDll { get; } = new("AntiDLL");
|
||||||
private static PluginCapability<ICS2_SimpleAdminApi> SimpleAdminApi { get; } = new("simpleadmin:api");
|
private static PluginCapability<ICS2_SimpleAdminApi> SimpleAdminApi { get; } = new("simpleadmin:api");
|
||||||
private int _banType = 0;
|
|
||||||
private static ICS2_SimpleAdminApi? _simpleAdminApi;
|
private static ICS2_SimpleAdminApi? _simpleAdminApi;
|
||||||
|
|
||||||
public override string ModuleName => "AntiDLL [CS2-SimpleAdmin Module]";
|
public override string ModuleName => "AntiDLL [CS2-SimpleAdmin Module]";
|
||||||
public override string ModuleDescription => "AntiDLL module for CS2-SimpleAdmin integration";
|
public override string ModuleDescription => "AntiDLL module for CS2-SimpleAdmin integration";
|
||||||
public override string ModuleVersion => "1.0.0";
|
public override string ModuleVersion => "1.0.1";
|
||||||
public override string ModuleAuthor => "daffyy";
|
public override string ModuleAuthor => "daffyy";
|
||||||
|
|
||||||
public override void Load(bool hotReload)
|
public override void Load(bool hotReload)
|
||||||
@@ -65,6 +65,9 @@ public sealed class AntiDLL_CS2_SimpleAdmin : BasePlugin, IPluginConfig<PluginCo
|
|||||||
Unload(false);
|
Unload(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Config.BanType != "auto" && Config.BanType != "simpleadmin")
|
||||||
|
return;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_simpleAdminApi = SimpleAdminApi.Get();
|
_simpleAdminApi = SimpleAdminApi.Get();
|
||||||
@@ -79,22 +82,45 @@ public sealed class AntiDLL_CS2_SimpleAdmin : BasePlugin, IPluginConfig<PluginCo
|
|||||||
|
|
||||||
private void OnClientDisconnect(int playerSlot)
|
private void OnClientDisconnect(int playerSlot)
|
||||||
{
|
{
|
||||||
var player = Utilities.GetPlayerFromSlot(playerSlot);
|
// var player = Utilities.GetPlayerFromSlot(playerSlot);
|
||||||
if (player == null || !player.IsValid || player.IsBot)
|
// if (player == null || !player.IsValid || player.IsBot)
|
||||||
return;
|
// return;
|
||||||
|
|
||||||
_bannedPlayers.Remove(playerSlot);
|
_bannedPlayers.Remove(playerSlot);
|
||||||
|
_detections.Remove(playerSlot);
|
||||||
|
}
|
||||||
|
|
||||||
|
[GameEventHandler]
|
||||||
|
public HookResult OnPlayerSpawn(EventPlayerSpawn @event, GameEventInfo _)
|
||||||
|
{
|
||||||
|
var player = @event.Userid;
|
||||||
|
if (player == null || !player.IsValid || player.IsBot || !_detections.Contains(player.Slot))
|
||||||
|
return HookResult.Continue;
|
||||||
|
|
||||||
|
if (!_bannedPlayers.Contains(player.Slot) && player.Connected == PlayerConnectedState.PlayerConnected && player.TeamNum != 0)
|
||||||
|
PunishPlayer(player);
|
||||||
|
|
||||||
|
return HookResult.Continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnDetection(CCSPlayerController? player, string eventName)
|
private void OnDetection(CCSPlayerController? player, string eventName)
|
||||||
{
|
{
|
||||||
if (player == null || !player.IsValid || player.IsBot) return;
|
if (player == null || !player.IsValid || player.IsBot) return;
|
||||||
if (player.Connected != PlayerConnectedState.PlayerConnected)
|
if (!_detections.Add(player.Slot))
|
||||||
{
|
|
||||||
AddTimer(3.0f, () => OnDetection(player, eventName));
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
|
// if (player.Connected != PlayerConnectedState.PlayerConnected)
|
||||||
|
// {
|
||||||
|
// _detections.Add(player.Slot);
|
||||||
|
// // AddTimer(3.0f, () => OnDetection(player, eventName));
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
|
||||||
|
Logger.LogInformation("Detected \"{eventName}\" for \"{player}({steamid})\"", eventName, player.PlayerName, player.SteamID.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void PunishPlayer(CCSPlayerController player)
|
||||||
|
{
|
||||||
if (!_bannedPlayers.Add(player.Slot))
|
if (!_bannedPlayers.Add(player.Slot))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -104,7 +130,7 @@ public sealed class AntiDLL_CS2_SimpleAdmin : BasePlugin, IPluginConfig<PluginCo
|
|||||||
}
|
}
|
||||||
else if (Config.BanType == "kick")
|
else if (Config.BanType == "kick")
|
||||||
{
|
{
|
||||||
player.Disconnect(NetworkDisconnectionReason.NETWORK_DISCONNECT_KICKED_UNTRUSTEDACCOUNT);
|
player.Disconnect(NetworkDisconnectionReason.NETWORK_DISCONNECT_KICKED_VACNETABNORMALBEHAVIOR);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
@@ -1,16 +0,0 @@
|
|||||||
"Config"
|
|
||||||
{
|
|
||||||
// Доступные переменные: {userid}, {steamid}, {name}
|
|
||||||
"punish_type" "1" // 0 - kick, 1 - command(punish_command)
|
|
||||||
|
|
||||||
"punish_command" "css_addban {steamid} 0 [AC] Cheats detected #5" // Command to execute when a player is detected with a DLL
|
|
||||||
// Команда для выполнения, когда игрок обнаружен с DLL
|
|
||||||
|
|
||||||
"chat_message" "" // Сообщение в чат при обнаружении DLL для всех игроков, пусто - не отправлять
|
|
||||||
// Chat message when a player is detected with a DLL for all players, empty - dont send
|
|
||||||
"logs" "1" // Логировать в файл наказания? 0 - нет, 1 - да
|
|
||||||
// Log punishments to file? 0 - no, 1 - yes
|
|
||||||
|
|
||||||
"interval" "120" // Интервал проверки игроков на наличие DLL в секундах
|
|
||||||
// Interval to check players for DLL in seconds
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user