mirror of
https://github.com/daffyyyy/CS2-SimpleAdmin.git
synced 2026-03-06 07:16:42 +00:00
1.6.9c
- Added config variable to enable/disable checking for banned multiaccounts by ip `CheckMultiAccountsByIp` - Fixed css_speed after player hurt - Finally fixed vote kick (callvote) - Small fix for admins loading from database
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.9a";
|
public override string ModuleVersion => "1.6.9c";
|
||||||
|
|
||||||
public override void Load(bool hotReload)
|
public override void Load(bool hotReload)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -378,11 +378,11 @@ public partial class CS2_SimpleAdmin
|
|||||||
await Server.NextWorldUpdateAsync(() =>
|
await Server.NextWorldUpdateAsync(() =>
|
||||||
{
|
{
|
||||||
if (!string.IsNullOrEmpty(adminsFile))
|
if (!string.IsNullOrEmpty(adminsFile))
|
||||||
AddTimer(1.0f, () => AdminManager.LoadAdminData(ModuleDirectory + "/data/admins.json"));
|
AddTimer(0.5f, () => AdminManager.LoadAdminData(ModuleDirectory + "/data/admins.json"));
|
||||||
if (!string.IsNullOrEmpty(groupsFile))
|
if (!string.IsNullOrEmpty(groupsFile))
|
||||||
AddTimer(1.5f, () => AdminManager.LoadAdminGroups(ModuleDirectory + "/data/groups.json"));
|
AddTimer(0.8f, () => AdminManager.LoadAdminGroups(ModuleDirectory + "/data/groups.json"));
|
||||||
if (!string.IsNullOrEmpty(adminsFile))
|
if (!string.IsNullOrEmpty(adminsFile))
|
||||||
AddTimer(2.0f, () => AdminManager.LoadAdminData(ModuleDirectory + "/data/admins.json"));
|
AddTimer(1.1f, () => AdminManager.LoadAdminData(ModuleDirectory + "/data/admins.json"));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -225,13 +225,16 @@ public class OtherSettings
|
|||||||
[JsonPropertyName("UserMessageGagChatType")]
|
[JsonPropertyName("UserMessageGagChatType")]
|
||||||
public bool UserMessageGagChatType { get; set; } = false;
|
public bool UserMessageGagChatType { get; set; } = false;
|
||||||
|
|
||||||
|
[JsonPropertyName("CheckMultiAccountsByIp")]
|
||||||
|
public bool CheckMultiAccountsByIp { get; set; } = true;
|
||||||
|
|
||||||
[JsonPropertyName("AdditionalCommandsToLog")]
|
[JsonPropertyName("AdditionalCommandsToLog")]
|
||||||
public List<string> AdditionalCommandsToLog = new();
|
public List<string> AdditionalCommandsToLog { get; set; } = new();
|
||||||
}
|
}
|
||||||
|
|
||||||
public class CS2_SimpleAdminConfig : BasePluginConfig
|
public class CS2_SimpleAdminConfig : BasePluginConfig
|
||||||
{
|
{
|
||||||
[JsonPropertyName("ConfigVersion")] public override int Version { get; set; } = 23;
|
[JsonPropertyName("ConfigVersion")] public override int Version { get; set; } = 24;
|
||||||
|
|
||||||
[JsonPropertyName("DatabaseHost")]
|
[JsonPropertyName("DatabaseHost")]
|
||||||
public string DatabaseHost { get; set; } = "";
|
public string DatabaseHost { get; set; } = "";
|
||||||
|
|||||||
@@ -147,7 +147,7 @@ public partial class CS2_SimpleAdmin
|
|||||||
|
|
||||||
foreach (var player in PlayersInfo.Values)
|
foreach (var player in PlayersInfo.Values)
|
||||||
{
|
{
|
||||||
player.DiePosition = null;
|
player.DiePosition = default;
|
||||||
}
|
}
|
||||||
|
|
||||||
AddTimer(0.41f, () =>
|
AddTimer(0.41f, () =>
|
||||||
@@ -215,8 +215,6 @@ public partial class CS2_SimpleAdmin
|
|||||||
if (target == null || !target.IsValid || target.Connected != PlayerConnectedState.PlayerConnected)
|
if (target == null || !target.IsValid || target.Connected != PlayerConnectedState.PlayerConnected)
|
||||||
return HookResult.Continue;
|
return HookResult.Continue;
|
||||||
|
|
||||||
Logger.LogInformation($"{player.PlayerName} {AdminManager.GetPlayerImmunity(player).ToString()} probuje wywalic {target.PlayerName} {AdminManager.GetPlayerImmunity(target).ToString()}");
|
|
||||||
|
|
||||||
return !player.CanTarget(target) ? HookResult.Stop : HookResult.Continue;
|
return !player.CanTarget(target) ? HookResult.Stop : HookResult.Continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -358,8 +356,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))
|
if (SpeedPlayers.TryGetValue(player.Slot, out var speedPlayer))
|
||||||
player.SetSpeed(speedPlayer);
|
AddTimer(0.15f, () => player.SetSpeed(speedPlayer));
|
||||||
|
|
||||||
if (!GodPlayers.Contains(player.Slot)) return HookResult.Continue;
|
if (!GodPlayers.Contains(player.Slot)) return HookResult.Continue;
|
||||||
|
|
||||||
@@ -380,19 +379,22 @@ public partial class CS2_SimpleAdmin
|
|||||||
SpeedPlayers.Remove(player.Slot);
|
SpeedPlayers.Remove(player.Slot);
|
||||||
GravityPlayers.Remove(player);
|
GravityPlayers.Remove(player);
|
||||||
|
|
||||||
if (!PlayersInfo.ContainsKey(player.UserId.Value))
|
if (!PlayersInfo.ContainsKey(player.UserId.Value) || @event.Attacker == null)
|
||||||
return HookResult.Continue;
|
return HookResult.Continue;
|
||||||
|
|
||||||
|
var playerPosition = player.PlayerPawn.Value?.AbsOrigin;
|
||||||
|
var playerRotation = player.PlayerPawn.Value?.AbsRotation;
|
||||||
|
|
||||||
PlayersInfo[player.UserId.Value].DiePosition = new DiePosition(
|
PlayersInfo[player.UserId.Value].DiePosition = new DiePosition(
|
||||||
new Vector(
|
new Vector(
|
||||||
player.PlayerPawn.Value?.AbsOrigin?.X ?? 0,
|
playerPosition?.X ?? 0,
|
||||||
player.PlayerPawn.Value?.AbsOrigin?.Y ?? 0,
|
playerPosition?.Y ?? 0,
|
||||||
player.PlayerPawn.Value?.AbsOrigin?.Z ?? 0
|
playerPosition?.Z ?? 0
|
||||||
),
|
),
|
||||||
new QAngle(
|
new QAngle(
|
||||||
player.PlayerPawn.Value?.AbsRotation?.X ?? 0,
|
playerRotation?.X ?? 0,
|
||||||
player.PlayerPawn.Value?.AbsRotation?.Y ?? 0,
|
playerRotation?.Y ?? 0,
|
||||||
player.PlayerPawn.Value?.AbsRotation?.Z ?? 0
|
playerRotation?.Z ?? 0
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -32,7 +32,8 @@ public static class PlayerExtensions
|
|||||||
|
|
||||||
return AdminManager.CanPlayerTarget(controller, target) ||
|
return AdminManager.CanPlayerTarget(controller, target) ||
|
||||||
AdminManager.CanPlayerTarget(new SteamID(controller.SteamID),
|
AdminManager.CanPlayerTarget(new SteamID(controller.SteamID),
|
||||||
new SteamID(target.SteamID));
|
new SteamID(target.SteamID)) ||
|
||||||
|
AdminManager.GetPlayerImmunity(controller) >= AdminManager.GetPlayerImmunity(target);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void SetSpeed(this CCSPlayerController? controller, float speed)
|
public static void SetSpeed(this CCSPlayerController? controller, float speed)
|
||||||
|
|||||||
@@ -159,6 +159,23 @@ internal static class Helper
|
|||||||
// Server.ExecuteCommand($"kickid {userId} {reason}");
|
// Server.ExecuteCommand($"kickid {userId} {reason}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void KickPlayer(CCSPlayerController player, NetworkDisconnectionReason reason = NetworkDisconnectionReason.NETWORK_DISCONNECT_KICKED)
|
||||||
|
{
|
||||||
|
player.Disconnect(reason);
|
||||||
|
|
||||||
|
// if (!string.IsNullOrEmpty(reason))
|
||||||
|
// {
|
||||||
|
// var escapeChars = reason.IndexOfAny([';', '|']);
|
||||||
|
//
|
||||||
|
// if (escapeChars != -1)
|
||||||
|
// {
|
||||||
|
// reason = reason[..escapeChars];
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// Server.ExecuteCommand($"kickid {userId} {reason}");
|
||||||
|
}
|
||||||
|
|
||||||
public static void PrintToCenterAll(string message)
|
public static void PrintToCenterAll(string message)
|
||||||
{
|
{
|
||||||
Utilities.GetPlayers().Where(p => p is { IsValid: true, IsBot: false, IsHLTV: false }).ToList().ForEach(controller =>
|
Utilities.GetPlayers().Where(p => p is { IsValid: true, IsBot: false, IsHLTV: false }).ToList().ForEach(controller =>
|
||||||
|
|||||||
@@ -123,7 +123,11 @@ internal class BanManager(Database.Database? database)
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var sql = CS2_SimpleAdmin.Instance.Config.MultiServerMode ? """
|
string sql;
|
||||||
|
|
||||||
|
if (CS2_SimpleAdmin.Instance.Config.OtherSettings.CheckMultiAccountsByIp)
|
||||||
|
{
|
||||||
|
sql = CS2_SimpleAdmin.Instance.Config.MultiServerMode ? """
|
||||||
SELECT COALESCE((
|
SELECT COALESCE((
|
||||||
SELECT COUNT(*)
|
SELECT COUNT(*)
|
||||||
FROM sa_bans
|
FROM sa_bans
|
||||||
@@ -172,6 +176,35 @@ internal class BanManager(Database.Database? database)
|
|||||||
)
|
)
|
||||||
), 0) AS TotalBanCount;
|
), 0) AS TotalBanCount;
|
||||||
""";
|
""";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sql = CS2_SimpleAdmin.Instance.Config.MultiServerMode ? """
|
||||||
|
UPDATE sa_bans
|
||||||
|
SET player_ip = CASE WHEN player_ip IS NULL THEN @PlayerIP ELSE player_ip END,
|
||||||
|
player_name = CASE WHEN player_name IS NULL THEN @PlayerName ELSE player_name END
|
||||||
|
WHERE (player_steamid = @PlayerSteamID OR player_ip = @PlayerIP)
|
||||||
|
AND status = 'ACTIVE'
|
||||||
|
AND (duration = 0 OR ends > @CurrentTime);
|
||||||
|
|
||||||
|
SELECT COUNT(*) FROM sa_bans
|
||||||
|
WHERE (player_steamid = @PlayerSteamID OR player_ip = @PlayerIP)
|
||||||
|
AND status = 'ACTIVE'
|
||||||
|
AND (duration = 0 OR ends > @CurrentTime);
|
||||||
|
""" : """
|
||||||
|
UPDATE sa_bans
|
||||||
|
SET player_ip = CASE WHEN player_ip IS NULL THEN @PlayerIP ELSE player_ip END,
|
||||||
|
player_name = CASE WHEN player_name IS NULL THEN @PlayerName ELSE player_name END
|
||||||
|
WHERE (player_steamid = @PlayerSteamID OR player_ip = @PlayerIP)
|
||||||
|
AND status = 'ACTIVE'
|
||||||
|
AND (duration = 0 OR ends > @CurrentTime) AND server_id = @ServerId;
|
||||||
|
|
||||||
|
SELECT COUNT(*) FROM sa_bans
|
||||||
|
WHERE (player_steamid = @PlayerSteamID OR player_ip = @PlayerIP)
|
||||||
|
AND status = 'ACTIVE'
|
||||||
|
AND (duration = 0 OR ends > @CurrentTime) AND server_id = @ServerId;
|
||||||
|
""";
|
||||||
|
}
|
||||||
|
|
||||||
await using var connection = await database.GetConnectionAsync();
|
await using var connection = await database.GetConnectionAsync();
|
||||||
|
|
||||||
|
|||||||
@@ -90,12 +90,11 @@ public class PermissionManager(Database.Database? database)
|
|||||||
))
|
))
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
/*
|
|
||||||
foreach (var player in groupedPlayers)
|
// foreach (var player in groupedPlayers)
|
||||||
{
|
// {
|
||||||
Console.WriteLine($"Player SteamID: {player.PlayerSteamId}, Name: {player.PlayerName}, Flags: {string.Join(", ", player.Flags)}, Immunity: {player.Immunity}, Ends: {player.Ends}");
|
// Console.WriteLine($"Player SteamID: {player.PlayerSteamId}, Name: {player.PlayerName}, Flags: {string.Join(", ", player.Flags)}, Immunity: {player.Immunity}, Ends: {player.Ends}");
|
||||||
}
|
// }
|
||||||
*/
|
|
||||||
|
|
||||||
List<(string, string, List<string>, int, DateTime?)> filteredFlagsWithImmunity = [];
|
List<(string, string, List<string>, int, DateTime?)> filteredFlagsWithImmunity = [];
|
||||||
|
|
||||||
|
|||||||
@@ -16,15 +16,26 @@ public class PlayerManager
|
|||||||
|
|
||||||
public void LoadPlayerData(CCSPlayerController player)
|
public void LoadPlayerData(CCSPlayerController player)
|
||||||
{
|
{
|
||||||
if (player.IsBot || string.IsNullOrEmpty(player.IpAddress) || player.IpAddress.Contains("127.0.0.1")
|
if (player.IsBot || string.IsNullOrEmpty(player.IpAddress) || player.IpAddress.Contains("127.0.0.1"))
|
||||||
|| !player.UserId.HasValue)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (!player.UserId.HasValue)
|
||||||
|
{
|
||||||
|
Helper.KickPlayer(player, NetworkDisconnectionReason.NETWORK_DISCONNECT_REJECT_INVALIDCONNECTION);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var ipAddress = player.IpAddress?.Split(":")[0];
|
var ipAddress = player.IpAddress?.Split(":")[0];
|
||||||
|
|
||||||
CS2_SimpleAdmin.PlayersInfo[player.UserId.Value] =
|
CS2_SimpleAdmin.PlayersInfo[player.UserId.Value] =
|
||||||
new PlayerInfo(player.UserId.Value, player.Slot, new SteamID(player.SteamID), player.PlayerName, ipAddress);
|
new PlayerInfo(player.UserId.Value, player.Slot, new SteamID(player.SteamID), player.PlayerName, ipAddress);
|
||||||
|
|
||||||
|
// if (!player.UserId.HasValue)
|
||||||
|
// {
|
||||||
|
// Helper.KickPlayer(player, NetworkDisconnectionReason.NETWORK_DISCONNECT_REJECT_INVALIDCONNECTION);
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
|
||||||
var userId = player.UserId.Value;
|
var userId = player.UserId.Value;
|
||||||
|
|
||||||
// Check if the player's IP or SteamID is in the bannedPlayers list
|
// Check if the player's IP or SteamID is in the bannedPlayers list
|
||||||
@@ -32,7 +43,6 @@ public class PlayerManager
|
|||||||
CS2_SimpleAdmin.BannedPlayers.Contains(player.SteamID.ToString()))
|
CS2_SimpleAdmin.BannedPlayers.Contains(player.SteamID.ToString()))
|
||||||
{
|
{
|
||||||
// Kick the player if banned
|
// Kick the player if banned
|
||||||
if (player.UserId.HasValue)
|
|
||||||
Helper.KickPlayer(player.UserId.Value, NetworkDisconnectionReason.NETWORK_DISCONNECT_REJECT_BANNED);
|
Helper.KickPlayer(player.UserId.Value, NetworkDisconnectionReason.NETWORK_DISCONNECT_REJECT_BANNED);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -113,7 +123,7 @@ public class PlayerManager
|
|||||||
{
|
{
|
||||||
var victim = Utilities.GetPlayerFromUserid(userId);
|
var victim = Utilities.GetPlayerFromUserid(userId);
|
||||||
|
|
||||||
if (victim?.UserId == null) return;
|
if (victim == null || !victim.UserId.HasValue) return;
|
||||||
|
|
||||||
if (CS2_SimpleAdmin.UnlockedCommands)
|
if (CS2_SimpleAdmin.UnlockedCommands)
|
||||||
Server.ExecuteCommand($"banid 1 {userId}");
|
Server.ExecuteCommand($"banid 1 {userId}");
|
||||||
|
|||||||
@@ -11,11 +11,11 @@ public class ServerManager
|
|||||||
|
|
||||||
public void LoadServerData()
|
public void LoadServerData()
|
||||||
{
|
{
|
||||||
CS2_SimpleAdmin.Instance.AddTimer(2.0f, () =>
|
CS2_SimpleAdmin.Instance.AddTimer(1.2f, () =>
|
||||||
{
|
{
|
||||||
if (CS2_SimpleAdmin.ServerLoaded || CS2_SimpleAdmin.ServerId != null || CS2_SimpleAdmin.Database == null) return;
|
if (CS2_SimpleAdmin.ServerLoaded || CS2_SimpleAdmin.ServerId != null || CS2_SimpleAdmin.Database == null) return;
|
||||||
|
|
||||||
if (_getIpTryCount > 16 && Helper.GetServerIp().StartsWith("0.0.0.0") || string.IsNullOrEmpty(Helper.GetServerIp()))
|
if (_getIpTryCount > 32 && Helper.GetServerIp().StartsWith("0.0.0.0") || string.IsNullOrEmpty(Helper.GetServerIp()))
|
||||||
{
|
{
|
||||||
CS2_SimpleAdmin._logger?.LogError("Unable to load server data - can't fetch ip address!");
|
CS2_SimpleAdmin._logger?.LogError("Unable to load server data - can't fetch ip address!");
|
||||||
return;
|
return;
|
||||||
@@ -27,7 +27,7 @@ public class ServerManager
|
|||||||
{
|
{
|
||||||
ipAddress = Helper.GetServerIp();
|
ipAddress = Helper.GetServerIp();
|
||||||
|
|
||||||
if (_getIpTryCount <= 16)
|
if (_getIpTryCount <= 32)
|
||||||
{
|
{
|
||||||
_getIpTryCount++;
|
_getIpTryCount++;
|
||||||
|
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
1.6.9a
|
1.6.9c
|
||||||
@@ -28,8 +28,8 @@ public class PlayerInfo(
|
|||||||
public DiePosition? DiePosition { get; set; }
|
public DiePosition? DiePosition { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public struct DiePosition(Vector? position = null, QAngle? angle = null)
|
public struct DiePosition(Vector position, QAngle angle)
|
||||||
{
|
{
|
||||||
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