mirror of
https://github.com/daffyyyy/CS2-SimpleAdmin.git
synced 2026-02-17 10:31:01 +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 ModuleDescription => "Simple admin plugin for Counter-Strike 2 :)";
|
||||
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)
|
||||
{
|
||||
|
||||
@@ -378,11 +378,11 @@ public partial class CS2_SimpleAdmin
|
||||
await Server.NextWorldUpdateAsync(() =>
|
||||
{
|
||||
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))
|
||||
AddTimer(1.5f, () => AdminManager.LoadAdminGroups(ModuleDirectory + "/data/groups.json"));
|
||||
AddTimer(0.8f, () => AdminManager.LoadAdminGroups(ModuleDirectory + "/data/groups.json"));
|
||||
if (!string.IsNullOrEmpty(adminsFile))
|
||||
AddTimer(2.0f, () => AdminManager.LoadAdminData(ModuleDirectory + "/data/admins.json"));
|
||||
AddTimer(1.1f, () => AdminManager.LoadAdminData(ModuleDirectory + "/data/admins.json"));
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -224,14 +224,17 @@ public class OtherSettings
|
||||
|
||||
[JsonPropertyName("UserMessageGagChatType")]
|
||||
public bool UserMessageGagChatType { get; set; } = false;
|
||||
|
||||
[JsonPropertyName("CheckMultiAccountsByIp")]
|
||||
public bool CheckMultiAccountsByIp { get; set; } = true;
|
||||
|
||||
[JsonPropertyName("AdditionalCommandsToLog")]
|
||||
public List<string> AdditionalCommandsToLog = new();
|
||||
public List<string> AdditionalCommandsToLog { get; set; } = new();
|
||||
}
|
||||
|
||||
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")]
|
||||
public string DatabaseHost { get; set; } = "";
|
||||
|
||||
@@ -128,7 +128,7 @@ public partial class CS2_SimpleAdmin
|
||||
|
||||
if (player == null || !player.IsValid || player.IsBot)
|
||||
return HookResult.Continue;
|
||||
|
||||
|
||||
new PlayerManager().LoadPlayerData(player);
|
||||
|
||||
return HookResult.Continue;
|
||||
@@ -147,7 +147,7 @@ public partial class CS2_SimpleAdmin
|
||||
|
||||
foreach (var player in PlayersInfo.Values)
|
||||
{
|
||||
player.DiePosition = null;
|
||||
player.DiePosition = default;
|
||||
}
|
||||
|
||||
AddTimer(0.41f, () =>
|
||||
@@ -215,8 +215,6 @@ public partial class CS2_SimpleAdmin
|
||||
if (target == null || !target.IsValid || target.Connected != PlayerConnectedState.PlayerConnected)
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -357,9 +355,10 @@ public partial class CS2_SimpleAdmin
|
||||
|
||||
if (player is null || @event.Attacker is null || !player.PawnIsAlive || player.PlayerPawn.Value == null)
|
||||
return HookResult.Continue;
|
||||
|
||||
|
||||
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;
|
||||
|
||||
@@ -373,26 +372,29 @@ public partial class CS2_SimpleAdmin
|
||||
public HookResult OnPlayerDeath(EventPlayerDeath @event, GameEventInfo info)
|
||||
{
|
||||
var player = @event.Userid;
|
||||
|
||||
|
||||
if (player?.UserId == null || !player.IsValid || player.IsHLTV || player.Connected != PlayerConnectedState.PlayerConnected)
|
||||
return HookResult.Continue;
|
||||
|
||||
SpeedPlayers.Remove(player.Slot);
|
||||
GravityPlayers.Remove(player);
|
||||
|
||||
if (!PlayersInfo.ContainsKey(player.UserId.Value))
|
||||
if (!PlayersInfo.ContainsKey(player.UserId.Value) || @event.Attacker == null)
|
||||
return HookResult.Continue;
|
||||
|
||||
var playerPosition = player.PlayerPawn.Value?.AbsOrigin;
|
||||
var playerRotation = player.PlayerPawn.Value?.AbsRotation;
|
||||
|
||||
PlayersInfo[player.UserId.Value].DiePosition = new DiePosition(
|
||||
new Vector(
|
||||
player.PlayerPawn.Value?.AbsOrigin?.X ?? 0,
|
||||
player.PlayerPawn.Value?.AbsOrigin?.Y ?? 0,
|
||||
player.PlayerPawn.Value?.AbsOrigin?.Z ?? 0
|
||||
playerPosition?.X ?? 0,
|
||||
playerPosition?.Y ?? 0,
|
||||
playerPosition?.Z ?? 0
|
||||
),
|
||||
new QAngle(
|
||||
player.PlayerPawn.Value?.AbsRotation?.X ?? 0,
|
||||
player.PlayerPawn.Value?.AbsRotation?.Y ?? 0,
|
||||
player.PlayerPawn.Value?.AbsRotation?.Z ?? 0
|
||||
playerRotation?.X ?? 0,
|
||||
playerRotation?.Y ?? 0,
|
||||
playerRotation?.Z ?? 0
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
@@ -32,7 +32,8 @@ public static class PlayerExtensions
|
||||
|
||||
return AdminManager.CanPlayerTarget(controller, target) ||
|
||||
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)
|
||||
|
||||
@@ -158,6 +158,23 @@ internal static class Helper
|
||||
//
|
||||
// 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)
|
||||
{
|
||||
|
||||
@@ -123,7 +123,11 @@ internal class BanManager(Database.Database? database)
|
||||
|
||||
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 COUNT(*)
|
||||
FROM sa_bans
|
||||
@@ -172,7 +176,36 @@ internal class BanManager(Database.Database? database)
|
||||
)
|
||||
), 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();
|
||||
|
||||
var parameters = new
|
||||
|
||||
@@ -90,13 +90,12 @@ public class PermissionManager(Database.Database? database)
|
||||
))
|
||||
.ToList();
|
||||
|
||||
/*
|
||||
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}");
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
// 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}");
|
||||
// }
|
||||
|
||||
List<(string, string, List<string>, int, DateTime?)> filteredFlagsWithImmunity = [];
|
||||
|
||||
// Add the grouped players to the list
|
||||
|
||||
@@ -16,15 +16,26 @@ public class PlayerManager
|
||||
|
||||
public void LoadPlayerData(CCSPlayerController player)
|
||||
{
|
||||
if (player.IsBot || string.IsNullOrEmpty(player.IpAddress) || player.IpAddress.Contains("127.0.0.1")
|
||||
|| !player.UserId.HasValue)
|
||||
if (player.IsBot || string.IsNullOrEmpty(player.IpAddress) || player.IpAddress.Contains("127.0.0.1"))
|
||||
return;
|
||||
|
||||
if (!player.UserId.HasValue)
|
||||
{
|
||||
Helper.KickPlayer(player, NetworkDisconnectionReason.NETWORK_DISCONNECT_REJECT_INVALIDCONNECTION);
|
||||
return;
|
||||
}
|
||||
|
||||
var ipAddress = player.IpAddress?.Split(":")[0];
|
||||
|
||||
CS2_SimpleAdmin.PlayersInfo[player.UserId.Value] =
|
||||
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;
|
||||
|
||||
// Check if the player's IP or SteamID is in the bannedPlayers list
|
||||
@@ -32,8 +43,7 @@ public class PlayerManager
|
||||
CS2_SimpleAdmin.BannedPlayers.Contains(player.SteamID.ToString()))
|
||||
{
|
||||
// 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;
|
||||
}
|
||||
|
||||
@@ -113,7 +123,7 @@ public class PlayerManager
|
||||
{
|
||||
var victim = Utilities.GetPlayerFromUserid(userId);
|
||||
|
||||
if (victim?.UserId == null) return;
|
||||
if (victim == null || !victim.UserId.HasValue) return;
|
||||
|
||||
if (CS2_SimpleAdmin.UnlockedCommands)
|
||||
Server.ExecuteCommand($"banid 1 {userId}");
|
||||
|
||||
@@ -11,11 +11,11 @@ public class ServerManager
|
||||
|
||||
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 (_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!");
|
||||
return;
|
||||
@@ -27,7 +27,7 @@ public class ServerManager
|
||||
{
|
||||
ipAddress = Helper.GetServerIp();
|
||||
|
||||
if (_getIpTryCount <= 16)
|
||||
if (_getIpTryCount <= 32)
|
||||
{
|
||||
_getIpTryCount++;
|
||||
|
||||
|
||||
@@ -1 +1 @@
|
||||
1.6.9a
|
||||
1.6.9c
|
||||
@@ -28,8 +28,8 @@ public class PlayerInfo(
|
||||
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 QAngle? Angle { get; set; } = angle;
|
||||
public Vector Position { get; set; } = position;
|
||||
public QAngle Angle { get; set; } = angle;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user