mirror of
https://github.com/daffyyyy/CS2-SimpleAdmin.git
synced 2026-02-18 10:43:23 +00:00
1.3.0f
- Fixed `css_kick` - Fixed gag/mute/silence on connect - Additional check in immunity
This commit is contained in:
@@ -27,12 +27,9 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
||||
{
|
||||
public static BasePlugin? _plugin = null;
|
||||
public static IStringLocalizer? _localizer;
|
||||
//public static ConcurrentBag<int> mutedPlayers = new ConcurrentBag<int>();
|
||||
public static Dictionary<string, int> voteAnswers = new Dictionary<string, int>();
|
||||
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;
|
||||
@@ -48,7 +45,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.0e";
|
||||
public override string ModuleVersion => "1.3.0f";
|
||||
|
||||
public CS2_SimpleAdminConfig Config { get; set; } = new();
|
||||
|
||||
@@ -425,7 +422,10 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
||||
string reason = "Unknown";
|
||||
|
||||
TargetResult? targets = GetTarget(command);
|
||||
if (targets == null) return;
|
||||
|
||||
if (targets == null)
|
||||
return;
|
||||
|
||||
List<CCSPlayerController> playersToTarget = targets!.Players.Where(player => player != null && player.IsValid && !player.IsHLTV).ToList();
|
||||
|
||||
if (playersToTarget.Count > 1 && Config.DisableDangerousCommands || playersToTarget.Count == 0)
|
||||
@@ -443,13 +443,9 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
||||
|
||||
if (caller!.CanTarget(player))
|
||||
{
|
||||
if (!player.IsBot && player.SteamID.ToString().Length == 17)
|
||||
return;
|
||||
|
||||
if (player.PawnIsAlive)
|
||||
{
|
||||
player.Pawn.Value!.Freeze();
|
||||
player.CommitSuicide(true, true);
|
||||
}
|
||||
|
||||
if (command.ArgCount >= 2)
|
||||
@@ -1454,7 +1450,6 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
||||
if (player.PawnIsAlive)
|
||||
{
|
||||
player.Pawn.Value!.Freeze();
|
||||
player.CommitSuicide(true, true);
|
||||
}
|
||||
|
||||
PlayerInfo playerInfo = new PlayerInfo
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="CounterStrikeSharp.API" Version="1.0.163" />
|
||||
<PackageReference Include="CounterStrikeSharp.API" Version="1.0.166" />
|
||||
<PackageReference Include="Dapper" Version="*" />
|
||||
<PackageReference Include="MySqlConnector" Version="2.3.5" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="*" />
|
||||
|
||||
55
Events.cs
55
Events.cs
@@ -15,31 +15,12 @@ public partial class CS2_SimpleAdmin
|
||||
{
|
||||
private void registerEvents()
|
||||
{
|
||||
//RegisterListener<OnClientAuthorized>(OnClientAuthorized);
|
||||
//RegisterListener<OnClientConnect>(OnClientConnect);
|
||||
RegisterListener<Listeners.OnClientPutInServer>(OnClientPutInServer);
|
||||
//RegisterListener<OnClientDisconnect>(OnClientDisconnect);
|
||||
//RegisterEventHandler<EventPlayerConnectFull>(OnPlayerFullConnect);
|
||||
RegisterListener<Listeners.OnMapStart>(OnMapStart);
|
||||
RegisterListener<Listeners.OnClientVoice>(OnClientVoice);
|
||||
//RegisterEventHandler<EventPlayerHurt>(OnPlayerHurt);
|
||||
//RegisterEventHandler<EventRoundStart>(OnRoundStart);
|
||||
AddCommandListener("say", OnCommandSay);
|
||||
AddCommandListener("say_team", OnCommandTeamSay);
|
||||
}
|
||||
|
||||
private void OnClientVoice(int playerSlot)
|
||||
{
|
||||
PlayerPenaltyManager playerPenaltyManager = new PlayerPenaltyManager();
|
||||
if (!playerPenaltyManager.IsSlotInPenalties(playerSlot)) return;
|
||||
|
||||
CCSPlayerController? player = Utilities.GetPlayerFromSlot(playerSlot);
|
||||
if (player is null || !player.IsValid) return;
|
||||
|
||||
if (playerPenaltyManager.IsPenalized(playerSlot, PenaltyType.Mute) || playerPenaltyManager.IsPenalized(playerSlot, PenaltyType.Silence))
|
||||
player.VoiceFlags = VoiceFlags.Muted;
|
||||
}
|
||||
|
||||
[GameEventHandler]
|
||||
private HookResult OnRoundEnd(EventRoundEnd @event, GameEventInfo info)
|
||||
{
|
||||
@@ -136,6 +117,7 @@ public partial class CS2_SimpleAdmin
|
||||
|
||||
BanManager _banManager = new(_database, Config);
|
||||
MuteManager _muteManager = new(_database);
|
||||
PlayerPenaltyManager playerPenaltyManager = new PlayerPenaltyManager();
|
||||
|
||||
Task.Run(async () =>
|
||||
{
|
||||
@@ -160,49 +142,42 @@ public partial class CS2_SimpleAdmin
|
||||
|
||||
if (activeMutes.Count > 0)
|
||||
{
|
||||
PlayerPenaltyManager playerPenaltyManager = new PlayerPenaltyManager();
|
||||
foreach (var mute in activeMutes)
|
||||
foreach (dynamic mute in activeMutes)
|
||||
{
|
||||
string muteType = mute.type;
|
||||
DateTime ends = mute.ends;
|
||||
int duration = mute.duration;
|
||||
|
||||
if (muteType == "GAG")
|
||||
{
|
||||
/*
|
||||
if (playerInfo.Slot.HasValue && !gaggedPlayers.Contains(playerInfo.Slot.Value))
|
||||
gaggedPlayers.Add(playerInfo.Slot.Value);
|
||||
*/
|
||||
playerPenaltyManager.AddPenalty(1, PenaltyType.Gag, DateTime.Parse(mute.ends), mute.duration);
|
||||
|
||||
if (TagsDetected)
|
||||
{
|
||||
playerPenaltyManager.AddPenalty(playerInfo.Slot, PenaltyType.Gag, ends, duration);
|
||||
Server.NextFrame(() =>
|
||||
{
|
||||
if (TagsDetected)
|
||||
{
|
||||
Server.ExecuteCommand($"css_tag_mute {playerInfo.SteamId}");
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
else if (muteType == "MUTE")
|
||||
{
|
||||
playerPenaltyManager.AddPenalty(1, PenaltyType.Mute, DateTime.Parse(mute.ends), mute.duration);
|
||||
playerPenaltyManager.AddPenalty(playerInfo.Slot, PenaltyType.Mute, ends, duration);
|
||||
Server.NextFrame(() =>
|
||||
{
|
||||
player.VoiceFlags = VoiceFlags.Muted;
|
||||
});
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
/*
|
||||
* if (playerInfo.Slot.HasValue && !gaggedPlayers.Contains(playerInfo.Slot.Value))
|
||||
gaggedPlayers.Add(playerInfo.Slot.Value);
|
||||
*/
|
||||
playerPenaltyManager.AddPenalty(1, PenaltyType.Silence, DateTime.Parse(mute.ends), mute.duration);
|
||||
|
||||
playerPenaltyManager.AddPenalty(playerInfo.Slot, PenaltyType.Silence, ends, duration);
|
||||
Server.NextFrame(() =>
|
||||
{
|
||||
if (player.IsValid)
|
||||
{
|
||||
player.VoiceFlags = VoiceFlags.Muted;
|
||||
if (TagsDetected)
|
||||
{
|
||||
Server.ExecuteCommand($"css_tag_mute {playerInfo.SteamId}");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,14 +23,14 @@ namespace CS2_SimpleAdmin
|
||||
|
||||
public static List<CCSPlayerController> GetPlayerFromSteamid64(string steamid)
|
||||
{
|
||||
return Utilities.GetPlayers().FindAll(x =>
|
||||
return GetValidPlayers().FindAll(x =>
|
||||
x.SteamID.ToString().Equals(steamid, StringComparison.OrdinalIgnoreCase)
|
||||
);
|
||||
}
|
||||
|
||||
public static List<CCSPlayerController> GetPlayerFromIp(string ipAddress)
|
||||
{
|
||||
return Utilities.GetPlayers().FindAll(x =>
|
||||
return GetValidPlayers().FindAll(x =>
|
||||
x.IpAddress != null &&
|
||||
x.IpAddress.Split(":")[0].Equals(ipAddress)
|
||||
);
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
{
|
||||
public int? Index { get; set; }
|
||||
public int? UserId { get; set; }
|
||||
public int? Slot { get; set; }
|
||||
public int Slot { get; set; }
|
||||
public string? SteamId { get; set; }
|
||||
public string? Name { get; set; }
|
||||
public string? IpAddress { get; set; }
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using CounterStrikeSharp.API;
|
||||
using CounterStrikeSharp.API.Core;
|
||||
using CounterStrikeSharp.API.Modules.Admin;
|
||||
using CounterStrikeSharp.API.Modules.Entities;
|
||||
using CounterStrikeSharp.API.Modules.Memory;
|
||||
using CounterStrikeSharp.API.Modules.Utils;
|
||||
using System.Text;
|
||||
@@ -24,7 +25,9 @@ public static class PlayerUtils
|
||||
public static bool CanTarget(this CCSPlayerController controller, CCSPlayerController target)
|
||||
{
|
||||
if (target.IsBot) return true;
|
||||
return AdminManager.CanPlayerTarget(controller, target);
|
||||
if (controller is null) return true;
|
||||
|
||||
return AdminManager.CanPlayerTarget(controller, target) || AdminManager.CanPlayerTarget(new SteamID(controller.SteamID), new SteamID(target.SteamID));
|
||||
}
|
||||
|
||||
public static void SetSpeed(this CCSPlayerController controller, float speed)
|
||||
|
||||
Reference in New Issue
Block a user