mirror of
https://github.com/daffyyyy/CS2-SimpleAdmin.git
synced 2026-03-06 15:26:34 +00:00
1.2.8a
- Updated minimum CounterStrikeSharp version to **154** - Fixed? issue with checking ban status for player with authorization problem - Added additional checks for immunity - Added new config variable `BanType` if `1` = `SteamID + IP`, if `0` = `SteamID`
This commit is contained in:
@@ -23,11 +23,12 @@ 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 = player.IpAddress,
|
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,
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ using System.Text;
|
|||||||
|
|
||||||
namespace CS2_SimpleAdmin;
|
namespace CS2_SimpleAdmin;
|
||||||
|
|
||||||
[MinimumApiVersion(142)]
|
[MinimumApiVersion(154)]
|
||||||
public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdminConfig>
|
public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdminConfig>
|
||||||
{
|
{
|
||||||
public static IStringLocalizer? _localizer;
|
public static IStringLocalizer? _localizer;
|
||||||
@@ -37,7 +37,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";
|
public override string ModuleAuthor => "daffyy";
|
||||||
public override string ModuleVersion => "1.2.7e";
|
public override string ModuleVersion => "1.2.8a";
|
||||||
|
|
||||||
public CS2_SimpleAdminConfig Config { get; set; } = new();
|
public CS2_SimpleAdminConfig Config { get; set; } = new();
|
||||||
|
|
||||||
@@ -307,6 +307,8 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
MuteManager _muteManager = new(dbConnectionString);
|
MuteManager _muteManager = new(dbConnectionString);
|
||||||
|
|
||||||
playersToTarget.ForEach(player =>
|
playersToTarget.ForEach(player =>
|
||||||
|
{
|
||||||
|
if (caller!.CanTarget(player))
|
||||||
{
|
{
|
||||||
PlayerInfo playerInfo = new PlayerInfo
|
PlayerInfo playerInfo = new PlayerInfo
|
||||||
{
|
{
|
||||||
@@ -377,6 +379,7 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -429,6 +432,8 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
reason = command.GetArg(2);
|
reason = command.GetArg(2);
|
||||||
|
|
||||||
targets.Players.ForEach(player =>
|
targets.Players.ForEach(player =>
|
||||||
|
{
|
||||||
|
if (caller!.CanTarget(player))
|
||||||
{
|
{
|
||||||
player.Pawn.Value!.Freeze();
|
player.Pawn.Value!.Freeze();
|
||||||
|
|
||||||
@@ -448,6 +453,7 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
sb.Append(_localizer["sa_admin_kick_message", caller == null ? "Console" : caller.PlayerName, player.PlayerName, reason]);
|
sb.Append(_localizer["sa_admin_kick_message", caller == null ? "Console" : caller.PlayerName, player.PlayerName, reason]);
|
||||||
Server.PrintToChatAll(sb.ToString());
|
Server.PrintToChatAll(sb.ToString());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -476,6 +482,8 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
MuteManager _muteManager = new(dbConnectionString);
|
MuteManager _muteManager = new(dbConnectionString);
|
||||||
|
|
||||||
playersToTarget.ForEach(player =>
|
playersToTarget.ForEach(player =>
|
||||||
|
{
|
||||||
|
if (caller!.CanTarget(player))
|
||||||
{
|
{
|
||||||
PlayerInfo playerInfo = new PlayerInfo
|
PlayerInfo playerInfo = new PlayerInfo
|
||||||
{
|
{
|
||||||
@@ -546,6 +554,7 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
Server.PrintToChatAll(sb.ToString());
|
Server.PrintToChatAll(sb.ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -708,7 +717,7 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
if (TagsDetected)
|
if (TagsDetected)
|
||||||
NativeAPI.IssueServerCommand($"css_tag_unmute {player!.UserId}");
|
NativeAPI.IssueServerCommand($"css_tag_unmute {player!.UserId}");
|
||||||
|
|
||||||
pattern = player.AuthorizedSteamID!.SteamId64.ToString();
|
pattern = player!.AuthorizedSteamID!.SteamId64.ToString();
|
||||||
|
|
||||||
found = true;
|
found = true;
|
||||||
}
|
}
|
||||||
@@ -742,7 +751,7 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (player.AuthorizedSteamID != null)
|
if (player!.AuthorizedSteamID != null)
|
||||||
_ = _muteManager.UnmutePlayer(player.AuthorizedSteamID.SteamId64.ToString(), 0); // Unmute by type 0 (gag)
|
_ = _muteManager.UnmutePlayer(player.AuthorizedSteamID.SteamId64.ToString(), 0); // Unmute by type 0 (gag)
|
||||||
|
|
||||||
if (TagsDetected)
|
if (TagsDetected)
|
||||||
@@ -779,6 +788,8 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
MuteManager _muteManager = new(dbConnectionString);
|
MuteManager _muteManager = new(dbConnectionString);
|
||||||
|
|
||||||
playersToTarget.ForEach(player =>
|
playersToTarget.ForEach(player =>
|
||||||
|
{
|
||||||
|
if (caller!.CanTarget(player))
|
||||||
{
|
{
|
||||||
PlayerInfo playerInfo = new PlayerInfo
|
PlayerInfo playerInfo = new PlayerInfo
|
||||||
{
|
{
|
||||||
@@ -852,6 +863,7 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
Server.PrintToChatAll(sb.ToString());
|
Server.PrintToChatAll(sb.ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1087,6 +1099,8 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
reason = command.GetArg(3);
|
reason = command.GetArg(3);
|
||||||
|
|
||||||
playersToTarget.ForEach(player =>
|
playersToTarget.ForEach(player =>
|
||||||
|
{
|
||||||
|
if (caller!.CanTarget(player))
|
||||||
{
|
{
|
||||||
player.Pawn.Value!.Freeze();
|
player.Pawn.Value!.Freeze();
|
||||||
|
|
||||||
@@ -1133,6 +1147,7 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
Server.PrintToChatAll(sb.ToString());
|
Server.PrintToChatAll(sb.ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1400,6 +1415,8 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
List<CCSPlayerController> playersToTarget = targets!.Players.Where(player => caller!.CanTarget(player) && player != null && player.IsValid && player.PawnIsAlive).ToList();
|
List<CCSPlayerController> playersToTarget = targets!.Players.Where(player => caller!.CanTarget(player) && player != null && player.IsValid && player.PawnIsAlive).ToList();
|
||||||
|
|
||||||
playersToTarget.ForEach(player =>
|
playersToTarget.ForEach(player =>
|
||||||
|
{
|
||||||
|
if (caller!.CanTarget(player))
|
||||||
{
|
{
|
||||||
player.RemoveWeapons();
|
player.RemoveWeapons();
|
||||||
|
|
||||||
@@ -1410,6 +1427,7 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
sb.Append(_localizer["sa_admin_strip_message", caller == null ? "Console" : caller.PlayerName, player.PlayerName]);
|
sb.Append(_localizer["sa_admin_strip_message", caller == null ? "Console" : caller.PlayerName, player.PlayerName]);
|
||||||
Server.PrintToChatAll(sb.ToString());
|
Server.PrintToChatAll(sb.ToString());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1426,6 +1444,8 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
List<CCSPlayerController> playersToTarget = targets!.Players.Where(player => caller!.CanTarget(player) && player != null && player.IsValid && player.PawnIsAlive).ToList();
|
List<CCSPlayerController> playersToTarget = targets!.Players.Where(player => caller!.CanTarget(player) && player != null && player.IsValid && player.PawnIsAlive).ToList();
|
||||||
|
|
||||||
playersToTarget.ForEach(player =>
|
playersToTarget.ForEach(player =>
|
||||||
|
{
|
||||||
|
if (caller!.CanTarget(player))
|
||||||
{
|
{
|
||||||
player.SetHp(health);
|
player.SetHp(health);
|
||||||
|
|
||||||
@@ -1436,6 +1456,7 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
sb.Append(_localizer["sa_admin_hp_message", caller == null ? "Console" : caller.PlayerName, player.PlayerName]);
|
sb.Append(_localizer["sa_admin_hp_message", caller == null ? "Console" : caller.PlayerName, player.PlayerName]);
|
||||||
Server.PrintToChatAll(sb.ToString());
|
Server.PrintToChatAll(sb.ToString());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1452,6 +1473,8 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
List<CCSPlayerController> playersToTarget = targets!.Players.Where(player => caller!.CanTarget(player) && player != null && player.IsValid && player.PawnIsAlive).ToList();
|
List<CCSPlayerController> playersToTarget = targets!.Players.Where(player => caller!.CanTarget(player) && player != null && player.IsValid && player.PawnIsAlive).ToList();
|
||||||
|
|
||||||
playersToTarget.ForEach(player =>
|
playersToTarget.ForEach(player =>
|
||||||
|
{
|
||||||
|
if (caller!.CanTarget(player))
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
player.Speed = (float)speed;
|
player.Speed = (float)speed;
|
||||||
@@ -1466,6 +1489,7 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
sb.Append(_localizer["sa_admin_speed_message", caller == null ? "Console" : caller.PlayerName, player.PlayerName]);
|
sb.Append(_localizer["sa_admin_speed_message", caller == null ? "Console" : caller.PlayerName, player.PlayerName]);
|
||||||
Server.PrintToChatAll(sb.ToString());
|
Server.PrintToChatAll(sb.ToString());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1479,6 +1503,8 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
List<CCSPlayerController> playersToTarget = targets!.Players.Where(player => caller!.CanTarget(player) && player != null && player.IsValid && player.PawnIsAlive).ToList();
|
List<CCSPlayerController> playersToTarget = targets!.Players.Where(player => caller!.CanTarget(player) && player != null && player.IsValid && player.PawnIsAlive).ToList();
|
||||||
|
|
||||||
playersToTarget.ForEach(player =>
|
playersToTarget.ForEach(player =>
|
||||||
|
{
|
||||||
|
if (caller!.CanTarget(player))
|
||||||
{
|
{
|
||||||
if (player != null && player.UserId != null)
|
if (player != null && player.UserId != null)
|
||||||
{
|
{
|
||||||
@@ -1495,6 +1521,7 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
Server.PrintToChatAll(sb.ToString());
|
Server.PrintToChatAll(sb.ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1515,6 +1542,8 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
}
|
}
|
||||||
|
|
||||||
playersToTarget.ForEach(player =>
|
playersToTarget.ForEach(player =>
|
||||||
|
{
|
||||||
|
if (caller!.CanTarget(player))
|
||||||
{
|
{
|
||||||
player!.Pawn.Value!.Slap(damage);
|
player!.Pawn.Value!.Slap(damage);
|
||||||
StringBuilder sb = new(_localizer!["sa_prefix"]);
|
StringBuilder sb = new(_localizer!["sa_prefix"]);
|
||||||
@@ -1524,6 +1553,7 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
sb.Append(_localizer["sa_admin_slap_message", caller == null ? "Console" : caller.PlayerName, player.PlayerName]);
|
sb.Append(_localizer["sa_admin_slap_message", caller == null ? "Console" : caller.PlayerName, player.PlayerName]);
|
||||||
Server.PrintToChatAll(sb.ToString());
|
Server.PrintToChatAll(sb.ToString());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1634,7 +1664,7 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
foreach (var p in Utilities.GetPlayers().Where(p => p.IsValid && !p.IsBot && !p.IsHLTV))
|
foreach (var p in Utilities.GetPlayers().Where(p => p.IsValid && !p.IsBot && !p.IsHLTV))
|
||||||
{
|
{
|
||||||
if (p == null) continue;
|
if (p == null) continue;
|
||||||
ChatMenus.OpenMenu(p, voteMenu);
|
MenuManager.OpenChatMenu(p, voteMenu);
|
||||||
}
|
}
|
||||||
|
|
||||||
AddTimer(40, () =>
|
AddTimer(40, () =>
|
||||||
@@ -1796,6 +1826,8 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
List<CCSPlayerController> playersToTarget = targets!.Players.Where(player => caller!.CanTarget(player) && player != null && player.IsValid && player.PawnIsAlive).ToList();
|
List<CCSPlayerController> playersToTarget = targets!.Players.Where(player => caller!.CanTarget(player) && player != null && player.IsValid && player.PawnIsAlive).ToList();
|
||||||
|
|
||||||
playersToTarget.ForEach(player =>
|
playersToTarget.ForEach(player =>
|
||||||
|
{
|
||||||
|
if (caller!.CanTarget(player))
|
||||||
{
|
{
|
||||||
player!.Pawn.Value!.ToggleNoclip();
|
player!.Pawn.Value!.ToggleNoclip();
|
||||||
|
|
||||||
@@ -1805,6 +1837,7 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
sb.Append(_localizer["sa_admin_noclip_message", caller == null ? "Console" : caller.PlayerName, player.PlayerName]);
|
sb.Append(_localizer["sa_admin_noclip_message", caller == null ? "Console" : caller.PlayerName, player.PlayerName]);
|
||||||
Server.PrintToChatAll(sb.ToString());
|
Server.PrintToChatAll(sb.ToString());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1820,6 +1853,8 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
List<CCSPlayerController> playersToTarget = targets!.Players.Where(player => caller!.CanTarget(player) && player != null && player.IsValid && player.PawnIsAlive).ToList();
|
List<CCSPlayerController> playersToTarget = targets!.Players.Where(player => caller!.CanTarget(player) && player != null && player.IsValid && player.PawnIsAlive).ToList();
|
||||||
|
|
||||||
playersToTarget.ForEach(player =>
|
playersToTarget.ForEach(player =>
|
||||||
|
{
|
||||||
|
if (caller!.CanTarget(player))
|
||||||
{
|
{
|
||||||
player!.Pawn.Value!.Freeze();
|
player!.Pawn.Value!.Freeze();
|
||||||
|
|
||||||
@@ -1832,6 +1867,7 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
sb.Append(_localizer["sa_admin_freeze_message", caller == null ? "Console" : caller.PlayerName, player.PlayerName]);
|
sb.Append(_localizer["sa_admin_freeze_message", caller == null ? "Console" : caller.PlayerName, player.PlayerName]);
|
||||||
Server.PrintToChatAll(sb.ToString());
|
Server.PrintToChatAll(sb.ToString());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1865,6 +1901,8 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
List<CCSPlayerController> playersToTarget = targets!.Players.Where(player => caller!.CanTarget(player) && player != null && player.IsValid).ToList();
|
List<CCSPlayerController> playersToTarget = targets!.Players.Where(player => caller!.CanTarget(player) && player != null && player.IsValid).ToList();
|
||||||
|
|
||||||
playersToTarget.ForEach(player =>
|
playersToTarget.ForEach(player =>
|
||||||
|
{
|
||||||
|
if (caller!.CanTarget(player))
|
||||||
{
|
{
|
||||||
player!.Respawn();
|
player!.Respawn();
|
||||||
|
|
||||||
@@ -1874,6 +1912,7 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
sb.Append(_localizer["sa_admin_respawn_message", caller == null ? "Console" : caller.PlayerName, player.PlayerName]);
|
sb.Append(_localizer["sa_admin_respawn_message", caller == null ? "Console" : caller.PlayerName, player.PlayerName]);
|
||||||
Server.PrintToChatAll(sb.ToString());
|
Server.PrintToChatAll(sb.ToString());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,9 +9,9 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="CounterStrikeSharp.API" Version="1.0.148" />
|
<PackageReference Include="CounterStrikeSharp.API" Version="1.0.154" />
|
||||||
<PackageReference Include="Dapper" Version="*" />
|
<PackageReference Include="Dapper" Version="*" />
|
||||||
<PackageReference Include="MySqlConnector" Version="*" />
|
<PackageReference Include="MySqlConnector" Version="2.3.5" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ namespace CS2_SimpleAdmin
|
|||||||
{
|
{
|
||||||
public class CS2_SimpleAdminConfig : BasePluginConfig
|
public class CS2_SimpleAdminConfig : BasePluginConfig
|
||||||
{
|
{
|
||||||
public override int Version { get; set; } = 2;
|
public override int Version { get; set; } = 3;
|
||||||
|
|
||||||
[JsonPropertyName("DatabaseHost")]
|
[JsonPropertyName("DatabaseHost")]
|
||||||
public string DatabaseHost { get; set; } = "";
|
public string DatabaseHost { get; set; } = "";
|
||||||
@@ -23,9 +23,13 @@ namespace CS2_SimpleAdmin
|
|||||||
public string DatabaseName { get; set; } = "";
|
public string DatabaseName { get; set; } = "";
|
||||||
|
|
||||||
[JsonPropertyName("KickTime")]
|
[JsonPropertyName("KickTime")]
|
||||||
public int KickTime { get; set; } = 10;
|
public int KickTime { get; set; } = 5;
|
||||||
|
|
||||||
[JsonPropertyName("DisableDangerousCommands")]
|
[JsonPropertyName("DisableDangerousCommands")]
|
||||||
public bool DisableDangerousCommands { get; set; } = true;
|
public bool DisableDangerousCommands { get; set; } = true;
|
||||||
|
|
||||||
|
[JsonPropertyName("BanType")]
|
||||||
|
public int BanType { get; set; } = 1;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
187
Events.cs
187
Events.cs
@@ -15,8 +15,8 @@ public partial class CS2_SimpleAdmin
|
|||||||
{
|
{
|
||||||
private void registerEvents()
|
private void registerEvents()
|
||||||
{
|
{
|
||||||
RegisterListener<OnClientAuthorized>(OnClientAuthorized);
|
//RegisterListener<OnClientAuthorized>(OnClientAuthorized);
|
||||||
RegisterListener<OnClientConnected>(OnClientConnected);
|
RegisterListener<OnClientConnect>(OnClientConnect);
|
||||||
//RegisterEventHandler<EventPlayerConnectFull>(OnPlayerFullConnect);
|
//RegisterEventHandler<EventPlayerConnectFull>(OnPlayerFullConnect);
|
||||||
RegisterListener<OnClientDisconnect>(OnClientDisconnect);
|
RegisterListener<OnClientDisconnect>(OnClientDisconnect);
|
||||||
RegisterListener<OnMapStart>(OnMapStart);
|
RegisterListener<OnMapStart>(OnMapStart);
|
||||||
@@ -86,7 +86,7 @@ public partial class CS2_SimpleAdmin
|
|||||||
|
|
||||||
if (AdminManager.PlayerHasPermissions(player, "@css/chat"))
|
if (AdminManager.PlayerHasPermissions(player, "@css/chat"))
|
||||||
{
|
{
|
||||||
sb.Append(_localizer!["sa_adminchat_template_admin", player.PlayerName, info.GetArg(1).Remove(0, 1)]);
|
sb.Append(_localizer!["sa_adminchat_template_admin", player!.PlayerName, info.GetArg(1).Remove(0, 1)]);
|
||||||
foreach (var p in Utilities.GetPlayers().Where(p => p.IsValid && !p.IsBot && !p.IsHLTV && AdminManager.PlayerHasPermissions(p, "@css/chat")))
|
foreach (var p in Utilities.GetPlayers().Where(p => p.IsValid && !p.IsBot && !p.IsHLTV && AdminManager.PlayerHasPermissions(p, "@css/chat")))
|
||||||
{
|
{
|
||||||
p.PrintToChat(sb.ToString());
|
p.PrintToChat(sb.ToString());
|
||||||
@@ -94,7 +94,7 @@ public partial class CS2_SimpleAdmin
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sb.Append(_localizer!["sa_adminchat_template_player", player.PlayerName, info.GetArg(1).Remove(0, 1)]);
|
sb.Append(_localizer!["sa_adminchat_template_player", player!.PlayerName, info.GetArg(1).Remove(0, 1)]);
|
||||||
player.PrintToChat(sb.ToString());
|
player.PrintToChat(sb.ToString());
|
||||||
foreach (var p in Utilities.GetPlayers().Where(p => p.IsValid && !p.IsBot && !p.IsHLTV && AdminManager.PlayerHasPermissions(p, "@css/chat")))
|
foreach (var p in Utilities.GetPlayers().Where(p => p.IsValid && !p.IsBot && !p.IsHLTV && AdminManager.PlayerHasPermissions(p, "@css/chat")))
|
||||||
{
|
{
|
||||||
@@ -125,10 +125,179 @@ public partial class CS2_SimpleAdmin
|
|||||||
return HookResult.Continue;
|
return HookResult.Continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnClientConnected(int playerSlot)
|
private void OnClientConnect(int playerSlot, string name, string ipAddress)
|
||||||
{
|
{
|
||||||
CCSPlayerController? player = Utilities.GetPlayerFromSlot(playerSlot);
|
CCSPlayerController? player = Utilities.GetPlayerFromSlot(playerSlot);
|
||||||
|
|
||||||
|
if (player == null || !player.IsValid || player.IsBot || player.IsHLTV)
|
||||||
|
return;
|
||||||
|
|
||||||
|
ipAddress = ipAddress.Split(":")[0];
|
||||||
|
|
||||||
|
if (
|
||||||
|
ipAddress != null && bannedPlayers.Contains(ipAddress) ||
|
||||||
|
player.SteamID.ToString() != "" && bannedPlayers.Contains(player.SteamID.ToString())
|
||||||
|
)
|
||||||
|
Helper.KickPlayer((ushort)player.UserId!, "Banned");
|
||||||
|
|
||||||
|
PlayerInfo playerInfo = new PlayerInfo
|
||||||
|
{
|
||||||
|
UserId = player.UserId,
|
||||||
|
Index = (ushort)player.Index,
|
||||||
|
SteamId = player?.SteamID.ToString(),
|
||||||
|
Name = player?.PlayerName,
|
||||||
|
IpAddress = ipAddress
|
||||||
|
};
|
||||||
|
|
||||||
|
Task.Run(async () =>
|
||||||
|
{
|
||||||
|
BanManager _banManager = new(dbConnectionString);
|
||||||
|
bool isBanned = await _banManager.IsPlayerBanned(playerInfo);
|
||||||
|
|
||||||
|
MuteManager _muteManager = new(dbConnectionString);
|
||||||
|
List<dynamic> activeMutes = await _muteManager.IsPlayerMuted(playerInfo.SteamId!);
|
||||||
|
|
||||||
|
AdminSQLManager _adminManager = new(dbConnectionString);
|
||||||
|
List<(List<string>, int)> activeFlags = await _adminManager.GetAdminFlags(playerInfo.SteamId!);
|
||||||
|
|
||||||
|
Server.NextFrame(() =>
|
||||||
|
{
|
||||||
|
if (player == null || !player.IsValid) return;
|
||||||
|
if (isBanned)
|
||||||
|
{
|
||||||
|
if (playerInfo.IpAddress != null && !bannedPlayers.Contains(playerInfo.IpAddress))
|
||||||
|
bannedPlayers.Add(playerInfo.IpAddress);
|
||||||
|
if (player.SteamID.ToString() != "" && !bannedPlayers.Contains(player.SteamID.ToString()))
|
||||||
|
bannedPlayers.Add(player.SteamID.ToString());
|
||||||
|
|
||||||
|
Helper.KickPlayer((ushort)player.UserId!, "Banned");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Helper.GivePlayerFlags(player, activeFlags);
|
||||||
|
|
||||||
|
if (activeMutes.Count > 0)
|
||||||
|
{
|
||||||
|
foreach (var mute in activeMutes)
|
||||||
|
{
|
||||||
|
string muteType = mute.type;
|
||||||
|
TimeSpan duration = mute.ends - mute.created;
|
||||||
|
int durationInSeconds = (int)duration.TotalSeconds;
|
||||||
|
|
||||||
|
if (muteType == "GAG")
|
||||||
|
{
|
||||||
|
// Chat mute
|
||||||
|
if (player.UserId != null && !gaggedPlayers.Any(index => index == (ushort)player.UserId))
|
||||||
|
gaggedPlayers.Add((ushort)player.UserId);
|
||||||
|
|
||||||
|
if (TagsDetected)
|
||||||
|
NativeAPI.IssueServerCommand($"css_tag_mute {player.UserId}");
|
||||||
|
|
||||||
|
if (durationInSeconds != 0 && duration.Minutes >= 0 && duration.Minutes <= 30)
|
||||||
|
{
|
||||||
|
AddTimer(durationInSeconds, () =>
|
||||||
|
{
|
||||||
|
if (player == null || !player.IsValid || player.SteamID.ToString() == "") return;
|
||||||
|
|
||||||
|
if (player != null && player.UserId != null && gaggedPlayers.Contains((ushort)player.UserId))
|
||||||
|
{
|
||||||
|
if (gaggedPlayers.TryTake(out ushort removedItem) && removedItem != (int)player.UserId)
|
||||||
|
{
|
||||||
|
gaggedPlayers.Add(removedItem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (TagsDetected)
|
||||||
|
NativeAPI.IssueServerCommand($"css_tag_unmute {player!.UserId}");
|
||||||
|
|
||||||
|
MuteManager _muteManager = new(dbConnectionString);
|
||||||
|
_ = _muteManager.UnmutePlayer(player!.SteamID.ToString(), 0);
|
||||||
|
}, CounterStrikeSharp.API.Modules.Timers.TimerFlags.STOP_ON_MAPCHANGE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
CCSPlayerController currentPlayer = player;
|
||||||
|
|
||||||
|
if (mute.duration == 0 || durationInSeconds >= 1800) continue;
|
||||||
|
|
||||||
|
await Task.Delay(TimeSpan.FromSeconds(durationInSeconds));
|
||||||
|
|
||||||
|
if (currentPlayer != null && currentPlayer.IsValid)
|
||||||
|
{
|
||||||
|
NativeAPI.IssueServerCommand($"css_tag_unmute {currentPlayer.Index.ToString()}");
|
||||||
|
await UnmutePlayer(currentPlayer.AuthorizedSteamID.SteamId64.ToString(), 0);
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Voice mute
|
||||||
|
player.VoiceFlags = VoiceFlags.Muted;
|
||||||
|
|
||||||
|
if (durationInSeconds != 0 && duration.Minutes >= 0 && duration.Minutes <= 30)
|
||||||
|
{
|
||||||
|
AddTimer(durationInSeconds, () =>
|
||||||
|
{
|
||||||
|
if (player == null || !player.IsValid || player.SteamID.ToString() == "") return;
|
||||||
|
|
||||||
|
/*
|
||||||
|
if (mutedPlayers.Contains((ushort)player.UserId))
|
||||||
|
{
|
||||||
|
if (mutedPlayers.TryTake(out int removedItem) && removedItem != (ushort)player.UserId)
|
||||||
|
{
|
||||||
|
mutedPlayers.Add(removedItem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
player.VoiceFlags = VoiceFlags.Normal;
|
||||||
|
|
||||||
|
//MuteManager _muteManager = new(dbConnectionString);
|
||||||
|
//_ = _muteManager.UnmutePlayer(player.AuthorizedSteamID.SteamId64.ToString(), 1);
|
||||||
|
}, CounterStrikeSharp.API.Modules.Timers.TimerFlags.STOP_ON_MAPCHANGE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
if (_adminManager._adminCache != null && _adminManager._adminCache.Count > 0)
|
||||||
|
{
|
||||||
|
foreach (var flags in activeFlags)
|
||||||
|
{
|
||||||
|
if (flags == null) continue;
|
||||||
|
string flagsValue = flags.flags.ToString();
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(flagsValue))
|
||||||
|
{
|
||||||
|
string[] _flags = flagsValue.Split(",");
|
||||||
|
|
||||||
|
AddTimer(10, () =>
|
||||||
|
{
|
||||||
|
if (player == null) return;
|
||||||
|
foreach (var _flag in _flags)
|
||||||
|
{
|
||||||
|
if (_flag.StartsWith("@"))
|
||||||
|
{
|
||||||
|
AdminManager.AddPlayerPermissions(player, _flag);
|
||||||
|
}
|
||||||
|
if (_flag.StartsWith("3"))
|
||||||
|
{
|
||||||
|
AdminManager.AddPlayerToGroup(player, _flag);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
/*
|
||||||
|
CCSPlayerController? player = Utilities.GetPlayerFromSlot(playerSlot);
|
||||||
|
|
||||||
if (player == null || !player.IsValid || player.IpAddress == null || player.UserId == null || loadedPlayers.Contains((ushort)player.UserId) || player.IsBot || player.IsHLTV)
|
if (player == null || !player.IsValid || player.IpAddress == null || player.UserId == null || loadedPlayers.Contains((ushort)player.UserId) || player.IsBot || player.IsHLTV)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -161,11 +330,15 @@ public partial class CS2_SimpleAdmin
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnClientAuthorized(int playerSlot, SteamID steamID)
|
private void OnClientAuthorized(int playerSlot, SteamID steamID)
|
||||||
{
|
{
|
||||||
|
return;
|
||||||
|
#pragma warning disable CS0162
|
||||||
CCSPlayerController? player = Utilities.GetPlayerFromSlot(playerSlot);
|
CCSPlayerController? player = Utilities.GetPlayerFromSlot(playerSlot);
|
||||||
|
#pragma warning restore CS0162
|
||||||
|
|
||||||
if (player == null || !player.IsValid || player.IsBot || player.IsHLTV)
|
if (player == null || !player.IsValid || player.IsBot || player.IsHLTV)
|
||||||
return;
|
return;
|
||||||
@@ -247,7 +420,7 @@ public partial class CS2_SimpleAdmin
|
|||||||
NativeAPI.IssueServerCommand($"css_tag_unmute {player!.UserId}");
|
NativeAPI.IssueServerCommand($"css_tag_unmute {player!.UserId}");
|
||||||
|
|
||||||
MuteManager _muteManager = new(dbConnectionString);
|
MuteManager _muteManager = new(dbConnectionString);
|
||||||
_ = _muteManager.UnmutePlayer(player.AuthorizedSteamID.SteamId64.ToString(), 0);
|
_ = _muteManager.UnmutePlayer(player!.AuthorizedSteamID.SteamId64.ToString(), 0);
|
||||||
}, CounterStrikeSharp.API.Modules.Timers.TimerFlags.STOP_ON_MAPCHANGE);
|
}, CounterStrikeSharp.API.Modules.Timers.TimerFlags.STOP_ON_MAPCHANGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -359,7 +532,7 @@ public partial class CS2_SimpleAdmin
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (player.UserId != null && silentPlayers.Contains((ushort)player.UserId))
|
if (player!.UserId != null && silentPlayers.Contains((ushort)player.UserId))
|
||||||
{
|
{
|
||||||
silentPlayers.Remove((ushort)player.UserId);
|
silentPlayers.Remove((ushort)player.UserId);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user