mirror of
https://github.com/daffyyyy/CS2-SimpleAdmin.git
synced 2026-02-17 18:39:07 +00:00
1.3.6d - IMPORTANT
- Fixed pool size - Fixed `css_rename` - Updated CounterStrikeSharp - Minor changes
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
using CounterStrikeSharp.API.Core;
|
using CounterStrikeSharp.API;
|
||||||
|
using CounterStrikeSharp.API.Core;
|
||||||
using CounterStrikeSharp.API.Core.Attributes;
|
using CounterStrikeSharp.API.Core.Attributes;
|
||||||
using CounterStrikeSharp.API.Modules.Commands;
|
using CounterStrikeSharp.API.Modules.Commands;
|
||||||
using CounterStrikeSharp.API.Modules.Commands.Targeting;
|
using CounterStrikeSharp.API.Modules.Commands.Targeting;
|
||||||
@@ -12,7 +13,7 @@ using System.Collections.Concurrent;
|
|||||||
|
|
||||||
namespace CS2_SimpleAdmin;
|
namespace CS2_SimpleAdmin;
|
||||||
|
|
||||||
[MinimumApiVersion(191)]
|
[MinimumApiVersion(198)]
|
||||||
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 +39,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.6c";
|
public override string ModuleVersion => "1.3.6d";
|
||||||
|
|
||||||
public CS2_SimpleAdminConfig Config { get; set; } = new();
|
public CS2_SimpleAdminConfig Config { get; set; } = new();
|
||||||
|
|
||||||
@@ -71,7 +72,10 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
UserID = config.DatabaseUser,
|
UserID = config.DatabaseUser,
|
||||||
Password = config.DatabasePassword,
|
Password = config.DatabasePassword,
|
||||||
Port = (uint)config.DatabasePort,
|
Port = (uint)config.DatabasePort,
|
||||||
Pooling = true
|
Pooling = true,
|
||||||
|
MinimumPoolSize = 0,
|
||||||
|
MaximumPoolSize = (uint)(Server.MaxPlayers > 21 ? 640 : 210),
|
||||||
|
ConnectionIdleTimeout = 30
|
||||||
};
|
};
|
||||||
|
|
||||||
dbConnectionString = builder.ConnectionString;
|
dbConnectionString = builder.ConnectionString;
|
||||||
|
|||||||
@@ -10,10 +10,10 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="CounterStrikeSharp.API" Version="1.0.193" />
|
<PackageReference Include="CounterStrikeSharp.API" Version="1.0.198" />
|
||||||
<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.14.1" />
|
||||||
<PackageReference Include="MySqlConnector" Version="2.3.5" />
|
<PackageReference Include="MySqlConnector" Version="2.3.6" />
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="*" />
|
<PackageReference Include="Newtonsoft.Json" Version="*" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|||||||
@@ -33,7 +33,12 @@ namespace CS2_SimpleAdmin
|
|||||||
commandSql.CommandText = commandText;
|
commandSql.CommandText = commandText;
|
||||||
await commandSql.ExecuteNonQueryAsync();
|
await commandSql.ExecuteNonQueryAsync();
|
||||||
|
|
||||||
command.ReplyToCommand("Successfully updated the database");
|
commandText = "ALTER TABLE `sa_servers` MODIFY COLUMN `hostname` varchar(128);";
|
||||||
|
using var commandSql1 = connection.CreateCommand();
|
||||||
|
commandSql1.CommandText = commandText;
|
||||||
|
await commandSql1.ExecuteNonQueryAsync();
|
||||||
|
|
||||||
|
command.ReplyToCommand($"Successfully updated the database - {ModuleVersion}");
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -662,7 +662,6 @@ namespace CS2_SimpleAdmin
|
|||||||
|
|
||||||
if (caller!.CanTarget(player))
|
if (caller!.CanTarget(player))
|
||||||
{
|
{
|
||||||
player.Rename(newName);
|
|
||||||
|
|
||||||
if (caller == null || caller != null && !silentPlayers.Contains(caller.Slot))
|
if (caller == null || caller != null && !silentPlayers.Contains(caller.Slot))
|
||||||
{
|
{
|
||||||
@@ -676,6 +675,8 @@ namespace CS2_SimpleAdmin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
player.Rename(newName);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -815,6 +816,7 @@ namespace CS2_SimpleAdmin
|
|||||||
_discordWebhookClientLog.SendMessageAsync(Helper.GenerateMessageDiscord(_localizer["sa_discord_log_command", $"[{callerName}]({communityUrl})", command.GetCommandString]));
|
_discordWebhookClientLog.SendMessageAsync(Helper.GenerateMessageDiscord(_localizer["sa_discord_log_command", $"[{callerName}]({communityUrl})", command.GetCommandString]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Helper.LogCommand(caller, command);
|
Helper.LogCommand(caller, command);
|
||||||
|
|
||||||
playersToTarget.ForEach(player =>
|
playersToTarget.ForEach(player =>
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ CREATE TABLE IF NOT EXISTS `sa_admins` (
|
|||||||
CREATE TABLE IF NOT EXISTS `sa_servers` (
|
CREATE TABLE IF NOT EXISTS `sa_servers` (
|
||||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||||
`address` varchar(64) NOT NULL,
|
`address` varchar(64) NOT NULL,
|
||||||
`hostname` varchar(64) NOT NULL,
|
`hostname` varchar(128) NOT NULL,
|
||||||
PRIMARY KEY (`id`),
|
PRIMARY KEY (`id`),
|
||||||
UNIQUE KEY `address` (`address`)
|
UNIQUE KEY `address` (`address`)
|
||||||
) ENGINE=InnoDB AUTO_INCREMENT=36 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
) ENGINE=InnoDB AUTO_INCREMENT=36 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||||
188
Events.cs
188
Events.cs
@@ -32,70 +32,84 @@ public partial class CS2_SimpleAdmin
|
|||||||
CCSPlayerController? player = @event.Userid;
|
CCSPlayerController? player = @event.Userid;
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
Logger.LogCritical("[OnClientDisconnect] Before");
|
Logger.LogCritical("[OnClientDisconnect] Before");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (player is null || !player.IsValid || string.IsNullOrEmpty(player.IpAddress) || player.IsBot || player.IsHLTV) return HookResult.Continue;
|
if (player == null || !player.IsValid || string.IsNullOrEmpty(player.IpAddress) || player.IsBot || player.IsHLTV)
|
||||||
if (!loadedPlayers.Contains(player.Slot)) return HookResult.Continue;
|
{
|
||||||
|
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");
|
||||||
#endif
|
#endif
|
||||||
|
try
|
||||||
PlayerPenaltyManager playerPenaltyManager = new();
|
|
||||||
playerPenaltyManager.RemoveAllPenalties(player.Slot);
|
|
||||||
|
|
||||||
if (TagsDetected)
|
|
||||||
Server.ExecuteCommand($"css_tag_unmute {player.SteamID}");
|
|
||||||
|
|
||||||
if (silentPlayers.Contains(player.Slot))
|
|
||||||
RemoveFromConcurrentBag(silentPlayers, player.Slot);
|
|
||||||
if (godPlayers.Contains(player.Slot))
|
|
||||||
RemoveFromConcurrentBag(godPlayers, player.Slot);
|
|
||||||
|
|
||||||
loadedPlayers.Remove(player.Slot);
|
|
||||||
|
|
||||||
SteamID? authorizedSteamID = player.AuthorizedSteamID;
|
|
||||||
|
|
||||||
if (authorizedSteamID == null) return HookResult.Continue;
|
|
||||||
|
|
||||||
Task.Run(() =>
|
|
||||||
{
|
{
|
||||||
if (AdminSQLManager._adminCache.TryGetValue(authorizedSteamID, out DateTime? expirationTime)
|
PlayerPenaltyManager playerPenaltyManager = new PlayerPenaltyManager();
|
||||||
|
playerPenaltyManager.RemoveAllPenalties(player.Slot);
|
||||||
|
|
||||||
|
if (TagsDetected)
|
||||||
|
{
|
||||||
|
Server.ExecuteCommand($"css_tag_unmute {player.SteamID}");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (silentPlayers.Contains(player.Slot))
|
||||||
|
{
|
||||||
|
RemoveFromConcurrentBag(silentPlayers, player.Slot);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (godPlayers.Contains(player.Slot))
|
||||||
|
{
|
||||||
|
RemoveFromConcurrentBag(godPlayers, player.Slot);
|
||||||
|
}
|
||||||
|
|
||||||
|
SteamID? authorizedSteamID = player.AuthorizedSteamID;
|
||||||
|
if (authorizedSteamID != null && AdminSQLManager._adminCache.TryGetValue(authorizedSteamID, out DateTime? expirationTime)
|
||||||
&& expirationTime <= DateTime.Now)
|
&& expirationTime <= DateTime.Now)
|
||||||
{
|
{
|
||||||
AdminManager.ClearPlayerPermissions(authorizedSteamID);
|
AdminManager.ClearPlayerPermissions(authorizedSteamID);
|
||||||
AdminManager.RemovePlayerAdminData(authorizedSteamID);
|
AdminManager.RemovePlayerAdminData(authorizedSteamID);
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
return HookResult.Continue;
|
loadedPlayers.Remove(player.Slot);
|
||||||
|
|
||||||
|
return HookResult.Continue;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Logger.LogError($"An error occurred in OnClientDisconnect: {ex.Message}");
|
||||||
|
return HookResult.Continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
[GameEventHandler]
|
[GameEventHandler]
|
||||||
public HookResult OnPlayerFullConnect(EventPlayerConnectFull @event, GameEventInfo info)
|
public HookResult OnPlayerFullConnect(EventPlayerConnectFull @event, GameEventInfo info)
|
||||||
{
|
{
|
||||||
CCSPlayerController? player = @event.Userid;
|
CCSPlayerController? player = @event.Userid;
|
||||||
#if DEBUG
|
|
||||||
Logger.LogCritical($"[OnPlayerConnect] Before check {player.PlayerName} : {player.IpAddress}");
|
|
||||||
#endif
|
|
||||||
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 (player == null || string.IsNullOrEmpty(player.IpAddress) || player.IpAddress.Contains("127.0.0.1")
|
||||||
Logger.LogCritical("[OnPlayerConnect] After Check");
|
|| player.IsBot || player.IsHLTV || !player.UserId.HasValue)
|
||||||
#endif
|
return HookResult.Continue;
|
||||||
|
|
||||||
string ipAddress = player.IpAddress.Split(":")[0];
|
string ipAddress = player.IpAddress.Split(":")[0];
|
||||||
|
|
||||||
|
// Check if the player's IP or SteamID is in the bannedPlayers list
|
||||||
if (bannedPlayers.Contains(ipAddress) || bannedPlayers.Contains(player.SteamID.ToString()))
|
if (bannedPlayers.Contains(ipAddress) || bannedPlayers.Contains(player.SteamID.ToString()))
|
||||||
{
|
{
|
||||||
if (!player.UserId.HasValue) return HookResult.Continue;
|
// Kick the player if banned
|
||||||
Helper.KickPlayer(player.UserId.Value, "Banned");
|
if (player.UserId.HasValue)
|
||||||
|
Helper.KickPlayer(player.UserId.Value, "Banned");
|
||||||
|
|
||||||
return HookResult.Continue;
|
return HookResult.Continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_database == null || !player.UserId.HasValue || player.UserId == null)
|
if (_database == null) return HookResult.Continue;
|
||||||
return HookResult.Continue;
|
|
||||||
|
|
||||||
PlayerInfo playerInfo = new PlayerInfo
|
PlayerInfo playerInfo = new PlayerInfo
|
||||||
{
|
{
|
||||||
@@ -107,12 +121,13 @@ 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 () =>
|
||||||
{
|
{
|
||||||
|
// Initialize BanManager, MuteManager, and PlayerPenaltyManager within the async delegate
|
||||||
|
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))
|
||||||
@@ -178,6 +193,7 @@ public partial class CS2_SimpleAdmin
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Add player to loadedPlayers
|
||||||
if (!loadedPlayers.Contains(player.Slot))
|
if (!loadedPlayers.Contains(player.Slot))
|
||||||
loadedPlayers.Add(player.Slot);
|
loadedPlayers.Add(player.Slot);
|
||||||
|
|
||||||
@@ -197,7 +213,9 @@ public partial class CS2_SimpleAdmin
|
|||||||
|
|
||||||
public 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 || info.GetArg(1).StartsWith("/")
|
||||||
|
|| info.GetArg(1).StartsWith("!") && info.GetArg(1).Length >= 12)
|
||||||
|
return HookResult.Continue;
|
||||||
|
|
||||||
PlayerPenaltyManager playerPenaltyManager = new PlayerPenaltyManager();
|
PlayerPenaltyManager playerPenaltyManager = new PlayerPenaltyManager();
|
||||||
|
|
||||||
@@ -209,7 +227,9 @@ public partial class CS2_SimpleAdmin
|
|||||||
|
|
||||||
public 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 || info.GetArg(1).StartsWith("/")
|
||||||
|
|| info.GetArg(1).StartsWith("!") && info.GetArg(1).Length >= 12)
|
||||||
|
return HookResult.Continue;
|
||||||
|
|
||||||
PlayerPenaltyManager playerPenaltyManager = new PlayerPenaltyManager();
|
PlayerPenaltyManager playerPenaltyManager = new PlayerPenaltyManager();
|
||||||
|
|
||||||
@@ -262,63 +282,68 @@ public partial class CS2_SimpleAdmin
|
|||||||
|
|
||||||
if (_database == null) return;
|
if (_database == null) return;
|
||||||
|
|
||||||
AddTimer(61.0f, async () =>
|
AddTimer(61.0f, () =>
|
||||||
{
|
{
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
Logger.LogCritical("[OnMapStart] Expired check");
|
Logger.LogCritical("[OnMapStart] Expired check");
|
||||||
#endif
|
#endif
|
||||||
AdminSQLManager _adminManager = new(_database);
|
|
||||||
BanManager _banManager = new(_database, Config);
|
|
||||||
MuteManager _muteManager = new(_database);
|
|
||||||
await _banManager.ExpireOldBans();
|
|
||||||
await _muteManager.ExpireOldMutes();
|
|
||||||
await _adminManager.DeleteOldAdmins();
|
|
||||||
|
|
||||||
bannedPlayers.Clear();
|
Task.Run(async () =>
|
||||||
|
|
||||||
Server.NextFrame(() =>
|
|
||||||
{
|
{
|
||||||
try
|
AdminSQLManager _adminManager = new AdminSQLManager(_database);
|
||||||
|
BanManager _banManager = new BanManager(_database, Config);
|
||||||
|
MuteManager _muteManager = new MuteManager(_database);
|
||||||
|
await _banManager.ExpireOldBans();
|
||||||
|
await _muteManager.ExpireOldMutes();
|
||||||
|
await _adminManager.DeleteOldAdmins();
|
||||||
|
|
||||||
|
bannedPlayers.Clear();
|
||||||
|
|
||||||
|
Server.NextFrame(() =>
|
||||||
{
|
{
|
||||||
foreach (CCSPlayerController player in Helper.GetValidPlayers())
|
try
|
||||||
{
|
{
|
||||||
if (playerPenaltyManager.IsSlotInPenalties(player.Slot))
|
foreach (CCSPlayerController player in Helper.GetValidPlayers())
|
||||||
{
|
{
|
||||||
if (!playerPenaltyManager.IsPenalized(player.Slot, PenaltyType.Mute) && !playerPenaltyManager.IsPenalized(player.Slot, PenaltyType.Silence))
|
if (playerPenaltyManager.IsSlotInPenalties(player.Slot))
|
||||||
player.VoiceFlags = VoiceFlags.Normal;
|
|
||||||
|
|
||||||
if (!playerPenaltyManager.IsPenalized(player.Slot, PenaltyType.Gag) && !playerPenaltyManager.IsPenalized(player.Slot, PenaltyType.Silence))
|
|
||||||
{
|
{
|
||||||
if (TagsDetected)
|
if (!playerPenaltyManager.IsPenalized(player.Slot, PenaltyType.Mute) && !playerPenaltyManager.IsPenalized(player.Slot, PenaltyType.Silence))
|
||||||
Server.ExecuteCommand($"css_tag_unmute {player!.SteamID}");
|
player.VoiceFlags = VoiceFlags.Normal;
|
||||||
}
|
|
||||||
|
|
||||||
if (
|
if (!playerPenaltyManager.IsPenalized(player.Slot, PenaltyType.Gag) && !playerPenaltyManager.IsPenalized(player.Slot, PenaltyType.Silence))
|
||||||
!playerPenaltyManager.IsPenalized(player.Slot, PenaltyType.Silence) &&
|
{
|
||||||
!playerPenaltyManager.IsPenalized(player.Slot, PenaltyType.Mute) &&
|
if (TagsDetected)
|
||||||
!playerPenaltyManager.IsPenalized(player.Slot, PenaltyType.Gag)
|
Server.ExecuteCommand($"css_tag_unmute {player!.SteamID}");
|
||||||
)
|
}
|
||||||
{
|
|
||||||
player.VoiceFlags = VoiceFlags.Normal;
|
|
||||||
|
|
||||||
if (TagsDetected)
|
if (
|
||||||
Server.ExecuteCommand($"css_tag_unmute {player!.SteamID}");
|
!playerPenaltyManager.IsPenalized(player.Slot, PenaltyType.Silence) &&
|
||||||
|
!playerPenaltyManager.IsPenalized(player.Slot, PenaltyType.Mute) &&
|
||||||
|
!playerPenaltyManager.IsPenalized(player.Slot, PenaltyType.Gag)
|
||||||
|
)
|
||||||
|
{
|
||||||
|
player.VoiceFlags = VoiceFlags.Normal;
|
||||||
|
|
||||||
|
if (TagsDetected)
|
||||||
|
Server.ExecuteCommand($"css_tag_unmute {player!.SteamID}");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception) { }
|
|
||||||
});
|
|
||||||
|
|
||||||
playerPenaltyManager.RemoveExpiredPenalties();
|
playerPenaltyManager.RemoveExpiredPenalties();
|
||||||
|
}
|
||||||
|
catch (Exception) { }
|
||||||
|
});
|
||||||
|
});
|
||||||
}, 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(2.0f, async () =>
|
AddTimer(2.5f, () =>
|
||||||
{
|
{
|
||||||
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;
|
||||||
|
|
||||||
await Task.Run(async () =>
|
Task.Run(async () =>
|
||||||
{
|
{
|
||||||
AdminSQLManager _adminManager = new(_database);
|
AdminSQLManager _adminManager = new(_database);
|
||||||
try
|
try
|
||||||
@@ -354,6 +379,7 @@ public partial class CS2_SimpleAdmin
|
|||||||
|
|
||||||
await _adminManager.GiveAllFlags();
|
await _adminManager.GiveAllFlags();
|
||||||
});
|
});
|
||||||
|
|
||||||
}, CounterStrikeSharp.API.Modules.Timers.TimerFlags.STOP_ON_MAPCHANGE);
|
}, CounterStrikeSharp.API.Modules.Timers.TimerFlags.STOP_ON_MAPCHANGE);
|
||||||
|
|
||||||
AddTimer(3.0f, () =>
|
AddTimer(3.0f, () =>
|
||||||
|
|||||||
@@ -121,7 +121,7 @@ public static class PlayerExtensions
|
|||||||
if (CS2_SimpleAdmin.Instance == null)
|
if (CS2_SimpleAdmin.Instance == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
newName = CS2_SimpleAdmin._localizer?["sa_unknown"] ?? "Unknown";
|
newName = newName ?? CS2_SimpleAdmin._localizer?["sa_unknown"] ?? "Unknown";
|
||||||
|
|
||||||
SchemaString<CBasePlayerController> playerName = new SchemaString<CBasePlayerController>(controller, "m_iszPlayerName");
|
SchemaString<CBasePlayerController> playerName = new SchemaString<CBasePlayerController>(controller, "m_iszPlayerName");
|
||||||
playerName.Set(newName + " ");
|
playerName.Set(newName + " ");
|
||||||
|
|||||||
@@ -45,13 +45,13 @@ namespace CS2_SimpleAdmin
|
|||||||
|
|
||||||
public static List<CCSPlayerController> GetValidPlayers()
|
public static List<CCSPlayerController> GetValidPlayers()
|
||||||
{
|
{
|
||||||
return Utilities.GetPlayers().FindAll(p => p != null && p.IsValid && p.SteamID.ToString().Length == 17 && p.Connected == PlayerConnectedState.PlayerConnected && !p.IsBot && !p.IsHLTV);
|
return Utilities.GetPlayers().FindAll(p => p != null && p.IsValid && p.SteamID.ToString().Length == 17 && !string.IsNullOrEmpty(p.IpAddress) && p.Connected == PlayerConnectedState.PlayerConnected && !p.IsBot && !p.IsHLTV);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<CCSPlayerController> GetValidPlayersWithBots()
|
public static List<CCSPlayerController> GetValidPlayersWithBots()
|
||||||
{
|
{
|
||||||
return Utilities.GetPlayers().FindAll(p =>
|
return Utilities.GetPlayers().FindAll(p =>
|
||||||
p != null && p.IsValid && p.SteamID.ToString().Length == 17 && p.Connected == PlayerConnectedState.PlayerConnected && !p.IsBot && !p.IsHLTV ||
|
p != null && p.IsValid && p.SteamID.ToString().Length == 17 && !string.IsNullOrEmpty(p.IpAddress) && p.Connected == PlayerConnectedState.PlayerConnected && !p.IsBot && !p.IsHLTV ||
|
||||||
p != null && p.IsValid && p.Connected == PlayerConnectedState.PlayerConnected && p.IsBot && !p.IsHLTV
|
p != null && p.IsValid && p.Connected == PlayerConnectedState.PlayerConnected && p.IsBot && !p.IsHLTV
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,17 +17,22 @@ public class PlayerPenaltyManager
|
|||||||
// Add a penalty for a player
|
// Add a penalty for a player
|
||||||
public void AddPenalty(int slot, PenaltyType penaltyType, DateTime endDateTime, int durationSeconds)
|
public void AddPenalty(int slot, PenaltyType penaltyType, DateTime endDateTime, int durationSeconds)
|
||||||
{
|
{
|
||||||
if (!penalties.ContainsKey(slot))
|
penalties.AddOrUpdate(slot,
|
||||||
{
|
(_) =>
|
||||||
penalties[slot] = new Dictionary<PenaltyType, List<(DateTime, int)>>();
|
{
|
||||||
}
|
var dict = new Dictionary<PenaltyType, List<(DateTime, int)>>();
|
||||||
|
dict[penaltyType] = new List<(DateTime, int)>() { (endDateTime, durationSeconds) };
|
||||||
if (!penalties[slot].ContainsKey(penaltyType))
|
return dict;
|
||||||
{
|
},
|
||||||
penalties[slot][penaltyType] = new List<(DateTime, int)>();
|
(_, existingDict) =>
|
||||||
}
|
{
|
||||||
|
if (!existingDict.ContainsKey(penaltyType))
|
||||||
penalties[slot][penaltyType].Add((endDateTime, durationSeconds));
|
{
|
||||||
|
existingDict[penaltyType] = new List<(DateTime, int)>();
|
||||||
|
}
|
||||||
|
existingDict[penaltyType].Add((endDateTime, durationSeconds));
|
||||||
|
return existingDict;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsPenalized(int slot, PenaltyType penaltyType)
|
public bool IsPenalized(int slot, PenaltyType penaltyType)
|
||||||
|
|||||||
Reference in New Issue
Block a user