mirror of
https://github.com/daffyyyy/CS2-SimpleAdmin.git
synced 2026-03-08 23:59:06 +00:00
1.2.8a
- Small fixes
This commit is contained in:
@@ -147,6 +147,8 @@ namespace CS2_SimpleAdmin
|
|||||||
return flagsToCache.Cast<object>().ToList();
|
return flagsToCache.Cast<object>().ToList();
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
await connection.CloseAsync();
|
||||||
|
|
||||||
return filteredFlagsWithImmunity;
|
return filteredFlagsWithImmunity;
|
||||||
//return filteredFlags.Cast<object>().ToList();
|
//return filteredFlags.Cast<object>().ToList();
|
||||||
}
|
}
|
||||||
@@ -208,6 +210,8 @@ namespace CS2_SimpleAdmin
|
|||||||
filteredFlagsWithImmunity.Add((steamId, flagsValue.Split(',').ToList(), immunityValue, ends));
|
filteredFlagsWithImmunity.Add((steamId, flagsValue.Split(',').ToList(), immunityValue, ends));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await connection.CloseAsync();
|
||||||
|
|
||||||
return filteredFlagsWithImmunity;
|
return filteredFlagsWithImmunity;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -259,6 +263,8 @@ namespace CS2_SimpleAdmin
|
|||||||
}
|
}
|
||||||
|
|
||||||
await connection.ExecuteAsync(sql, new { PlayerSteamID = playerSteamId, ServerId = CS2_SimpleAdmin.ServerId });
|
await connection.ExecuteAsync(sql, new { PlayerSteamID = playerSteamId, ServerId = CS2_SimpleAdmin.ServerId });
|
||||||
|
|
||||||
|
await connection.CloseAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task AddAdminBySteamId(string playerSteamId, string playerName, string flags, int immunity = 0, int time = 0, bool globalAdmin = false)
|
public async Task AddAdminBySteamId(string playerSteamId, string playerName, string flags, int immunity = 0, int time = 0, bool globalAdmin = false)
|
||||||
@@ -292,6 +298,8 @@ namespace CS2_SimpleAdmin
|
|||||||
created = now,
|
created = now,
|
||||||
serverid = serverId
|
serverid = serverId
|
||||||
});
|
});
|
||||||
|
|
||||||
|
await connection.CloseAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task DeleteOldAdmins()
|
public async Task DeleteOldAdmins()
|
||||||
@@ -301,6 +309,8 @@ namespace CS2_SimpleAdmin
|
|||||||
|
|
||||||
string sql = "DELETE FROM sa_admins WHERE ends IS NOT NULL AND ends <= @CurrentTime";
|
string sql = "DELETE FROM sa_admins WHERE ends IS NOT NULL AND ends <= @CurrentTime";
|
||||||
await connection.ExecuteAsync(sql, new { CurrentTime = DateTime.Now });
|
await connection.ExecuteAsync(sql, new { CurrentTime = DateTime.Now });
|
||||||
|
|
||||||
|
await connection.CloseAsync();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -6,10 +6,12 @@ namespace CS2_SimpleAdmin
|
|||||||
internal class BanManager
|
internal class BanManager
|
||||||
{
|
{
|
||||||
private readonly MySqlConnection _dbConnection;
|
private readonly MySqlConnection _dbConnection;
|
||||||
|
private readonly CS2_SimpleAdminConfig _config;
|
||||||
|
|
||||||
public BanManager(string connectionString)
|
public BanManager(string connectionString, CS2_SimpleAdminConfig config)
|
||||||
{
|
{
|
||||||
_dbConnection = new MySqlConnection(connectionString);
|
_dbConnection = new MySqlConnection(connectionString);
|
||||||
|
_config = config;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task BanPlayer(PlayerInfo player, PlayerInfo issuer, string reason, int time = 0)
|
public async Task BanPlayer(PlayerInfo player, PlayerInfo issuer, string reason, int time = 0)
|
||||||
@@ -23,12 +25,11 @@ namespace CS2_SimpleAdmin
|
|||||||
var sql = "INSERT INTO `sa_bans` (`player_steamid`, `player_name`, `player_ip`, `admin_steamid`, `admin_name`, `reason`, `duration`, `ends`, `created`, `server_id`) " +
|
var 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)";
|
"VALUES (@playerSteamid, @playerName, @playerIp, @adminSteamid, @adminName, @banReason, @duration, @ends, @created, @serverid)";
|
||||||
|
|
||||||
CS2_SimpleAdminConfig config = new CS2_SimpleAdminConfig();
|
|
||||||
await connection.ExecuteAsync(sql, new
|
await connection.ExecuteAsync(sql, new
|
||||||
{
|
{
|
||||||
playerSteamid = player.SteamId,
|
playerSteamid = player.SteamId,
|
||||||
playerName = player.Name,
|
playerName = player.Name,
|
||||||
playerIp = config.BanType == 1 ? player.IpAddress : null,
|
playerIp = _config.BanType == 1 ? player.IpAddress : null,
|
||||||
adminSteamid = issuer.SteamId == null ? "Console" : issuer.SteamId,
|
adminSteamid = issuer.SteamId == null ? "Console" : issuer.SteamId,
|
||||||
adminName = issuer.Name == null ? "Console" : issuer.Name,
|
adminName = issuer.Name == null ? "Console" : issuer.Name,
|
||||||
banReason = reason,
|
banReason = reason,
|
||||||
@@ -37,6 +38,8 @@ namespace CS2_SimpleAdmin
|
|||||||
created = now,
|
created = now,
|
||||||
serverid = CS2_SimpleAdmin.ServerId
|
serverid = CS2_SimpleAdmin.ServerId
|
||||||
});
|
});
|
||||||
|
|
||||||
|
await connection.CloseAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task AddBanBySteamid(string playerSteamId, PlayerInfo issuer, string reason, int time = 0)
|
public async Task AddBanBySteamid(string playerSteamId, PlayerInfo issuer, string reason, int time = 0)
|
||||||
@@ -63,6 +66,8 @@ namespace CS2_SimpleAdmin
|
|||||||
created = now,
|
created = now,
|
||||||
serverid = CS2_SimpleAdmin.ServerId
|
serverid = CS2_SimpleAdmin.ServerId
|
||||||
});
|
});
|
||||||
|
|
||||||
|
await connection.CloseAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task AddBanByIp(string playerIp, PlayerInfo issuer, string reason, int time = 0)
|
public async Task AddBanByIp(string playerIp, PlayerInfo issuer, string reason, int time = 0)
|
||||||
@@ -89,6 +94,8 @@ namespace CS2_SimpleAdmin
|
|||||||
created = now,
|
created = now,
|
||||||
serverid = CS2_SimpleAdmin.ServerId
|
serverid = CS2_SimpleAdmin.ServerId
|
||||||
});
|
});
|
||||||
|
|
||||||
|
await connection.CloseAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<bool> IsPlayerBanned(PlayerInfo player)
|
public async Task<bool> IsPlayerBanned(PlayerInfo player)
|
||||||
@@ -111,6 +118,8 @@ namespace CS2_SimpleAdmin
|
|||||||
banCount = await connection.ExecuteScalarAsync<int>(sql, new { PlayerSteamID = player.SteamId, PlayerIP = DBNull.Value, CurrentTime = now });
|
banCount = await connection.ExecuteScalarAsync<int>(sql, new { PlayerSteamID = player.SteamId, PlayerIP = DBNull.Value, CurrentTime = now });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await connection.CloseAsync();
|
||||||
|
|
||||||
return banCount > 0;
|
return banCount > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -131,6 +140,8 @@ namespace CS2_SimpleAdmin
|
|||||||
banCount = await connection.ExecuteScalarAsync<int>(sql, new { PlayerSteamID = player.SteamId, PlayerIP = DBNull.Value });
|
banCount = await connection.ExecuteScalarAsync<int>(sql, new { PlayerSteamID = player.SteamId, PlayerIP = DBNull.Value });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await connection.CloseAsync();
|
||||||
|
|
||||||
return banCount;
|
return banCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -146,6 +157,8 @@ namespace CS2_SimpleAdmin
|
|||||||
|
|
||||||
string sqlUnban = "UPDATE sa_bans SET status = 'UNBANNED' WHERE player_steamid = @pattern OR player_name = @pattern OR player_ip = @pattern AND status = 'ACTIVE'";
|
string sqlUnban = "UPDATE sa_bans SET status = 'UNBANNED' WHERE player_steamid = @pattern OR player_name = @pattern OR player_ip = @pattern AND status = 'ACTIVE'";
|
||||||
await connection.ExecuteAsync(sqlUnban, new { pattern = playerPattern });
|
await connection.ExecuteAsync(sqlUnban, new { pattern = playerPattern });
|
||||||
|
|
||||||
|
await connection.CloseAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task ExpireOldBans()
|
public async Task ExpireOldBans()
|
||||||
@@ -155,6 +168,8 @@ namespace CS2_SimpleAdmin
|
|||||||
|
|
||||||
string sql = "UPDATE sa_bans SET status = 'EXPIRED' WHERE status = 'ACTIVE' AND `duration` > 0 AND ends <= @CurrentTime";
|
string sql = "UPDATE sa_bans SET status = 'EXPIRED' WHERE status = 'ACTIVE' AND `duration` > 0 AND ends <= @CurrentTime";
|
||||||
await connection.ExecuteAsync(sql, new { CurrentTime = DateTime.Now });
|
await connection.ExecuteAsync(sql, new { CurrentTime = DateTime.Now });
|
||||||
|
|
||||||
|
await connection.CloseAsync();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -24,7 +24,6 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
public static IStringLocalizer? _localizer;
|
public static IStringLocalizer? _localizer;
|
||||||
public static ConcurrentBag<ushort> gaggedPlayers = new ConcurrentBag<ushort>();
|
public static ConcurrentBag<ushort> gaggedPlayers = new ConcurrentBag<ushort>();
|
||||||
//public static ConcurrentBag<int> mutedPlayers = new ConcurrentBag<int>();
|
//public static ConcurrentBag<int> mutedPlayers = new ConcurrentBag<int>();
|
||||||
public static List<int> loadedPlayers = new List<int>();
|
|
||||||
public static Dictionary<string, int> voteAnswers = new Dictionary<string, int>();
|
public static Dictionary<string, int> voteAnswers = new Dictionary<string, int>();
|
||||||
public static HashSet<ushort> godPlayers = new HashSet<ushort>();
|
public static HashSet<ushort> godPlayers = new HashSet<ushort>();
|
||||||
public static List<ushort> silentPlayers = new List<ushort>();
|
public static List<ushort> silentPlayers = new List<ushort>();
|
||||||
@@ -303,7 +302,7 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
if (targets == null) return;
|
if (targets == null) return;
|
||||||
List<CCSPlayerController> playersToTarget = targets!.Players.Where(player => caller!.CanTarget(player) && player != null && player.IsValid && !player.IsBot && !player.IsHLTV).ToList();
|
List<CCSPlayerController> playersToTarget = targets!.Players.Where(player => caller!.CanTarget(player) && player != null && player.IsValid && !player.IsBot && !player.IsHLTV).ToList();
|
||||||
|
|
||||||
BanManager _banManager = new(dbConnectionString);
|
BanManager _banManager = new(dbConnectionString, Config);
|
||||||
MuteManager _muteManager = new(dbConnectionString);
|
MuteManager _muteManager = new(dbConnectionString);
|
||||||
|
|
||||||
playersToTarget.ForEach(player =>
|
playersToTarget.ForEach(player =>
|
||||||
@@ -435,7 +434,11 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
{
|
{
|
||||||
if (caller!.CanTarget(player))
|
if (caller!.CanTarget(player))
|
||||||
{
|
{
|
||||||
player.Pawn.Value!.Freeze();
|
if (player.PawnIsAlive)
|
||||||
|
{
|
||||||
|
player.Pawn.Value!.Freeze();
|
||||||
|
player.CommitSuicide(true, true);
|
||||||
|
}
|
||||||
|
|
||||||
if (command.ArgCount >= 2)
|
if (command.ArgCount >= 2)
|
||||||
{
|
{
|
||||||
@@ -1091,7 +1094,7 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
BanManager _banManager = new(dbConnectionString);
|
BanManager _banManager = new(dbConnectionString, Config);
|
||||||
|
|
||||||
int.TryParse(command.GetArg(2), out time);
|
int.TryParse(command.GetArg(2), out time);
|
||||||
|
|
||||||
@@ -1102,7 +1105,11 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
{
|
{
|
||||||
if (caller!.CanTarget(player))
|
if (caller!.CanTarget(player))
|
||||||
{
|
{
|
||||||
player.Pawn.Value!.Freeze();
|
if (player.PawnIsAlive)
|
||||||
|
{
|
||||||
|
player.Pawn.Value!.Freeze();
|
||||||
|
player.CommitSuicide(true, true);
|
||||||
|
}
|
||||||
|
|
||||||
PlayerInfo playerInfo = new PlayerInfo
|
PlayerInfo playerInfo = new PlayerInfo
|
||||||
{
|
{
|
||||||
@@ -1171,7 +1178,7 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
int time = 0;
|
int time = 0;
|
||||||
string reason = "Unknown";
|
string reason = "Unknown";
|
||||||
|
|
||||||
BanManager _banManager = new(dbConnectionString);
|
BanManager _banManager = new(dbConnectionString, Config);
|
||||||
|
|
||||||
int.TryParse(command.GetArg(2), out time);
|
int.TryParse(command.GetArg(2), out time);
|
||||||
|
|
||||||
@@ -1227,7 +1234,7 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
|
|
||||||
Task.Run(async () =>
|
Task.Run(async () =>
|
||||||
{
|
{
|
||||||
BanManager _banManager = new(dbConnectionString);
|
BanManager _banManager = new(dbConnectionString, Config);
|
||||||
await _banManager.AddBanBySteamid(steamid, adminInfo, reason, time);
|
await _banManager.AddBanBySteamid(steamid, adminInfo, reason, time);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -1309,7 +1316,7 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
|
|
||||||
Task.Run(async () =>
|
Task.Run(async () =>
|
||||||
{
|
{
|
||||||
BanManager _banManager = new(dbConnectionString);
|
BanManager _banManager = new(dbConnectionString, Config);
|
||||||
await _banManager.AddBanByIp(ipAddress, adminInfo, reason, time);
|
await _banManager.AddBanByIp(ipAddress, adminInfo, reason, time);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -1328,7 +1335,7 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
}
|
}
|
||||||
|
|
||||||
string pattern = command.GetArg(1);
|
string pattern = command.GetArg(1);
|
||||||
BanManager _banManager = new(dbConnectionString);
|
BanManager _banManager = new(dbConnectionString, Config);
|
||||||
|
|
||||||
_ = _banManager.UnbanPlayer(pattern);
|
_ = _banManager.UnbanPlayer(pattern);
|
||||||
|
|
||||||
|
|||||||
39
Events.cs
39
Events.cs
@@ -151,7 +151,7 @@ public partial class CS2_SimpleAdmin
|
|||||||
|
|
||||||
Task.Run(async () =>
|
Task.Run(async () =>
|
||||||
{
|
{
|
||||||
BanManager _banManager = new(dbConnectionString);
|
BanManager _banManager = new(dbConnectionString, Config);
|
||||||
bool isBanned = await _banManager.IsPlayerBanned(playerInfo);
|
bool isBanned = await _banManager.IsPlayerBanned(playerInfo);
|
||||||
|
|
||||||
MuteManager _muteManager = new(dbConnectionString);
|
MuteManager _muteManager = new(dbConnectionString);
|
||||||
@@ -360,7 +360,7 @@ public partial class CS2_SimpleAdmin
|
|||||||
|
|
||||||
Task.Run(async () =>
|
Task.Run(async () =>
|
||||||
{
|
{
|
||||||
BanManager _banManager = new(dbConnectionString);
|
BanManager _banManager = new(dbConnectionString, Config);
|
||||||
bool isBanned = await _banManager.IsPlayerBanned(playerInfo);
|
bool isBanned = await _banManager.IsPlayerBanned(playerInfo);
|
||||||
|
|
||||||
MuteManager _muteManager = new(dbConnectionString);
|
MuteManager _muteManager = new(dbConnectionString);
|
||||||
@@ -501,9 +501,6 @@ public partial class CS2_SimpleAdmin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (player.UserId != null && !loadedPlayers.Contains((ushort)player.UserId))
|
|
||||||
loadedPlayers.Add((ushort)player.UserId);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -542,9 +539,6 @@ public partial class CS2_SimpleAdmin
|
|||||||
godPlayers.Remove((ushort)player.UserId);
|
godPlayers.Remove((ushort)player.UserId);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (player.UserId != null && loadedPlayers.Contains((ushort)player.UserId))
|
|
||||||
loadedPlayers.Remove((ushort)player.UserId);
|
|
||||||
|
|
||||||
if (player.AuthorizedSteamID != null && AdminSQLManager._adminCacheSet.Contains(player.AuthorizedSteamID))
|
if (player.AuthorizedSteamID != null && AdminSQLManager._adminCacheSet.Contains(player.AuthorizedSteamID))
|
||||||
{
|
{
|
||||||
if (AdminSQLManager._adminCacheTimestamps != null && AdminSQLManager._adminCacheTimestamps.TryGetValue(player.AuthorizedSteamID, out DateTime? expirationTime) && expirationTime.HasValue && expirationTime.Value <= DateTime.Now)
|
if (AdminSQLManager._adminCacheTimestamps != null && AdminSQLManager._adminCacheTimestamps.TryGetValue(player.AuthorizedSteamID, out DateTime? expirationTime) && expirationTime.HasValue && expirationTime.Value <= DateTime.Now)
|
||||||
@@ -565,7 +559,7 @@ public partial class CS2_SimpleAdmin
|
|||||||
AddTimer(60.0f, bannedPlayers.Clear, CounterStrikeSharp.API.Modules.Timers.TimerFlags.REPEAT | CounterStrikeSharp.API.Modules.Timers.TimerFlags.STOP_ON_MAPCHANGE);
|
AddTimer(60.0f, bannedPlayers.Clear, CounterStrikeSharp.API.Modules.Timers.TimerFlags.REPEAT | CounterStrikeSharp.API.Modules.Timers.TimerFlags.STOP_ON_MAPCHANGE);
|
||||||
AddTimer(120.0f, () =>
|
AddTimer(120.0f, () =>
|
||||||
{
|
{
|
||||||
BanManager _banManager = new(dbConnectionString);
|
BanManager _banManager = new(dbConnectionString, Config);
|
||||||
MuteManager _muteManager = new(dbConnectionString);
|
MuteManager _muteManager = new(dbConnectionString);
|
||||||
_ = _banManager.ExpireOldBans();
|
_ = _banManager.ExpireOldBans();
|
||||||
_ = _muteManager.ExpireOldMutes();
|
_ = _muteManager.ExpireOldMutes();
|
||||||
@@ -578,23 +572,26 @@ public partial class CS2_SimpleAdmin
|
|||||||
TagsDetected = true;
|
TagsDetected = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
using (var connection = new MySqlConnection(dbConnectionString))
|
AddTimer(1.0f, () =>
|
||||||
{
|
{
|
||||||
connection.Open();
|
using (var connection = new MySqlConnection(dbConnectionString))
|
||||||
|
{
|
||||||
|
connection.Open();
|
||||||
|
|
||||||
connection.Execute(
|
connection.Execute(
|
||||||
"INSERT INTO `sa_servers` (address, hostname) VALUES (@address, @hostname) " +
|
"INSERT INTO `sa_servers` (address, hostname) VALUES (@address, @hostname) " +
|
||||||
"ON DUPLICATE KEY UPDATE hostname = @hostname",
|
"ON DUPLICATE KEY UPDATE hostname = @hostname",
|
||||||
new { address = $"{ConVar.Find("ip")!.StringValue}:{ConVar.Find("hostport")!.GetPrimitiveValue<int>()}", hostname = ConVar.Find("hostname")!.StringValue });
|
new { address = $"{ConVar.Find("ip")!.StringValue}:{ConVar.Find("hostport")!.GetPrimitiveValue<int>()}", hostname = ConVar.Find("hostname")!.StringValue });
|
||||||
|
|
||||||
int? serverId = connection.ExecuteScalar<int>(
|
int? serverId = connection.ExecuteScalar<int>(
|
||||||
"SELECT `id` FROM `sa_servers` WHERE `address` = @address",
|
"SELECT `id` FROM `sa_servers` WHERE `address` = @address",
|
||||||
new { address = $"{ConVar.Find("ip")!.StringValue}:{ConVar.Find("hostport")!.GetPrimitiveValue<int>()}" });
|
new { address = $"{ConVar.Find("ip")!.StringValue}:{ConVar.Find("hostport")!.GetPrimitiveValue<int>()}" });
|
||||||
|
|
||||||
ServerId = serverId;
|
ServerId = serverId;
|
||||||
|
|
||||||
connection.Close();
|
connection.Close();
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
_ = _adminManager.GiveAllFlags();
|
_ = _adminManager.GiveAllFlags();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,6 +44,8 @@ namespace CS2_SimpleAdmin
|
|||||||
type = muteType,
|
type = muteType,
|
||||||
serverid = CS2_SimpleAdmin.ServerId
|
serverid = CS2_SimpleAdmin.ServerId
|
||||||
});
|
});
|
||||||
|
|
||||||
|
await connection.CloseAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task AddMuteBySteamid(string playerSteamId, PlayerInfo issuer, string reason, int time = 0, int type = 0)
|
public async Task AddMuteBySteamid(string playerSteamId, PlayerInfo issuer, string reason, int time = 0, int type = 0)
|
||||||
@@ -75,6 +77,8 @@ namespace CS2_SimpleAdmin
|
|||||||
type = muteType,
|
type = muteType,
|
||||||
serverid = CS2_SimpleAdmin.ServerId
|
serverid = CS2_SimpleAdmin.ServerId
|
||||||
});
|
});
|
||||||
|
|
||||||
|
await connection.CloseAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<List<dynamic>> IsPlayerMuted(string steamId)
|
public async Task<List<dynamic>> IsPlayerMuted(string steamId)
|
||||||
@@ -87,6 +91,8 @@ namespace CS2_SimpleAdmin
|
|||||||
string sql = "SELECT * FROM sa_mutes WHERE player_steamid = @PlayerSteamID AND status = 'ACTIVE' AND (duration = 0 OR ends > @CurrentTime)";
|
string sql = "SELECT * FROM sa_mutes WHERE player_steamid = @PlayerSteamID AND status = 'ACTIVE' AND (duration = 0 OR ends > @CurrentTime)";
|
||||||
var activeMutes = (await connection.QueryAsync(sql, new { PlayerSteamID = steamId, CurrentTime = now })).ToList();
|
var activeMutes = (await connection.QueryAsync(sql, new { PlayerSteamID = steamId, CurrentTime = now })).ToList();
|
||||||
|
|
||||||
|
await connection.CloseAsync();
|
||||||
|
|
||||||
return activeMutes;
|
return activeMutes;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -100,6 +106,8 @@ namespace CS2_SimpleAdmin
|
|||||||
|
|
||||||
muteCount = await connection.ExecuteScalarAsync<int>(sql, new { PlayerSteamID = steamId });
|
muteCount = await connection.ExecuteScalarAsync<int>(sql, new { PlayerSteamID = steamId });
|
||||||
|
|
||||||
|
await connection.CloseAsync();
|
||||||
|
|
||||||
return muteCount;
|
return muteCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -134,6 +142,8 @@ namespace CS2_SimpleAdmin
|
|||||||
|
|
||||||
string sqlUnban = "UPDATE sa_mutes SET status = 'UNMUTED' WHERE (player_steamid = @pattern OR player_name = @pattern) AND type = @muteType AND status = 'ACTIVE'";
|
string sqlUnban = "UPDATE sa_mutes SET status = 'UNMUTED' WHERE (player_steamid = @pattern OR player_name = @pattern) AND type = @muteType AND status = 'ACTIVE'";
|
||||||
await connection.ExecuteAsync(sqlUnban, new { pattern = playerPattern, muteType });
|
await connection.ExecuteAsync(sqlUnban, new { pattern = playerPattern, muteType });
|
||||||
|
|
||||||
|
await connection.CloseAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task ExpireOldMutes()
|
public async Task ExpireOldMutes()
|
||||||
@@ -143,6 +153,8 @@ namespace CS2_SimpleAdmin
|
|||||||
|
|
||||||
string sql = "UPDATE sa_mutes SET status = 'EXPIRED' WHERE status = 'ACTIVE' AND `duration` > 0 AND ends <= @CurrentTime";
|
string sql = "UPDATE sa_mutes SET status = 'EXPIRED' WHERE status = 'ACTIVE' AND `duration` > 0 AND ends <= @CurrentTime";
|
||||||
await connection.ExecuteAsync(sql, new { CurrentTime = DateTime.Now });
|
await connection.ExecuteAsync(sql, new { CurrentTime = DateTime.Now });
|
||||||
|
|
||||||
|
await connection.CloseAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task CheckMute(PlayerInfo player)
|
public async Task CheckMute(PlayerInfo player)
|
||||||
|
|||||||
Reference in New Issue
Block a user