1.7.1a
【UPDATE 1.7.1a】 🆕 What's new and what's changed: - Fixed 2x player lock text - Added immunity check when using css_addX - MenuManagerCS2 has been updated - Added return of lock ID by api (check example_module) - Fixed reasons for locks, no longer need to use `“”` if there is a space in them - Improved handling of lock times, from now on you can use: -- 1mo - 1 month -- 1w - 1 week -- 1d - 1 day -- 1h - 1 hour -- 1m - 1 minute -- 1 - 1 minute You can also combine it, e.g: 10d5h - 10 days and 5 hours 2w3d - 2 weeks and 3 days 1w1d1h1 - 1 week, 1 day and 1 minute So for example css_ban player 10d5h Super reason for my ban - Added a `rcon_password` column in the `sa_servers` table that populates with the rcon password - Fixed `banid` and banning - Fixed too fast kick (it was caused by checking players online) ⚠️ **Remember to update all files + api**
This commit is contained in:
parent
8af805632a
commit
3f1b6b3bf7
25 changed files with 532 additions and 253 deletions
|
|
@ -10,21 +10,26 @@ namespace CS2_SimpleAdmin.Managers;
|
|||
|
||||
internal class BanManager(Database.Database? database)
|
||||
{
|
||||
public async Task BanPlayer(PlayerInfo player, PlayerInfo? issuer, string reason, int time = 0)
|
||||
public async Task<int?> BanPlayer(PlayerInfo player, PlayerInfo? issuer, string reason, int time = 0)
|
||||
{
|
||||
if (database == null) return;
|
||||
|
||||
if (database == null) return null;
|
||||
|
||||
DateTime now = Time.ActualDateTime();
|
||||
DateTime futureTime = now.AddMinutes(time);
|
||||
|
||||
await using MySqlConnection connection = await database.GetConnectionAsync();
|
||||
try
|
||||
{
|
||||
const string sql =
|
||||
"INSERT INTO `sa_bans` (`player_steamid`, `player_name`, `player_ip`, `admin_steamid`, `admin_name`, `reason`, `duration`, `ends`, `created`, `server_id`) " +
|
||||
"VALUES (@playerSteamid, @playerName, @playerIp, @adminSteamid, @adminName, @banReason, @duration, @ends, @created, @serverid)";
|
||||
const string sql = """
|
||||
|
||||
INSERT INTO `sa_bans`
|
||||
(`player_steamid`, `player_name`, `player_ip`, `admin_steamid`, `admin_name`, `reason`, `duration`, `ends`, `created`, `server_id`)
|
||||
VALUES
|
||||
(@playerSteamid, @playerName, @playerIp, @adminSteamid, @adminName, @banReason, @duration, @ends, @created, @serverid);
|
||||
SELECT LAST_INSERT_ID();
|
||||
""";
|
||||
|
||||
await connection.ExecuteAsync(sql, new
|
||||
var banId = await connection.ExecuteScalarAsync<int?>(sql, new
|
||||
{
|
||||
playerSteamid = player.SteamId.SteamId64.ToString(),
|
||||
playerName = player.Name,
|
||||
|
|
@ -37,15 +42,19 @@ internal class BanManager(Database.Database? database)
|
|||
created = now,
|
||||
serverid = CS2_SimpleAdmin.ServerId
|
||||
});
|
||||
|
||||
return banId;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return null;
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
public async Task AddBanBySteamid(string playerSteamId, PlayerInfo? issuer, string reason, int time = 0)
|
||||
public async Task<int?> AddBanBySteamid(string playerSteamId, PlayerInfo? issuer, string reason, int time = 0)
|
||||
{
|
||||
if (database == null) return;
|
||||
|
||||
if (string.IsNullOrEmpty(playerSteamId)) return;
|
||||
if (database == null) return null;
|
||||
if (string.IsNullOrEmpty(playerSteamId)) return null;
|
||||
|
||||
DateTime now = Time.ActualDateTime();
|
||||
DateTime futureTime = now.AddMinutes(time);
|
||||
|
|
@ -54,10 +63,16 @@ internal class BanManager(Database.Database? database)
|
|||
{
|
||||
await using MySqlConnection connection = await database.GetConnectionAsync();
|
||||
|
||||
var sql = "INSERT INTO `sa_bans` (`player_steamid`, `admin_steamid`, `admin_name`, `reason`, `duration`, `ends`, `created`, `server_id`) " +
|
||||
"VALUES (@playerSteamid, @adminSteamid, @adminName, @banReason, @duration, @ends, @created, @serverid)";
|
||||
const string sql = """
|
||||
|
||||
INSERT INTO `sa_bans`
|
||||
(`player_steamid`, `admin_steamid`, `admin_name`, `reason`, `duration`, `ends`, `created`, `server_id`)
|
||||
VALUES
|
||||
(@playerSteamid, @adminSteamid, @adminName, @banReason, @duration, @ends, @created, @serverid);
|
||||
SELECT LAST_INSERT_ID();
|
||||
""";
|
||||
|
||||
await connection.ExecuteAsync(sql, new
|
||||
var banId = await connection.ExecuteScalarAsync<int?>(sql, new
|
||||
{
|
||||
playerSteamid = playerSteamId,
|
||||
adminSteamid = issuer?.SteamId.SteamId64.ToString() ?? CS2_SimpleAdmin._localizer?["sa_console"] ?? "Console",
|
||||
|
|
@ -68,8 +83,13 @@ internal class BanManager(Database.Database? database)
|
|||
created = now,
|
||||
serverid = CS2_SimpleAdmin.ServerId
|
||||
});
|
||||
|
||||
return banId;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
public async Task AddBanByIp(string playerIp, PlayerInfo? issuer, string reason, int time = 0)
|
||||
|
|
@ -383,7 +403,7 @@ internal class BanManager(Database.Database? database)
|
|||
foreach (var player in filteredPlayers.Where(player => bannedSteamIds.Contains(player.SteamID) ||
|
||||
(checkIpBans && bannedIps.Contains(player.IpAddress ?? ""))))
|
||||
{
|
||||
if (!player.UserId.HasValue) continue;
|
||||
if (!player.UserId.HasValue || CS2_SimpleAdmin.PlayersInfo[player.UserId.Value].WaitingForKick) continue;
|
||||
|
||||
await Server.NextFrameAsync(() =>
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue