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