mirror of
https://github.com/daffyyyy/CS2-SimpleAdmin.git
synced 2026-02-18 10:43:23 +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();
|
||||||
|
|
||||||
@@ -308,75 +308,78 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
|
|
||||||
playersToTarget.ForEach(player =>
|
playersToTarget.ForEach(player =>
|
||||||
{
|
{
|
||||||
PlayerInfo playerInfo = new PlayerInfo
|
if (caller!.CanTarget(player))
|
||||||
{
|
{
|
||||||
UserId = player.UserId,
|
PlayerInfo playerInfo = new PlayerInfo
|
||||||
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(() =>
|
|
||||||
{
|
{
|
||||||
if (caller != null)
|
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(() =>
|
||||||
{
|
{
|
||||||
caller!.PrintToConsole($"--------- INFO ABOUT \"{playerInfo.Name}\" ---------");
|
if (caller != null)
|
||||||
|
|
||||||
caller!.PrintToConsole($"• Clan: \"{player!.Clan}\" Name: \"{playerInfo.Name}\"");
|
|
||||||
caller!.PrintToConsole($"• UserID: \"{playerInfo.UserId}\"");
|
|
||||||
if (playerInfo.SteamId != null)
|
|
||||||
caller!.PrintToConsole($"• SteamID64: \"{playerInfo.SteamId}\"");
|
|
||||||
if (player.AuthorizedSteamID != null)
|
|
||||||
{
|
{
|
||||||
caller!.PrintToConsole($"• SteamID2: \"{player.AuthorizedSteamID.SteamId2}\"");
|
caller!.PrintToConsole($"--------- INFO ABOUT \"{playerInfo.Name}\" ---------");
|
||||||
caller!.PrintToConsole($"• Community link: \"{player.AuthorizedSteamID.ToCommunityUrl()}\"");
|
|
||||||
}
|
|
||||||
if (playerInfo.IpAddress != null)
|
|
||||||
caller!.PrintToConsole($"• IP Address: \"{playerInfo.IpAddress}\"");
|
|
||||||
caller!.PrintToConsole($"• Ping: \"{player.Ping}\"");
|
|
||||||
if (player.AuthorizedSteamID != null)
|
|
||||||
{
|
|
||||||
caller!.PrintToConsole($"• Total Bans: \"{totalBans}\"");
|
|
||||||
caller!.PrintToConsole($"• Total Mutes: \"{totalMutes}\"");
|
|
||||||
}
|
|
||||||
|
|
||||||
caller!.PrintToConsole($"--------- END INFO ABOUT \"{player.PlayerName}\" ---------");
|
caller!.PrintToConsole($"• Clan: \"{player!.Clan}\" Name: \"{playerInfo.Name}\"");
|
||||||
}
|
caller!.PrintToConsole($"• UserID: \"{playerInfo.UserId}\"");
|
||||||
else
|
if (playerInfo.SteamId != null)
|
||||||
{
|
caller!.PrintToConsole($"• SteamID64: \"{playerInfo.SteamId}\"");
|
||||||
Server.PrintToConsole($"--------- INFO ABOUT \"{playerInfo.Name}\" ---------");
|
if (player.AuthorizedSteamID != null)
|
||||||
|
{
|
||||||
|
caller!.PrintToConsole($"• SteamID2: \"{player.AuthorizedSteamID.SteamId2}\"");
|
||||||
|
caller!.PrintToConsole($"• Community link: \"{player.AuthorizedSteamID.ToCommunityUrl()}\"");
|
||||||
|
}
|
||||||
|
if (playerInfo.IpAddress != null)
|
||||||
|
caller!.PrintToConsole($"• IP Address: \"{playerInfo.IpAddress}\"");
|
||||||
|
caller!.PrintToConsole($"• Ping: \"{player.Ping}\"");
|
||||||
|
if (player.AuthorizedSteamID != null)
|
||||||
|
{
|
||||||
|
caller!.PrintToConsole($"• Total Bans: \"{totalBans}\"");
|
||||||
|
caller!.PrintToConsole($"• Total Mutes: \"{totalMutes}\"");
|
||||||
|
}
|
||||||
|
|
||||||
Server.PrintToConsole($"• Clan: \"{player!.Clan}\" Name: \"{playerInfo.Name}\"");
|
caller!.PrintToConsole($"--------- END INFO ABOUT \"{player.PlayerName}\" ---------");
|
||||||
Server.PrintToConsole($"• UserID: \"{playerInfo.UserId}\"");
|
|
||||||
if (playerInfo.SteamId != null)
|
|
||||||
Server.PrintToConsole($"• SteamID64: \"{playerInfo.SteamId}\"");
|
|
||||||
if (player.AuthorizedSteamID != null)
|
|
||||||
{
|
|
||||||
Server.PrintToConsole($"• SteamID2: \"{player.AuthorizedSteamID.SteamId2}\"");
|
|
||||||
Server.PrintToConsole($"• Community link: \"{player.AuthorizedSteamID.ToCommunityUrl()}\"");
|
|
||||||
}
|
}
|
||||||
if (playerInfo.IpAddress != null)
|
else
|
||||||
Server.PrintToConsole($"• IP Address: \"{playerInfo.IpAddress}\"");
|
|
||||||
Server.PrintToConsole($"• Ping: \"{player.Ping}\"");
|
|
||||||
if (player.AuthorizedSteamID != null)
|
|
||||||
{
|
{
|
||||||
Server.PrintToConsole($"• Total Bans: \"{totalBans}\"");
|
Server.PrintToConsole($"--------- INFO ABOUT \"{playerInfo.Name}\" ---------");
|
||||||
Server.PrintToConsole($"• Total Mutes: \"{totalMutes}\"");
|
|
||||||
}
|
|
||||||
|
|
||||||
Server.PrintToConsole($"--------- END INFO ABOUT \"{player.PlayerName}\" ---------");
|
Server.PrintToConsole($"• Clan: \"{player!.Clan}\" Name: \"{playerInfo.Name}\"");
|
||||||
}
|
Server.PrintToConsole($"• UserID: \"{playerInfo.UserId}\"");
|
||||||
|
if (playerInfo.SteamId != null)
|
||||||
|
Server.PrintToConsole($"• SteamID64: \"{playerInfo.SteamId}\"");
|
||||||
|
if (player.AuthorizedSteamID != null)
|
||||||
|
{
|
||||||
|
Server.PrintToConsole($"• SteamID2: \"{player.AuthorizedSteamID.SteamId2}\"");
|
||||||
|
Server.PrintToConsole($"• Community link: \"{player.AuthorizedSteamID.ToCommunityUrl()}\"");
|
||||||
|
}
|
||||||
|
if (playerInfo.IpAddress != null)
|
||||||
|
Server.PrintToConsole($"• IP Address: \"{playerInfo.IpAddress}\"");
|
||||||
|
Server.PrintToConsole($"• Ping: \"{player.Ping}\"");
|
||||||
|
if (player.AuthorizedSteamID != null)
|
||||||
|
{
|
||||||
|
Server.PrintToConsole($"• Total Bans: \"{totalBans}\"");
|
||||||
|
Server.PrintToConsole($"• Total Mutes: \"{totalMutes}\"");
|
||||||
|
}
|
||||||
|
|
||||||
|
Server.PrintToConsole($"--------- END INFO ABOUT \"{player.PlayerName}\" ---------");
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -430,23 +433,26 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
|
|
||||||
targets.Players.ForEach(player =>
|
targets.Players.ForEach(player =>
|
||||||
{
|
{
|
||||||
player.Pawn.Value!.Freeze();
|
if (caller!.CanTarget(player))
|
||||||
|
{
|
||||||
|
player.Pawn.Value!.Freeze();
|
||||||
|
|
||||||
if (command.ArgCount >= 2)
|
if (command.ArgCount >= 2)
|
||||||
{
|
{
|
||||||
player.PrintToCenter(_localizer!["sa_player_kick_message", reason, caller == null ? "Console" : caller.PlayerName]);
|
player.PrintToCenter(_localizer!["sa_player_kick_message", reason, caller == null ? "Console" : caller.PlayerName]);
|
||||||
AddTimer(Config.KickTime, () => Helper.KickPlayer((ushort)player.UserId!, reason));
|
AddTimer(Config.KickTime, () => Helper.KickPlayer((ushort)player.UserId!, reason));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
AddTimer(Config.KickTime, () => Helper.KickPlayer((ushort)player.UserId!));
|
AddTimer(Config.KickTime, () => Helper.KickPlayer((ushort)player.UserId!));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (caller == null || caller != null && caller.UserId != null && !silentPlayers.Contains((ushort)caller.UserId))
|
if (caller == null || caller != null && caller.UserId != null && !silentPlayers.Contains((ushort)caller.UserId))
|
||||||
{
|
{
|
||||||
StringBuilder sb = new(_localizer!["sa_prefix"]);
|
StringBuilder sb = new(_localizer!["sa_prefix"]);
|
||||||
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());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -477,73 +483,76 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
|
|
||||||
playersToTarget.ForEach(player =>
|
playersToTarget.ForEach(player =>
|
||||||
{
|
{
|
||||||
PlayerInfo playerInfo = new PlayerInfo
|
if (caller!.CanTarget(player))
|
||||||
{
|
{
|
||||||
SteamId = player?.AuthorizedSteamID?.SteamId64.ToString(),
|
PlayerInfo playerInfo = new PlayerInfo
|
||||||
Name = player?.PlayerName,
|
|
||||||
IpAddress = player?.IpAddress?.Split(":")[0]
|
|
||||||
};
|
|
||||||
|
|
||||||
PlayerInfo adminInfo = new PlayerInfo
|
|
||||||
{
|
|
||||||
SteamId = caller?.AuthorizedSteamID?.SteamId64.ToString(),
|
|
||||||
Name = caller?.PlayerName,
|
|
||||||
IpAddress = caller?.IpAddress?.Split(":")[0]
|
|
||||||
};
|
|
||||||
|
|
||||||
Task.Run(async () =>
|
|
||||||
{
|
|
||||||
await _muteManager.MutePlayer(playerInfo, adminInfo, reason, time);
|
|
||||||
});
|
|
||||||
|
|
||||||
if (TagsDetected)
|
|
||||||
NativeAPI.IssueServerCommand($"css_tag_mute {player!.UserId}");
|
|
||||||
|
|
||||||
if (player != null && player.UserId != null && gaggedPlayers.Contains((ushort)player.UserId))
|
|
||||||
gaggedPlayers.Add((ushort)player.UserId);
|
|
||||||
|
|
||||||
if (time > 0 && time <= 30)
|
|
||||||
{
|
|
||||||
AddTimer(time * 60, () =>
|
|
||||||
{
|
{
|
||||||
if (player == null || !player.IsValid || player.AuthorizedSteamID == null) return;
|
SteamId = player?.AuthorizedSteamID?.SteamId64.ToString(),
|
||||||
|
Name = player?.PlayerName,
|
||||||
|
IpAddress = player?.IpAddress?.Split(":")[0]
|
||||||
|
};
|
||||||
|
|
||||||
if (TagsDetected)
|
PlayerInfo adminInfo = new PlayerInfo
|
||||||
NativeAPI.IssueServerCommand($"css_tag_unmute {player.UserId}");
|
{
|
||||||
|
SteamId = caller?.AuthorizedSteamID?.SteamId64.ToString(),
|
||||||
|
Name = caller?.PlayerName,
|
||||||
|
IpAddress = caller?.IpAddress?.Split(":")[0]
|
||||||
|
};
|
||||||
|
|
||||||
if (player != null && player.UserId != null && gaggedPlayers.Contains((ushort)player.UserId))
|
Task.Run(async () =>
|
||||||
|
{
|
||||||
|
await _muteManager.MutePlayer(playerInfo, adminInfo, reason, time);
|
||||||
|
});
|
||||||
|
|
||||||
|
if (TagsDetected)
|
||||||
|
NativeAPI.IssueServerCommand($"css_tag_mute {player!.UserId}");
|
||||||
|
|
||||||
|
if (player != null && player.UserId != null && gaggedPlayers.Contains((ushort)player.UserId))
|
||||||
|
gaggedPlayers.Add((ushort)player.UserId);
|
||||||
|
|
||||||
|
if (time > 0 && time <= 30)
|
||||||
|
{
|
||||||
|
AddTimer(time * 60, () =>
|
||||||
{
|
{
|
||||||
if (gaggedPlayers.TryTake(out ushort removedItem) && removedItem != (ushort)player.UserId)
|
if (player == null || !player.IsValid || player.AuthorizedSteamID == null) return;
|
||||||
|
|
||||||
|
if (TagsDetected)
|
||||||
|
NativeAPI.IssueServerCommand($"css_tag_unmute {player.UserId}");
|
||||||
|
|
||||||
|
if (player != null && player.UserId != null && gaggedPlayers.Contains((ushort)player.UserId))
|
||||||
{
|
{
|
||||||
gaggedPlayers.Add(removedItem);
|
if (gaggedPlayers.TryTake(out ushort removedItem) && removedItem != (ushort)player.UserId)
|
||||||
|
{
|
||||||
|
gaggedPlayers.Add(removedItem);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
//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);
|
||||||
}
|
|
||||||
|
|
||||||
if (time == 0)
|
|
||||||
{
|
|
||||||
player!.PrintToCenter(_localizer!["sa_player_gag_message_perm", reason, caller == null ? "Console" : caller.PlayerName]);
|
|
||||||
|
|
||||||
if (caller == null || caller != null && caller.UserId != null && !silentPlayers.Contains((ushort)caller.UserId))
|
|
||||||
{
|
|
||||||
StringBuilder sb = new(_localizer!["sa_prefix"]);
|
|
||||||
sb.Append(_localizer["sa_admin_gag_message_perm", caller == null ? "Console" : caller.PlayerName, player.PlayerName, reason]);
|
|
||||||
Server.PrintToChatAll(sb.ToString());
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
player!.PrintToCenter(_localizer!["sa_player_gag_message_time", reason, time, caller == null ? "Console" : caller.PlayerName]);
|
|
||||||
|
|
||||||
if (caller == null || caller != null && caller != null && caller.UserId != null && !silentPlayers.Contains((ushort)caller.UserId))
|
if (time == 0)
|
||||||
{
|
{
|
||||||
StringBuilder sb = new(_localizer!["sa_prefix"]);
|
player!.PrintToCenter(_localizer!["sa_player_gag_message_perm", reason, caller == null ? "Console" : caller.PlayerName]);
|
||||||
sb.Append(_localizer["sa_admin_gag_message_time", caller == null ? "Console" : caller.PlayerName, player.PlayerName, reason, time]);
|
|
||||||
Server.PrintToChatAll(sb.ToString());
|
if (caller == null || caller != null && caller.UserId != null && !silentPlayers.Contains((ushort)caller.UserId))
|
||||||
|
{
|
||||||
|
StringBuilder sb = new(_localizer!["sa_prefix"]);
|
||||||
|
sb.Append(_localizer["sa_admin_gag_message_perm", caller == null ? "Console" : caller.PlayerName, player.PlayerName, reason]);
|
||||||
|
Server.PrintToChatAll(sb.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
player!.PrintToCenter(_localizer!["sa_player_gag_message_time", reason, time, caller == null ? "Console" : caller.PlayerName]);
|
||||||
|
|
||||||
|
if (caller == null || caller != null && caller != null && caller.UserId != null && !silentPlayers.Contains((ushort)caller.UserId))
|
||||||
|
{
|
||||||
|
StringBuilder sb = new(_localizer!["sa_prefix"]);
|
||||||
|
sb.Append(_localizer["sa_admin_gag_message_time", caller == null ? "Console" : caller.PlayerName, player.PlayerName, reason, time]);
|
||||||
|
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)
|
||||||
@@ -780,76 +789,79 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
|
|
||||||
playersToTarget.ForEach(player =>
|
playersToTarget.ForEach(player =>
|
||||||
{
|
{
|
||||||
PlayerInfo playerInfo = new PlayerInfo
|
if (caller!.CanTarget(player))
|
||||||
{
|
{
|
||||||
SteamId = player?.AuthorizedSteamID?.SteamId64.ToString(),
|
PlayerInfo playerInfo = new PlayerInfo
|
||||||
Name = player?.PlayerName,
|
|
||||||
IpAddress = player?.IpAddress?.Split(":")[0]
|
|
||||||
};
|
|
||||||
|
|
||||||
PlayerInfo adminInfo = new PlayerInfo
|
|
||||||
{
|
|
||||||
SteamId = caller?.AuthorizedSteamID?.SteamId64.ToString(),
|
|
||||||
Name = caller?.PlayerName,
|
|
||||||
IpAddress = caller?.IpAddress?.Split(":")[0]
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
if (!mutedPlayers.Contains((ushort)player.UserId))
|
|
||||||
mutedPlayers.Add((ushort)player.UserId);
|
|
||||||
*/
|
|
||||||
|
|
||||||
player!.VoiceFlags = VoiceFlags.Muted;
|
|
||||||
|
|
||||||
Task.Run(async () =>
|
|
||||||
{
|
|
||||||
await _muteManager.MutePlayer(playerInfo, adminInfo, reason, time, 1);
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
if (time > 0 && time <= 30)
|
|
||||||
{
|
|
||||||
AddTimer(time * 60, () =>
|
|
||||||
{
|
{
|
||||||
if (player == null || !player.IsValid || player.AuthorizedSteamID == null) return;
|
SteamId = player?.AuthorizedSteamID?.SteamId64.ToString(),
|
||||||
|
Name = player?.PlayerName,
|
||||||
|
IpAddress = player?.IpAddress?.Split(":")[0]
|
||||||
|
};
|
||||||
|
|
||||||
//MuteManager _muteManager = new(dbConnectionString);
|
PlayerInfo adminInfo = new PlayerInfo
|
||||||
//_ = _muteManager.UnmutePlayer(player.AuthorizedSteamID.SteamId64.ToString(), 1);
|
{
|
||||||
|
SteamId = caller?.AuthorizedSteamID?.SteamId64.ToString(),
|
||||||
|
Name = caller?.PlayerName,
|
||||||
|
IpAddress = caller?.IpAddress?.Split(":")[0]
|
||||||
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
if (mutedPlayers.Contains((int)player.Index))
|
if (!mutedPlayers.Contains((ushort)player.UserId))
|
||||||
|
mutedPlayers.Add((ushort)player.UserId);
|
||||||
|
*/
|
||||||
|
|
||||||
|
player!.VoiceFlags = VoiceFlags.Muted;
|
||||||
|
|
||||||
|
Task.Run(async () =>
|
||||||
|
{
|
||||||
|
await _muteManager.MutePlayer(playerInfo, adminInfo, reason, time, 1);
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
if (time > 0 && time <= 30)
|
||||||
|
{
|
||||||
|
AddTimer(time * 60, () =>
|
||||||
{
|
{
|
||||||
if (mutedPlayers.TryTake(out int removedItem) && removedItem != (int)player.Index)
|
if (player == null || !player.IsValid || player.AuthorizedSteamID == null) return;
|
||||||
|
|
||||||
|
//MuteManager _muteManager = new(dbConnectionString);
|
||||||
|
//_ = _muteManager.UnmutePlayer(player.AuthorizedSteamID.SteamId64.ToString(), 1);
|
||||||
|
|
||||||
|
/*
|
||||||
|
if (mutedPlayers.Contains((int)player.Index))
|
||||||
{
|
{
|
||||||
mutedPlayers.Add(removedItem);
|
if (mutedPlayers.TryTake(out int removedItem) && removedItem != (int)player.Index)
|
||||||
|
{
|
||||||
|
mutedPlayers.Add(removedItem);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
*/
|
||||||
*/
|
|
||||||
|
|
||||||
player.VoiceFlags = VoiceFlags.Normal;
|
player.VoiceFlags = VoiceFlags.Normal;
|
||||||
}, CounterStrikeSharp.API.Modules.Timers.TimerFlags.STOP_ON_MAPCHANGE);
|
}, CounterStrikeSharp.API.Modules.Timers.TimerFlags.STOP_ON_MAPCHANGE);
|
||||||
}
|
|
||||||
|
|
||||||
if (time == 0)
|
|
||||||
{
|
|
||||||
player!.PrintToCenter(_localizer!["sa_player_mute_message_perm", reason, caller == null ? "Console" : caller.PlayerName]);
|
|
||||||
|
|
||||||
if (caller == null || caller != null && caller.UserId != null && !silentPlayers.Contains((ushort)caller.UserId))
|
|
||||||
{
|
|
||||||
StringBuilder sb = new(_localizer!["sa_prefix"]);
|
|
||||||
sb.Append(_localizer["sa_admin_mute_message_perm", caller == null ? "Console" : caller.PlayerName, player.PlayerName, reason]);
|
|
||||||
Server.PrintToChatAll(sb.ToString());
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
player!.PrintToCenter(_localizer!["sa_player_mute_message_time", reason, time, caller == null ? "Console" : caller.PlayerName]);
|
|
||||||
|
|
||||||
if (caller == null || caller != null && caller.UserId != null && !silentPlayers.Contains((ushort)caller.UserId))
|
if (time == 0)
|
||||||
{
|
{
|
||||||
StringBuilder sb = new(_localizer!["sa_prefix"]);
|
player!.PrintToCenter(_localizer!["sa_player_mute_message_perm", reason, caller == null ? "Console" : caller.PlayerName]);
|
||||||
sb.Append(_localizer["sa_admin_mute_message_time", caller == null ? "Console" : caller.PlayerName, player.PlayerName, reason, time]);
|
|
||||||
Server.PrintToChatAll(sb.ToString());
|
if (caller == null || caller != null && caller.UserId != null && !silentPlayers.Contains((ushort)caller.UserId))
|
||||||
|
{
|
||||||
|
StringBuilder sb = new(_localizer!["sa_prefix"]);
|
||||||
|
sb.Append(_localizer["sa_admin_mute_message_perm", caller == null ? "Console" : caller.PlayerName, player.PlayerName, reason]);
|
||||||
|
Server.PrintToChatAll(sb.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
player!.PrintToCenter(_localizer!["sa_player_mute_message_time", reason, time, caller == null ? "Console" : caller.PlayerName]);
|
||||||
|
|
||||||
|
if (caller == null || caller != null && caller.UserId != null && !silentPlayers.Contains((ushort)caller.UserId))
|
||||||
|
{
|
||||||
|
StringBuilder sb = new(_localizer!["sa_prefix"]);
|
||||||
|
sb.Append(_localizer["sa_admin_mute_message_time", caller == null ? "Console" : caller.PlayerName, player.PlayerName, reason, time]);
|
||||||
|
Server.PrintToChatAll(sb.ToString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -1088,49 +1100,52 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
|
|
||||||
playersToTarget.ForEach(player =>
|
playersToTarget.ForEach(player =>
|
||||||
{
|
{
|
||||||
player.Pawn.Value!.Freeze();
|
if (caller!.CanTarget(player))
|
||||||
|
|
||||||
PlayerInfo playerInfo = new PlayerInfo
|
|
||||||
{
|
{
|
||||||
SteamId = player?.AuthorizedSteamID?.SteamId64.ToString(),
|
player.Pawn.Value!.Freeze();
|
||||||
Name = player?.PlayerName,
|
|
||||||
IpAddress = player?.IpAddress?.Split(":")[0]
|
|
||||||
};
|
|
||||||
|
|
||||||
PlayerInfo adminInfo = new PlayerInfo
|
PlayerInfo playerInfo = new PlayerInfo
|
||||||
{
|
|
||||||
SteamId = caller?.AuthorizedSteamID?.SteamId64.ToString(),
|
|
||||||
Name = caller?.PlayerName,
|
|
||||||
IpAddress = caller?.IpAddress?.Split(":")[0]
|
|
||||||
};
|
|
||||||
|
|
||||||
Task.Run(async () =>
|
|
||||||
{
|
|
||||||
await _banManager.BanPlayer(playerInfo, adminInfo, reason, time);
|
|
||||||
});
|
|
||||||
|
|
||||||
AddTimer(Config.KickTime, () => Helper.KickPlayer((ushort)player!.UserId!));
|
|
||||||
|
|
||||||
if (time == 0)
|
|
||||||
{
|
|
||||||
player!.PrintToCenter(_localizer!["sa_player_ban_message_perm", reason, caller == null ? "Console" : caller.PlayerName]);
|
|
||||||
|
|
||||||
if (caller == null || caller != null && caller.UserId != null && !silentPlayers.Contains((ushort)caller.UserId))
|
|
||||||
{
|
{
|
||||||
StringBuilder sb = new(_localizer!["sa_prefix"]);
|
SteamId = player?.AuthorizedSteamID?.SteamId64.ToString(),
|
||||||
sb.Append(_localizer["sa_admin_ban_message_perm", caller == null ? "Console" : caller.PlayerName, player.PlayerName, reason]);
|
Name = player?.PlayerName,
|
||||||
Server.PrintToChatAll(sb.ToString());
|
IpAddress = player?.IpAddress?.Split(":")[0]
|
||||||
|
};
|
||||||
|
|
||||||
|
PlayerInfo adminInfo = new PlayerInfo
|
||||||
|
{
|
||||||
|
SteamId = caller?.AuthorizedSteamID?.SteamId64.ToString(),
|
||||||
|
Name = caller?.PlayerName,
|
||||||
|
IpAddress = caller?.IpAddress?.Split(":")[0]
|
||||||
|
};
|
||||||
|
|
||||||
|
Task.Run(async () =>
|
||||||
|
{
|
||||||
|
await _banManager.BanPlayer(playerInfo, adminInfo, reason, time);
|
||||||
|
});
|
||||||
|
|
||||||
|
AddTimer(Config.KickTime, () => Helper.KickPlayer((ushort)player!.UserId!));
|
||||||
|
|
||||||
|
if (time == 0)
|
||||||
|
{
|
||||||
|
player!.PrintToCenter(_localizer!["sa_player_ban_message_perm", reason, caller == null ? "Console" : caller.PlayerName]);
|
||||||
|
|
||||||
|
if (caller == null || caller != null && caller.UserId != null && !silentPlayers.Contains((ushort)caller.UserId))
|
||||||
|
{
|
||||||
|
StringBuilder sb = new(_localizer!["sa_prefix"]);
|
||||||
|
sb.Append(_localizer["sa_admin_ban_message_perm", caller == null ? "Console" : caller.PlayerName, player.PlayerName, reason]);
|
||||||
|
Server.PrintToChatAll(sb.ToString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
else
|
||||||
else
|
|
||||||
{
|
|
||||||
player!.PrintToCenter(_localizer!["sa_player_ban_message_time", reason, time, caller == null ? "Console" : caller.PlayerName]);
|
|
||||||
|
|
||||||
if (caller == null || caller != null && caller.UserId != null && !silentPlayers.Contains((ushort)caller.UserId))
|
|
||||||
{
|
{
|
||||||
StringBuilder sb = new(_localizer!["sa_prefix"]);
|
player!.PrintToCenter(_localizer!["sa_player_ban_message_time", reason, time, caller == null ? "Console" : caller.PlayerName]);
|
||||||
sb.Append(_localizer["sa_admin_ban_message_time", caller == null ? "Console" : caller.PlayerName, player.PlayerName, reason, time]);
|
|
||||||
Server.PrintToChatAll(sb.ToString());
|
if (caller == null || caller != null && caller.UserId != null && !silentPlayers.Contains((ushort)caller.UserId))
|
||||||
|
{
|
||||||
|
StringBuilder sb = new(_localizer!["sa_prefix"]);
|
||||||
|
sb.Append(_localizer["sa_admin_ban_message_time", caller == null ? "Console" : caller.PlayerName, player.PlayerName, reason, time]);
|
||||||
|
Server.PrintToChatAll(sb.ToString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -1401,14 +1416,17 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
|
|
||||||
playersToTarget.ForEach(player =>
|
playersToTarget.ForEach(player =>
|
||||||
{
|
{
|
||||||
player.RemoveWeapons();
|
if (caller!.CanTarget(player))
|
||||||
|
|
||||||
StringBuilder sb = new(_localizer!["sa_prefix"]);
|
|
||||||
|
|
||||||
if (caller == null || caller != null && caller.UserId != null && !silentPlayers.Contains((ushort)caller.UserId))
|
|
||||||
{
|
{
|
||||||
sb.Append(_localizer["sa_admin_strip_message", caller == null ? "Console" : caller.PlayerName, player.PlayerName]);
|
player.RemoveWeapons();
|
||||||
Server.PrintToChatAll(sb.ToString());
|
|
||||||
|
StringBuilder sb = new(_localizer!["sa_prefix"]);
|
||||||
|
|
||||||
|
if (caller == null || caller != null && caller.UserId != null && !silentPlayers.Contains((ushort)caller.UserId))
|
||||||
|
{
|
||||||
|
sb.Append(_localizer["sa_admin_strip_message", caller == null ? "Console" : caller.PlayerName, player.PlayerName]);
|
||||||
|
Server.PrintToChatAll(sb.ToString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -1427,14 +1445,17 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
|
|
||||||
playersToTarget.ForEach(player =>
|
playersToTarget.ForEach(player =>
|
||||||
{
|
{
|
||||||
player.SetHp(health);
|
if (caller!.CanTarget(player))
|
||||||
|
|
||||||
StringBuilder sb = new(_localizer!["sa_prefix"]);
|
|
||||||
|
|
||||||
if (caller == null || caller != null && caller.UserId != null && !silentPlayers.Contains((ushort)caller.UserId))
|
|
||||||
{
|
{
|
||||||
sb.Append(_localizer["sa_admin_hp_message", caller == null ? "Console" : caller.PlayerName, player.PlayerName]);
|
player.SetHp(health);
|
||||||
Server.PrintToChatAll(sb.ToString());
|
|
||||||
|
StringBuilder sb = new(_localizer!["sa_prefix"]);
|
||||||
|
|
||||||
|
if (caller == null || caller != null && caller.UserId != null && !silentPlayers.Contains((ushort)caller.UserId))
|
||||||
|
{
|
||||||
|
sb.Append(_localizer["sa_admin_hp_message", caller == null ? "Console" : caller.PlayerName, player.PlayerName]);
|
||||||
|
Server.PrintToChatAll(sb.ToString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -1453,18 +1474,21 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
|
|
||||||
playersToTarget.ForEach(player =>
|
playersToTarget.ForEach(player =>
|
||||||
{
|
{
|
||||||
/*
|
if (caller!.CanTarget(player))
|
||||||
player.Speed = (float)speed;
|
|
||||||
player.PlayerPawn.Value!.Speed = (float)speed;
|
|
||||||
*/
|
|
||||||
player.SetSpeed((float)speed);
|
|
||||||
|
|
||||||
StringBuilder sb = new(_localizer!["sa_prefix"]);
|
|
||||||
|
|
||||||
if (caller == null || caller != null && caller.UserId != null && !silentPlayers.Contains((ushort)caller.UserId))
|
|
||||||
{
|
{
|
||||||
sb.Append(_localizer["sa_admin_speed_message", caller == null ? "Console" : caller.PlayerName, player.PlayerName]);
|
/*
|
||||||
Server.PrintToChatAll(sb.ToString());
|
player.Speed = (float)speed;
|
||||||
|
player.PlayerPawn.Value!.Speed = (float)speed;
|
||||||
|
*/
|
||||||
|
player.SetSpeed((float)speed);
|
||||||
|
|
||||||
|
StringBuilder sb = new(_localizer!["sa_prefix"]);
|
||||||
|
|
||||||
|
if (caller == null || caller != null && caller.UserId != null && !silentPlayers.Contains((ushort)caller.UserId))
|
||||||
|
{
|
||||||
|
sb.Append(_localizer["sa_admin_speed_message", caller == null ? "Console" : caller.PlayerName, player.PlayerName]);
|
||||||
|
Server.PrintToChatAll(sb.ToString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -1480,19 +1504,22 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
|
|
||||||
playersToTarget.ForEach(player =>
|
playersToTarget.ForEach(player =>
|
||||||
{
|
{
|
||||||
if (player != null && player.UserId != null)
|
if (caller!.CanTarget(player))
|
||||||
{
|
{
|
||||||
if (!godPlayers.Contains((ushort)player.UserId))
|
if (player != null && player.UserId != null)
|
||||||
godPlayers.Add((ushort)player.UserId);
|
|
||||||
else
|
|
||||||
godPlayers.Remove((ushort)player.UserId);
|
|
||||||
|
|
||||||
StringBuilder sb = new(_localizer!["sa_prefix"]);
|
|
||||||
|
|
||||||
if (caller == null || caller != null && caller.UserId != null && !silentPlayers.Contains((ushort)caller!.UserId))
|
|
||||||
{
|
{
|
||||||
sb.Append(_localizer["sa_admin_god_message", caller == null ? "Console" : caller.PlayerName, player.PlayerName]);
|
if (!godPlayers.Contains((ushort)player.UserId))
|
||||||
Server.PrintToChatAll(sb.ToString());
|
godPlayers.Add((ushort)player.UserId);
|
||||||
|
else
|
||||||
|
godPlayers.Remove((ushort)player.UserId);
|
||||||
|
|
||||||
|
StringBuilder sb = new(_localizer!["sa_prefix"]);
|
||||||
|
|
||||||
|
if (caller == null || caller != null && caller.UserId != null && !silentPlayers.Contains((ushort)caller!.UserId))
|
||||||
|
{
|
||||||
|
sb.Append(_localizer["sa_admin_god_message", caller == null ? "Console" : caller.PlayerName, player.PlayerName]);
|
||||||
|
Server.PrintToChatAll(sb.ToString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -1516,13 +1543,16 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
|
|
||||||
playersToTarget.ForEach(player =>
|
playersToTarget.ForEach(player =>
|
||||||
{
|
{
|
||||||
player!.Pawn.Value!.Slap(damage);
|
if (caller!.CanTarget(player))
|
||||||
StringBuilder sb = new(_localizer!["sa_prefix"]);
|
|
||||||
|
|
||||||
if (caller == null || caller != null && caller.UserId != null && !silentPlayers.Contains((ushort)caller.UserId))
|
|
||||||
{
|
{
|
||||||
sb.Append(_localizer["sa_admin_slap_message", caller == null ? "Console" : caller.PlayerName, player.PlayerName]);
|
player!.Pawn.Value!.Slap(damage);
|
||||||
Server.PrintToChatAll(sb.ToString());
|
StringBuilder sb = new(_localizer!["sa_prefix"]);
|
||||||
|
|
||||||
|
if (caller == null || caller != null && caller.UserId != null && !silentPlayers.Contains((ushort)caller.UserId))
|
||||||
|
{
|
||||||
|
sb.Append(_localizer["sa_admin_slap_message", caller == null ? "Console" : caller.PlayerName, player.PlayerName]);
|
||||||
|
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, () =>
|
||||||
@@ -1797,13 +1827,16 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
|
|
||||||
playersToTarget.ForEach(player =>
|
playersToTarget.ForEach(player =>
|
||||||
{
|
{
|
||||||
player!.Pawn.Value!.ToggleNoclip();
|
if (caller!.CanTarget(player))
|
||||||
|
|
||||||
if (caller == null || caller != null && caller.UserId != null && !silentPlayers.Contains((ushort)caller.UserId))
|
|
||||||
{
|
{
|
||||||
StringBuilder sb = new(_localizer!["sa_prefix"]);
|
player!.Pawn.Value!.ToggleNoclip();
|
||||||
sb.Append(_localizer["sa_admin_noclip_message", caller == null ? "Console" : caller.PlayerName, player.PlayerName]);
|
|
||||||
Server.PrintToChatAll(sb.ToString());
|
if (caller == null || caller != null && caller.UserId != null && !silentPlayers.Contains((ushort)caller.UserId))
|
||||||
|
{
|
||||||
|
StringBuilder sb = new(_localizer!["sa_prefix"]);
|
||||||
|
sb.Append(_localizer["sa_admin_noclip_message", caller == null ? "Console" : caller.PlayerName, player.PlayerName]);
|
||||||
|
Server.PrintToChatAll(sb.ToString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -1821,16 +1854,19 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
|
|
||||||
playersToTarget.ForEach(player =>
|
playersToTarget.ForEach(player =>
|
||||||
{
|
{
|
||||||
player!.Pawn.Value!.Freeze();
|
if (caller!.CanTarget(player))
|
||||||
|
|
||||||
if (time > 0)
|
|
||||||
AddTimer(time, () => player.Pawn.Value!.Unfreeze());
|
|
||||||
|
|
||||||
if (caller == null || caller != null && caller.UserId != null && !silentPlayers.Contains((ushort)caller.UserId))
|
|
||||||
{
|
{
|
||||||
StringBuilder sb = new(_localizer!["sa_prefix"]);
|
player!.Pawn.Value!.Freeze();
|
||||||
sb.Append(_localizer["sa_admin_freeze_message", caller == null ? "Console" : caller.PlayerName, player.PlayerName]);
|
|
||||||
Server.PrintToChatAll(sb.ToString());
|
if (time > 0)
|
||||||
|
AddTimer(time, () => player.Pawn.Value!.Unfreeze());
|
||||||
|
|
||||||
|
if (caller == null || caller != null && caller.UserId != null && !silentPlayers.Contains((ushort)caller.UserId))
|
||||||
|
{
|
||||||
|
StringBuilder sb = new(_localizer!["sa_prefix"]);
|
||||||
|
sb.Append(_localizer["sa_admin_freeze_message", caller == null ? "Console" : caller.PlayerName, player.PlayerName]);
|
||||||
|
Server.PrintToChatAll(sb.ToString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -1866,13 +1902,16 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
|
|
||||||
playersToTarget.ForEach(player =>
|
playersToTarget.ForEach(player =>
|
||||||
{
|
{
|
||||||
player!.Respawn();
|
if (caller!.CanTarget(player))
|
||||||
|
|
||||||
if (caller == null || caller != null && caller.UserId != null && !silentPlayers.Contains((ushort)caller.UserId))
|
|
||||||
{
|
{
|
||||||
StringBuilder sb = new(_localizer!["sa_prefix"]);
|
player!.Respawn();
|
||||||
sb.Append(_localizer["sa_admin_respawn_message", caller == null ? "Console" : caller.PlayerName, player.PlayerName]);
|
|
||||||
Server.PrintToChatAll(sb.ToString());
|
if (caller == null || caller != null && caller.UserId != null && !silentPlayers.Contains((ushort)caller.UserId))
|
||||||
|
{
|
||||||
|
StringBuilder sb = new(_localizer!["sa_prefix"]);
|
||||||
|
sb.Append(_localizer["sa_admin_respawn_message", caller == null ? "Console" : caller.PlayerName, player.PlayerName]);
|
||||||
|
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