mirror of
https://github.com/daffyyyy/CS2-SimpleAdmin.git
synced 2026-02-17 18:39:07 +00:00
Fixed who
This commit is contained in:
@@ -3,7 +3,7 @@ using MySqlConnector;
|
||||
|
||||
namespace CS2_SimpleAdmin
|
||||
{
|
||||
internal class BanManager
|
||||
public class BanManager
|
||||
{
|
||||
private readonly MySqlConnection _dbConnection;
|
||||
private readonly CS2_SimpleAdminConfig _config;
|
||||
|
||||
@@ -306,16 +306,70 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
||||
TargetResult? targets = GetTarget(command);
|
||||
if (targets == null) return;
|
||||
List<CCSPlayerController> playersToTarget = targets!.Players.Where(player => caller!.CanTarget(player) && player != null && player.IsValid && !player.IsBot && !player.IsHLTV).ToList();
|
||||
|
||||
|
||||
BanManager banManager = new(dbConnectionString, Config);
|
||||
MuteManager muteManager = new(dbConnectionString);
|
||||
|
||||
playersToTarget.ForEach(player =>
|
||||
{
|
||||
if (caller!.CanTarget(player))
|
||||
{
|
||||
ManagePlayersMenu.WhoIs(caller, player);
|
||||
Who(caller, player, banManager, muteManager);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void Who(CCSPlayerController? caller, CCSPlayerController player, BanManager banManager = null, MuteManager muteManager = null)
|
||||
{
|
||||
banManager ??= new(dbConnectionString, Config);
|
||||
muteManager ??= new(dbConnectionString);
|
||||
|
||||
PlayerInfo playerInfo = new PlayerInfo
|
||||
{
|
||||
UserId = player.UserId,
|
||||
Index = (int)player.Index,
|
||||
SteamId = player?.AuthorizedSteamID?.SteamId64.ToString(),
|
||||
Name = player?.PlayerName,
|
||||
IpAddress = player?.IpAddress?.Split(":")[0]
|
||||
};
|
||||
|
||||
Task.Run(async () =>
|
||||
{
|
||||
int totalBans = 0;
|
||||
int totalMutes = 0;
|
||||
|
||||
totalBans = await banManager.GetPlayerBans(playerInfo);
|
||||
totalMutes = await muteManager.GetPlayerMutes(playerInfo.SteamId!);
|
||||
|
||||
Server.NextFrame(() =>
|
||||
{
|
||||
Action<string> printMethod = caller == null ? Server.PrintToConsole : caller.PrintToConsole;
|
||||
printMethod($"--------- INFO ABOUT \"{playerInfo.Name}\" ---------");
|
||||
|
||||
printMethod($"• Clan: \"{player!.Clan}\" Name: \"{playerInfo.Name}\"");
|
||||
printMethod($"• UserID: \"{playerInfo.UserId}\"");
|
||||
if (playerInfo.SteamId != null)
|
||||
printMethod($"• SteamID64: \"{playerInfo.SteamId}\"");
|
||||
if (player.AuthorizedSteamID != null)
|
||||
{
|
||||
printMethod($"• SteamID2: \"{player.AuthorizedSteamID.SteamId2}\"");
|
||||
printMethod($"• Community link: \"{player.AuthorizedSteamID.ToCommunityUrl()}\"");
|
||||
}
|
||||
|
||||
if (playerInfo.IpAddress != null)
|
||||
printMethod($"• IP Address: \"{playerInfo.IpAddress}\"");
|
||||
printMethod($"• Ping: \"{player.Ping}\"");
|
||||
if (player.AuthorizedSteamID != null)
|
||||
{
|
||||
printMethod($"• Total Bans: \"{totalBans}\"");
|
||||
printMethod($"• Total Mutes: \"{totalMutes}\"");
|
||||
}
|
||||
|
||||
printMethod($"--------- END INFO ABOUT \"{player.PlayerName}\" ---------");
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
[ConsoleCommand("css_players")]
|
||||
[CommandHelper(whoCanExecute: CommandUsage.CLIENT_AND_SERVER)]
|
||||
[RequiresPermissions("@css/generic")]
|
||||
|
||||
@@ -69,53 +69,7 @@ namespace CS2_SimpleAdmin.Menus
|
||||
|
||||
private static void WhoIs(CCSPlayerController admin, CCSPlayerController player)
|
||||
{
|
||||
BanManager banManager = new(CS2_SimpleAdmin.Instance.dbConnectionString, CS2_SimpleAdmin.Instance.Config);
|
||||
MuteManager muteManager = new(CS2_SimpleAdmin.Instance.dbConnectionString);
|
||||
|
||||
PlayerInfo playerInfo = new PlayerInfo
|
||||
{
|
||||
UserId = player.UserId,
|
||||
Index = (int)player.Index,
|
||||
SteamId = player?.AuthorizedSteamID?.SteamId64.ToString(),
|
||||
Name = player?.PlayerName,
|
||||
IpAddress = player?.IpAddress?.Split(":")[0]
|
||||
};
|
||||
|
||||
Task.Run(async () =>
|
||||
{
|
||||
int totalBans = 0;
|
||||
int totalMutes = 0;
|
||||
|
||||
totalBans = await banManager.GetPlayerBans(playerInfo);
|
||||
totalMutes = await muteManager.GetPlayerMutes(playerInfo.SteamId!);
|
||||
|
||||
Server.NextFrame(() =>
|
||||
{
|
||||
Action<string> printMethod = admin == null ? Server.PrintToConsole : admin.PrintToConsole;
|
||||
printMethod($"--------- INFO ABOUT \"{playerInfo.Name}\" ---------");
|
||||
|
||||
printMethod($"• Clan: \"{player!.Clan}\" Name: \"{playerInfo.Name}\"");
|
||||
printMethod($"• UserID: \"{playerInfo.UserId}\"");
|
||||
if (playerInfo.SteamId != null)
|
||||
printMethod($"• SteamID64: \"{playerInfo.SteamId}\"");
|
||||
if (player.AuthorizedSteamID != null)
|
||||
{
|
||||
printMethod($"• SteamID2: \"{player.AuthorizedSteamID.SteamId2}\"");
|
||||
printMethod($"• Community link: \"{player.AuthorizedSteamID.ToCommunityUrl()}\"");
|
||||
}
|
||||
|
||||
if (playerInfo.IpAddress != null)
|
||||
printMethod($"• IP Address: \"{playerInfo.IpAddress}\"");
|
||||
printMethod($"• Ping: \"{player.Ping}\"");
|
||||
if (player.AuthorizedSteamID != null)
|
||||
{
|
||||
printMethod($"• Total Bans: \"{totalBans}\"");
|
||||
printMethod($"• Total Mutes: \"{totalMutes}\"");
|
||||
}
|
||||
|
||||
printMethod($"--------- END INFO ABOUT \"{player.PlayerName}\" ---------");
|
||||
});
|
||||
});
|
||||
CS2_SimpleAdmin.Instance.Who(admin, player);
|
||||
}
|
||||
|
||||
private static void SlapMenu(CCSPlayerController admin, CCSPlayerController player)
|
||||
|
||||
Reference in New Issue
Block a user