mirror of
https://github.com/daffyyyy/CS2-SimpleAdmin.git
synced 2026-09-27 20:17:04 +02:00
Merge branch 'daffyyyy:main' into main
This commit is contained in:
commit
d4960c6466
11 changed files with 97 additions and 89 deletions
|
|
@ -12,7 +12,7 @@ using System.Collections.Concurrent;
|
||||||
|
|
||||||
namespace CS2_SimpleAdmin;
|
namespace CS2_SimpleAdmin;
|
||||||
|
|
||||||
[MinimumApiVersion(178)]
|
[MinimumApiVersion(191)]
|
||||||
public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdminConfig>
|
public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdminConfig>
|
||||||
{
|
{
|
||||||
public static CS2_SimpleAdmin Instance { get; private set; } = new();
|
public static CS2_SimpleAdmin Instance { get; private set; } = new();
|
||||||
|
|
@ -38,7 +38,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 & Dliix66";
|
public override string ModuleAuthor => "daffyy & Dliix66";
|
||||||
public override string ModuleVersion => "1.3.6a";
|
public override string ModuleVersion => "1.3.6c";
|
||||||
|
|
||||||
public CS2_SimpleAdminConfig Config { get; set; } = new();
|
public CS2_SimpleAdminConfig Config { get; set; } = new();
|
||||||
|
|
||||||
|
|
@ -81,24 +81,22 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
using (MySqlConnection connection = await _database.GetConnectionAsync())
|
using MySqlConnection connection = await _database.GetConnectionAsync();
|
||||||
|
using MySqlTransaction transaction = await connection.BeginTransactionAsync();
|
||||||
|
|
||||||
|
try
|
||||||
{
|
{
|
||||||
using MySqlTransaction transaction = await connection.BeginTransactionAsync();
|
string sqlFilePath = ModuleDirectory + "/Database/database_setup.sql";
|
||||||
|
string sql = await File.ReadAllTextAsync(sqlFilePath);
|
||||||
|
|
||||||
try
|
await connection.QueryAsync(sql, transaction: transaction);
|
||||||
{
|
|
||||||
string sqlFilePath = ModuleDirectory + "/Database/database_setup.sql";
|
|
||||||
string sql = await File.ReadAllTextAsync(sqlFilePath);
|
|
||||||
|
|
||||||
await connection.QueryAsync(sql, transaction: transaction);
|
await transaction.CommitAsync();
|
||||||
|
}
|
||||||
await transaction.CommitAsync();
|
catch (Exception)
|
||||||
}
|
{
|
||||||
catch (Exception)
|
await transaction.RollbackAsync();
|
||||||
{
|
throw;
|
||||||
await transaction.RollbackAsync();
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="CounterStrikeSharp.API" Version="1.0.189" />
|
<PackageReference Include="CounterStrikeSharp.API" Version="1.0.193" />
|
||||||
<PackageReference Include="Dapper" Version="2.1.35" />
|
<PackageReference Include="Dapper" Version="2.1.35" />
|
||||||
<PackageReference Include="Discord.Net.Webhook" Version="3.13.1" />
|
<PackageReference Include="Discord.Net.Webhook" Version="3.13.1" />
|
||||||
<PackageReference Include="MySqlConnector" Version="2.3.5" />
|
<PackageReference Include="MySqlConnector" Version="2.3.5" />
|
||||||
|
|
|
||||||
|
|
@ -413,7 +413,7 @@ namespace CS2_SimpleAdmin
|
||||||
player.Pawn.Value!.Freeze();
|
player.Pawn.Value!.Freeze();
|
||||||
}
|
}
|
||||||
|
|
||||||
reason = CS2_SimpleAdmin._localizer?["sa_unknown"] ?? "Unknown";
|
reason = reason ?? CS2_SimpleAdmin._localizer?["sa_unknown"] ?? "Unknown";
|
||||||
|
|
||||||
Helper.LogCommand(caller, $"css_kick {player.PlayerName} {reason}");
|
Helper.LogCommand(caller, $"css_kick {player.PlayerName} {reason}");
|
||||||
|
|
||||||
|
|
@ -462,6 +462,8 @@ namespace CS2_SimpleAdmin
|
||||||
string callerName = caller == null ? "Console" : caller.PlayerName;
|
string callerName = caller == null ? "Console" : caller.PlayerName;
|
||||||
string _command = string.Empty;
|
string _command = string.Empty;
|
||||||
|
|
||||||
|
map = map.ToLower();
|
||||||
|
|
||||||
if (map.StartsWith("ws:"))
|
if (map.StartsWith("ws:"))
|
||||||
{
|
{
|
||||||
if (long.TryParse(map.Replace("ws:", ""), out long mapId))
|
if (long.TryParse(map.Replace("ws:", ""), out long mapId))
|
||||||
|
|
@ -540,6 +542,8 @@ namespace CS2_SimpleAdmin
|
||||||
string callerName = caller == null ? "Console" : caller.PlayerName;
|
string callerName = caller == null ? "Console" : caller.PlayerName;
|
||||||
string _command = string.Empty;
|
string _command = string.Empty;
|
||||||
|
|
||||||
|
map = map.ToLower();
|
||||||
|
|
||||||
if (long.TryParse(map, out long mapId))
|
if (long.TryParse(map, out long mapId))
|
||||||
{
|
{
|
||||||
_command = $"host_workshop_map {mapId}";
|
_command = $"host_workshop_map {mapId}";
|
||||||
|
|
|
||||||
|
|
@ -358,7 +358,6 @@ namespace CS2_SimpleAdmin
|
||||||
await _muteManager.UnmutePlayer(player.SteamID.ToString(), 0); // Unmute by type 0 (gag)
|
await _muteManager.UnmutePlayer(player.SteamID.ToString(), 0); // Unmute by type 0 (gag)
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
if (TagsDetected)
|
if (TagsDetected)
|
||||||
Server.ExecuteCommand($"css_tag_unmute {player!.SteamID}");
|
Server.ExecuteCommand($"css_tag_unmute {player!.SteamID}");
|
||||||
});
|
});
|
||||||
|
|
@ -695,7 +694,6 @@ namespace CS2_SimpleAdmin
|
||||||
player.VoiceFlags = VoiceFlags.Normal;
|
player.VoiceFlags = VoiceFlags.Normal;
|
||||||
});
|
});
|
||||||
*/
|
*/
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[ConsoleCommand("css_silence")]
|
[ConsoleCommand("css_silence")]
|
||||||
|
|
|
||||||
|
|
@ -16,8 +16,10 @@ namespace CS2_SimpleAdmin
|
||||||
{
|
{
|
||||||
[JsonPropertyName("Flag")]
|
[JsonPropertyName("Flag")]
|
||||||
public string Flag { get; set; } = "@css/generic";
|
public string Flag { get; set; } = "@css/generic";
|
||||||
|
|
||||||
[JsonPropertyName("DisplayName")]
|
[JsonPropertyName("DisplayName")]
|
||||||
public string DisplayName { get; set; } = "";
|
public string DisplayName { get; set; } = "";
|
||||||
|
|
||||||
[JsonPropertyName("Command")]
|
[JsonPropertyName("Command")]
|
||||||
public string Command { get; set; } = "";
|
public string Command { get; set; } = "";
|
||||||
}
|
}
|
||||||
|
|
|
||||||
103
Events.cs
103
Events.cs
|
|
@ -4,6 +4,7 @@ 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.Cvars;
|
using CounterStrikeSharp.API.Modules.Cvars;
|
||||||
|
using CounterStrikeSharp.API.Modules.Entities;
|
||||||
using Dapper;
|
using Dapper;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using System.Data;
|
using System.Data;
|
||||||
|
|
@ -14,24 +15,28 @@ namespace CS2_SimpleAdmin;
|
||||||
|
|
||||||
public partial class CS2_SimpleAdmin
|
public partial class CS2_SimpleAdmin
|
||||||
{
|
{
|
||||||
|
public static HashSet<int> loadedPlayers = new HashSet<int>();
|
||||||
|
|
||||||
private void RegisterEvents()
|
private void RegisterEvents()
|
||||||
{
|
{
|
||||||
RegisterListener<Listeners.OnMapStart>(OnMapStart);
|
RegisterListener<Listeners.OnMapStart>(OnMapStart);
|
||||||
RegisterListener<Listeners.OnClientConnected>(OnClientConnected);
|
//RegisterListener<Listeners.OnClientConnected>(OnClientConnected);
|
||||||
RegisterListener<Listeners.OnClientDisconnectPost>(OnClientDisconnectPost);
|
//RegisterListener<Listeners.OnClientDisconnect>(OnClientDisconnect);
|
||||||
AddCommandListener("say", OnCommandSay);
|
AddCommandListener("say", OnCommandSay);
|
||||||
AddCommandListener("say_team", OnCommandTeamSay);
|
AddCommandListener("say_team", OnCommandTeamSay);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnClientDisconnectPost(int playerSlot)
|
[GameEventHandler]
|
||||||
|
public HookResult OnClientDisconnect(EventPlayerDisconnect @event, GameEventInfo info)
|
||||||
{
|
{
|
||||||
CCSPlayerController? player = Utilities.GetPlayerFromSlot(playerSlot);
|
CCSPlayerController? player = @event.Userid;
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
Logger.LogCritical("[OnClientDisconnect] Before");
|
Logger.LogCritical("[OnClientDisconnect] Before");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (player is null || player.IsBot || player.IsHLTV || player.SteamID.ToString().Length != 17) return;
|
if (player is null || !player.IsValid || string.IsNullOrEmpty(player.IpAddress) || player.IsBot || player.IsHLTV) return HookResult.Continue;
|
||||||
|
if (!loadedPlayers.Contains(player.Slot)) return HookResult.Continue;
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
Logger.LogCritical("[OnClientDisconnect] After Check");
|
Logger.LogCritical("[OnClientDisconnect] After Check");
|
||||||
|
|
@ -39,6 +44,7 @@ public partial class CS2_SimpleAdmin
|
||||||
|
|
||||||
PlayerPenaltyManager playerPenaltyManager = new();
|
PlayerPenaltyManager playerPenaltyManager = new();
|
||||||
playerPenaltyManager.RemoveAllPenalties(player.Slot);
|
playerPenaltyManager.RemoveAllPenalties(player.Slot);
|
||||||
|
|
||||||
if (TagsDetected)
|
if (TagsDetected)
|
||||||
Server.ExecuteCommand($"css_tag_unmute {player.SteamID}");
|
Server.ExecuteCommand($"css_tag_unmute {player.SteamID}");
|
||||||
|
|
||||||
|
|
@ -47,23 +53,35 @@ public partial class CS2_SimpleAdmin
|
||||||
if (godPlayers.Contains(player.Slot))
|
if (godPlayers.Contains(player.Slot))
|
||||||
RemoveFromConcurrentBag(godPlayers, player.Slot);
|
RemoveFromConcurrentBag(godPlayers, player.Slot);
|
||||||
|
|
||||||
if (player.AuthorizedSteamID == null) return;
|
loadedPlayers.Remove(player.Slot);
|
||||||
|
|
||||||
if (AdminSQLManager._adminCache.TryGetValue(player.AuthorizedSteamID, out DateTime? expirationTime)
|
SteamID? authorizedSteamID = player.AuthorizedSteamID;
|
||||||
&& expirationTime <= DateTime.Now)
|
|
||||||
|
if (authorizedSteamID == null) return HookResult.Continue;
|
||||||
|
|
||||||
|
Task.Run(() =>
|
||||||
{
|
{
|
||||||
AdminManager.ClearPlayerPermissions(player.AuthorizedSteamID);
|
if (AdminSQLManager._adminCache.TryGetValue(authorizedSteamID, out DateTime? expirationTime)
|
||||||
AdminManager.RemovePlayerAdminData(player.AuthorizedSteamID);
|
&& expirationTime <= DateTime.Now)
|
||||||
}
|
{
|
||||||
}
|
AdminManager.ClearPlayerPermissions(authorizedSteamID);
|
||||||
|
AdminManager.RemovePlayerAdminData(authorizedSteamID);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
private void OnClientConnected(int playerSlot)
|
return HookResult.Continue;
|
||||||
|
}
|
||||||
|
[GameEventHandler]
|
||||||
|
public HookResult OnPlayerFullConnect(EventPlayerConnectFull @event, GameEventInfo info)
|
||||||
{
|
{
|
||||||
CCSPlayerController? player = Utilities.GetPlayerFromSlot(playerSlot);
|
CCSPlayerController? player = @event.Userid;
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
Logger.LogCritical($"[OnPlayerConnect] Before check {player.PlayerName} : {player.IpAddress}");
|
Logger.LogCritical($"[OnPlayerConnect] Before check {player.PlayerName} : {player.IpAddress}");
|
||||||
#endif
|
#endif
|
||||||
if (player is null || player.IsBot || player.IsHLTV || player.SteamID.ToString().Length != 17 || string.IsNullOrEmpty(player.IpAddress)) return;
|
if (player is null
|
||||||
|
|| string.IsNullOrEmpty(player.IpAddress) || player.IpAddress.Contains("127.0.0.1")
|
||||||
|
|| player.IsBot || player.IsHLTV || !player.UserId.HasValue) return HookResult.Continue;
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
Logger.LogCritical("[OnPlayerConnect] After Check");
|
Logger.LogCritical("[OnPlayerConnect] After Check");
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -71,13 +89,13 @@ public partial class CS2_SimpleAdmin
|
||||||
|
|
||||||
if (bannedPlayers.Contains(ipAddress) || bannedPlayers.Contains(player.SteamID.ToString()))
|
if (bannedPlayers.Contains(ipAddress) || bannedPlayers.Contains(player.SteamID.ToString()))
|
||||||
{
|
{
|
||||||
if (!player.UserId.HasValue) return;
|
if (!player.UserId.HasValue) return HookResult.Continue;
|
||||||
Helper.KickPlayer(player.UserId.Value, "Banned");
|
Helper.KickPlayer(player.UserId.Value, "Banned");
|
||||||
return;
|
return HookResult.Continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_database == null || !player.UserId.HasValue || player.UserId == null)
|
if (_database == null || !player.UserId.HasValue || player.UserId == null)
|
||||||
return;
|
return HookResult.Continue;
|
||||||
|
|
||||||
PlayerInfo playerInfo = new PlayerInfo
|
PlayerInfo playerInfo = new PlayerInfo
|
||||||
{
|
{
|
||||||
|
|
@ -89,12 +107,12 @@ public partial class CS2_SimpleAdmin
|
||||||
IpAddress = ipAddress
|
IpAddress = ipAddress
|
||||||
};
|
};
|
||||||
|
|
||||||
|
BanManager _banManager = new(_database, Config);
|
||||||
|
MuteManager _muteManager = new(_database);
|
||||||
|
PlayerPenaltyManager playerPenaltyManager = new PlayerPenaltyManager();
|
||||||
|
|
||||||
Task.Run(async () =>
|
Task.Run(async () =>
|
||||||
{
|
{
|
||||||
BanManager _banManager = new(_database, Config);
|
|
||||||
MuteManager _muteManager = new(_database);
|
|
||||||
PlayerPenaltyManager playerPenaltyManager = new PlayerPenaltyManager();
|
|
||||||
|
|
||||||
if (await _banManager.IsPlayerBanned(playerInfo))
|
if (await _banManager.IsPlayerBanned(playerInfo))
|
||||||
{
|
{
|
||||||
if (playerInfo.IpAddress != null && !bannedPlayers.Contains(playerInfo.IpAddress))
|
if (playerInfo.IpAddress != null && !bannedPlayers.Contains(playerInfo.IpAddress))
|
||||||
|
|
@ -159,19 +177,25 @@ public partial class CS2_SimpleAdmin
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (!loadedPlayers.Contains(player.Slot))
|
||||||
|
loadedPlayers.Add(player.Slot);
|
||||||
|
|
||||||
|
return HookResult.Continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
[GameEventHandler]
|
[GameEventHandler]
|
||||||
private HookResult OnRoundEnd(EventRoundEnd @event, GameEventInfo info)
|
public HookResult OnRoundEnd(EventRoundStart @event, GameEventInfo info)
|
||||||
{
|
{
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
Logger.LogCritical("[OnRoundEnd]");
|
Logger.LogCritical("[OnRoundEnd]");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
godPlayers.Clear();
|
godPlayers.Clear();
|
||||||
return HookResult.Continue;
|
return HookResult.Continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
private HookResult OnCommandSay(CCSPlayerController? player, CommandInfo info)
|
public HookResult OnCommandSay(CCSPlayerController? player, CommandInfo info)
|
||||||
{
|
{
|
||||||
if (player is null || !player.IsValid || player.IsBot || player.IsHLTV || info.GetArg(1).Length == 0) return HookResult.Continue;
|
if (player is null || !player.IsValid || player.IsBot || player.IsHLTV || info.GetArg(1).Length == 0) return HookResult.Continue;
|
||||||
|
|
||||||
|
|
@ -183,7 +207,7 @@ public partial class CS2_SimpleAdmin
|
||||||
return HookResult.Continue;
|
return HookResult.Continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
private HookResult OnCommandTeamSay(CCSPlayerController? player, CommandInfo info)
|
public HookResult OnCommandTeamSay(CCSPlayerController? player, CommandInfo info)
|
||||||
{
|
{
|
||||||
if (player is null || !player.IsValid || player.IsBot || player.IsHLTV || info.GetArg(1).Length == 0) return HookResult.Continue;
|
if (player is null || !player.IsValid || player.IsBot || player.IsHLTV || info.GetArg(1).Length == 0) return HookResult.Continue;
|
||||||
|
|
||||||
|
|
@ -220,23 +244,6 @@ public partial class CS2_SimpleAdmin
|
||||||
return HookResult.Continue;
|
return HookResult.Continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
[GameEventHandler]
|
|
||||||
public HookResult OnPlayerFullConnect(EventPlayerConnectFull @event, GameEventInfo info)
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
return HookResult.Continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
[GameEventHandler]
|
|
||||||
public HookResult OnPlayerDisconnect(EventPlayerDisconnect @event, GameEventInfo info)
|
|
||||||
{
|
|
||||||
|
|
||||||
return HookResult.Continue;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
private void OnMapStart(string mapName)
|
private void OnMapStart(string mapName)
|
||||||
{
|
{
|
||||||
string? path = Path.GetDirectoryName(ModuleDirectory);
|
string? path = Path.GetDirectoryName(ModuleDirectory);
|
||||||
|
|
@ -255,7 +262,7 @@ public partial class CS2_SimpleAdmin
|
||||||
|
|
||||||
if (_database == null) return;
|
if (_database == null) return;
|
||||||
|
|
||||||
AddTimer(60.0f, async () =>
|
AddTimer(61.0f, async () =>
|
||||||
{
|
{
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
Logger.LogCritical("[OnMapStart] Expired check");
|
Logger.LogCritical("[OnMapStart] Expired check");
|
||||||
|
|
@ -273,7 +280,6 @@ public partial class CS2_SimpleAdmin
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
||||||
foreach (CCSPlayerController player in Helper.GetValidPlayers())
|
foreach (CCSPlayerController player in Helper.GetValidPlayers())
|
||||||
{
|
{
|
||||||
if (playerPenaltyManager.IsSlotInPenalties(player.Slot))
|
if (playerPenaltyManager.IsSlotInPenalties(player.Slot))
|
||||||
|
|
@ -307,7 +313,7 @@ public partial class CS2_SimpleAdmin
|
||||||
playerPenaltyManager.RemoveExpiredPenalties();
|
playerPenaltyManager.RemoveExpiredPenalties();
|
||||||
}, CounterStrikeSharp.API.Modules.Timers.TimerFlags.REPEAT | CounterStrikeSharp.API.Modules.Timers.TimerFlags.STOP_ON_MAPCHANGE);
|
}, CounterStrikeSharp.API.Modules.Timers.TimerFlags.REPEAT | CounterStrikeSharp.API.Modules.Timers.TimerFlags.STOP_ON_MAPCHANGE);
|
||||||
|
|
||||||
AddTimer(3.0f, async () =>
|
AddTimer(2.0f, async () =>
|
||||||
{
|
{
|
||||||
string? address = $"{ConVar.Find("ip")!.StringValue}:{ConVar.Find("hostport")!.GetPrimitiveValue<int>()}";
|
string? address = $"{ConVar.Find("ip")!.StringValue}:{ConVar.Find("hostport")!.GetPrimitiveValue<int>()}";
|
||||||
string? hostname = ConVar.Find("hostname")!.StringValue;
|
string? hostname = ConVar.Find("hostname")!.StringValue;
|
||||||
|
|
@ -341,9 +347,9 @@ public partial class CS2_SimpleAdmin
|
||||||
|
|
||||||
ServerId = serverId;
|
ServerId = serverId;
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger?.LogCritical("Unable to create or get server_id");
|
_logger?.LogCritical("Unable to create or get server_id" + ex.Message);
|
||||||
}
|
}
|
||||||
|
|
||||||
await _adminManager.GiveAllFlags();
|
await _adminManager.GiveAllFlags();
|
||||||
|
|
@ -366,8 +372,7 @@ public partial class CS2_SimpleAdmin
|
||||||
{
|
{
|
||||||
CCSPlayerController? player = @event.Userid;
|
CCSPlayerController? player = @event.Userid;
|
||||||
|
|
||||||
if (player is null || @event.Attacker is null || (LifeState_t)player.LifeState != LifeState_t.LIFE_ALIVE || player.PlayerPawn.Value == null
|
if (player is null || @event.Attacker is null || !player.PawnIsAlive || player.PlayerPawn.Value == null)
|
||||||
|| player.Connected != PlayerConnectedState.PlayerConnected)
|
|
||||||
return HookResult.Continue;
|
return HookResult.Continue;
|
||||||
|
|
||||||
if (godPlayers.Contains(player.Slot))
|
if (godPlayers.Contains(player.Slot))
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ using Microsoft.Extensions.Logging;
|
||||||
using System.Collections.Concurrent;
|
using System.Collections.Concurrent;
|
||||||
|
|
||||||
namespace CS2_SimpleAdmin;
|
namespace CS2_SimpleAdmin;
|
||||||
|
|
||||||
public class AdminSQLManager
|
public class AdminSQLManager
|
||||||
{
|
{
|
||||||
private readonly Database _database;
|
private readonly Database _database;
|
||||||
|
|
@ -222,4 +223,4 @@ public class AdminSQLManager
|
||||||
CS2_SimpleAdmin._logger.LogCritical("Unable to remove expired admins");
|
CS2_SimpleAdmin._logger.LogCritical("Unable to remove expired admins");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
namespace CS2_SimpleAdmin;
|
namespace CS2_SimpleAdmin;
|
||||||
|
|
||||||
internal class BanManager
|
internal class BanManager
|
||||||
{
|
{
|
||||||
private readonly Database _database;
|
private readonly Database _database;
|
||||||
|
|
@ -188,14 +189,14 @@ internal class BanManager
|
||||||
*/
|
*/
|
||||||
|
|
||||||
string sql = @"
|
string sql = @"
|
||||||
UPDATE sa_bans
|
UPDATE sa_bans
|
||||||
SET
|
SET
|
||||||
status = 'EXPIRED'
|
status = 'EXPIRED'
|
||||||
WHERE
|
WHERE
|
||||||
status = 'ACTIVE'
|
status = 'ACTIVE'
|
||||||
AND
|
AND
|
||||||
`duration` > 0
|
`duration` > 0
|
||||||
AND
|
AND
|
||||||
ends <= @currentTime";
|
ends <= @currentTime";
|
||||||
|
|
||||||
await connection.ExecuteAsync(sql, new { currentTime });
|
await connection.ExecuteAsync(sql, new { currentTime });
|
||||||
|
|
@ -205,21 +206,20 @@ internal class BanManager
|
||||||
DateTime ipBansTime = currentTime.AddDays(-_config.ExpireOldIpBans).ToLocalTime();
|
DateTime ipBansTime = currentTime.AddDays(-_config.ExpireOldIpBans).ToLocalTime();
|
||||||
|
|
||||||
sql = @"
|
sql = @"
|
||||||
UPDATE sa_bans
|
UPDATE sa_bans
|
||||||
SET
|
SET
|
||||||
player_ip = NULL
|
player_ip = NULL
|
||||||
WHERE
|
WHERE
|
||||||
status = 'ACTIVE'
|
status = 'ACTIVE'
|
||||||
AND
|
AND
|
||||||
ends <= @ipBansTime";
|
ends <= @ipBansTime";
|
||||||
|
|
||||||
await connection.ExecuteAsync(sql, new { ipBansTime });
|
await connection.ExecuteAsync(sql, new { ipBansTime });
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
CS2_SimpleAdmin._logger?.LogCritical("Unable to remove expired bans");
|
CS2_SimpleAdmin._logger?.LogCritical("Unable to remove expired bans");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
namespace CS2_SimpleAdmin;
|
namespace CS2_SimpleAdmin;
|
||||||
|
|
||||||
internal class MuteManager
|
internal class MuteManager
|
||||||
{
|
{
|
||||||
private readonly Database _database;
|
private readonly Database _database;
|
||||||
|
|
@ -160,5 +161,4 @@ internal class MuteManager
|
||||||
CS2_SimpleAdmin._logger.LogCritical("Unable to remove expired mutes");
|
CS2_SimpleAdmin._logger.LogCritical("Unable to remove expired mutes");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
using System.Collections.Concurrent;
|
using System.Collections.Concurrent;
|
||||||
|
|
||||||
namespace CS2_SimpleAdmin;
|
namespace CS2_SimpleAdmin;
|
||||||
|
|
||||||
public enum PenaltyType
|
public enum PenaltyType
|
||||||
{
|
{
|
||||||
Mute,
|
Mute,
|
||||||
|
|
@ -134,4 +135,4 @@ public class PlayerPenaltyManager
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -47,5 +47,4 @@
|
||||||
"sa_adminchat_template_player": "{SILVER}(GRACZ) {lightred}{0}{default}: {lightred}{1}{default}",
|
"sa_adminchat_template_player": "{SILVER}(GRACZ) {lightred}{0}{default}: {lightred}{1}{default}",
|
||||||
|
|
||||||
"sa_discord_log_command": "**{0}** użył komendy `{1}` na serwerze `HOSTNAME`"
|
"sa_discord_log_command": "**{0}** użył komendy `{1}` na serwerze `HOSTNAME`"
|
||||||
|
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue