1.7.7-alpha

- Fixed (@all,@team,@lifestate) spam with discord webhook
- Currently `small` actions for ban optimizations
This commit is contained in:
Dawid Bepierszcz 2025-05-20 23:51:59 +02:00
parent b6c876d709
commit f69f1277f8
20 changed files with 460 additions and 241 deletions

View file

@ -73,12 +73,6 @@ public partial class CS2_SimpleAdmin
SimpleAdminApi?.OnPlayerPenaltiedEvent(playerInfo, adminInfo, PenaltyType.Ban, reason, time, penaltyId);
});
// Update banned players list
if (playerInfo.IpAddress != null && !BannedPlayers.Contains(playerInfo.IpAddress))
BannedPlayers.Add(playerInfo.IpAddress);
if (!BannedPlayers.Contains(player.SteamID.ToString()))
BannedPlayers.Add(player.SteamID.ToString());
// Determine message keys and arguments based on ban time
var (messageKey, activityMessageKey, centerArgs, adminActivityArgs) = time == 0
? ("sa_player_ban_message_perm", "sa_admin_ban_message_perm",
@ -129,8 +123,7 @@ public partial class CS2_SimpleAdmin
var adminInfo = caller != null && caller.UserId.HasValue ? PlayersInfo[caller.UserId.Value] : null;
var matches = Helper.GetPlayerFromSteamid64(steamid.SteamId64.ToString());
var player = matches.Count == 1 ? matches.FirstOrDefault() : null;
var player = Helper.GetPlayerFromSteamid64(steamid.SteamId64.ToString());
if (player != null && player.IsValid)
{
@ -184,8 +177,7 @@ public partial class CS2_SimpleAdmin
? PlayersInfo[caller.UserId.Value]
: null;
var matches = Helper.GetPlayerFromSteamid64(steamid);
var player = matches.Count == 1 ? matches.FirstOrDefault() : null;
var player = Helper.GetPlayerFromSteamid64(steamid);
if (player != null && player.IsValid)
{
@ -247,8 +239,7 @@ public partial class CS2_SimpleAdmin
? PlayersInfo[caller.UserId.Value]
: null;
var matches = Helper.GetPlayerFromIp(ipAddress);
var player = matches.Count == 1 ? matches.FirstOrDefault() : null;
var player = Helper.GetPlayerFromIp(ipAddress);
if (player != null && player.IsValid)
{
@ -442,8 +433,7 @@ public partial class CS2_SimpleAdmin
var adminInfo = caller != null && caller.UserId.HasValue ? PlayersInfo[caller.UserId.Value] : null;
var matches = Helper.GetPlayerFromSteamid64(steamid.SteamId64.ToString());
var player = matches.Count == 1 ? matches.FirstOrDefault() : null;
var player = Helper.GetPlayerFromSteamid64(steamid.SteamId64.ToString());
if (player != null && player.IsValid)
{

View file

@ -100,7 +100,6 @@ public partial class CS2_SimpleAdmin
var utf8String = Encoding.UTF8.GetString(utf8BytesString);
Helper.LogCommand(caller, command);
Helper.PrintToCenterAll(utf8String.ReplaceColorTags());
}

View file

@ -650,7 +650,6 @@ public partial class CS2_SimpleAdmin
Helper.LogCommand(caller, command);
var playersToTarget = targets.Players.Where(player => player is { IsValid: true, IsBot: false }).ToList();
if (playersToTarget.Count > 1)
return;
@ -708,20 +707,20 @@ public partial class CS2_SimpleAdmin
if (caller != null)
{
caller.PrintToConsole("--------- PLAYER LIST ---------");
playersToTarget.ForEach(player =>
foreach (var player in playersToTarget)
{
caller.PrintToConsole(
$"• [#{player.UserId}] \"{player.PlayerName}\" (IP Address: \"{(AdminManager.PlayerHasPermissions(new SteamID(caller.SteamID), "@css/showip") ? player.IpAddress?.Split(":")[0] : "Unknown")}\" SteamID64: \"{player.SteamID}\")");
});
};
caller.PrintToConsole("--------- END PLAYER LIST ---------");
}
else
{
Server.PrintToConsole("--------- PLAYER LIST ---------");
playersToTarget.ForEach(player =>
foreach (var player in playersToTarget)
{
Server.PrintToConsole($"• [#{player.UserId}] \"{player.PlayerName}\" (IP Address: \"{player.IpAddress?.Split(":")[0]}\" SteamID64: \"{player.SteamID}\")");
});
};
Server.PrintToConsole("--------- END PLAYER LIST ---------");
}
}
@ -789,6 +788,8 @@ public partial class CS2_SimpleAdmin
Kick(caller, player, reason, callerName, command);
}
});
Helper.LogCommand(caller, command);
}
public void Kick(CCSPlayerController? caller, CCSPlayerController player, string? reason = "Unknown", string? callerName = null, CommandInfo? command = null)
@ -828,8 +829,6 @@ public partial class CS2_SimpleAdmin
// Log the command and send Discord notification
if (command == null)
Helper.LogCommand(caller, $"css_kick {(string.IsNullOrEmpty(player.PlayerName) ? player.SteamID.ToString() : player.PlayerName)} {reason}");
else
Helper.LogCommand(caller, command);
SimpleAdminApi?.OnPlayerPenaltiedEvent(playerInfo, adminInfo, PenaltyType.Kick, reason, -1, null);
}

View file

@ -114,8 +114,7 @@ public partial class CS2_SimpleAdmin
var adminInfo = caller != null && caller.UserId.HasValue ? PlayersInfo[caller.UserId.Value] : null;
var matches = Helper.GetPlayerFromSteamid64(steamid.SteamId64.ToString());
var player = matches.Count == 1 ? matches.FirstOrDefault() : null;
var player = Helper.GetPlayerFromSteamid64(steamid.SteamId64.ToString());
if (player != null && player.IsValid)
{
@ -173,8 +172,7 @@ public partial class CS2_SimpleAdmin
var adminInfo = caller != null && caller.UserId.HasValue ? PlayersInfo[caller.UserId.Value] : null;
// Attempt to match player based on SteamID
var matches = Helper.GetPlayerFromSteamid64(steamid);
var player = matches.Count == 1 ? matches.FirstOrDefault() : null;
var player = Helper.GetPlayerFromSteamid64(steamid);
if (player != null && player.IsValid)
{
@ -230,8 +228,7 @@ public partial class CS2_SimpleAdmin
// Check if pattern is a valid SteamID64
if (Helper.ValidateSteamId(pattern, out var steamId) && steamId != null)
{
var matches = Helper.GetPlayerFromSteamid64(steamId.SteamId64.ToString());
var player = matches.Count == 1 ? matches.FirstOrDefault() : null;
var player = Helper.GetPlayerFromSteamid64(steamId.SteamId64.ToString());
if (player != null && player.IsValid)
{
@ -406,8 +403,7 @@ public partial class CS2_SimpleAdmin
var adminInfo = caller != null && caller.UserId.HasValue ? PlayersInfo[caller.UserId.Value] : null;
// Attempt to match player based on SteamID
var matches = Helper.GetPlayerFromSteamid64(steamid);
var player = matches.Count == 1 ? matches.FirstOrDefault() : null;
var player = Helper.GetPlayerFromSteamid64(steamid);
if (player != null && player.IsValid)
{
@ -447,8 +443,7 @@ public partial class CS2_SimpleAdmin
var adminInfo = caller != null && caller.UserId.HasValue ? PlayersInfo[caller.UserId.Value] : null;
var matches = Helper.GetPlayerFromSteamid64(steamid.SteamId64.ToString());
var player = matches.Count == 1 ? matches.FirstOrDefault() : null;
var player = Helper.GetPlayerFromSteamid64(steamid.SteamId64.ToString());
if (player != null && player.IsValid)
{
@ -498,8 +493,7 @@ public partial class CS2_SimpleAdmin
// Check if pattern is a valid SteamID64
if (Helper.ValidateSteamId(pattern, out var steamId) && steamId != null)
{
var matches = Helper.GetPlayerFromSteamid64(steamId.SteamId64.ToString());
var player = matches.Count == 1 ? matches.FirstOrDefault() : null;
var player = Helper.GetPlayerFromSteamid64(steamId.SteamId64.ToString());
if (player != null && player.IsValid)
{
@ -674,8 +668,7 @@ public partial class CS2_SimpleAdmin
var adminInfo = caller != null && caller.UserId.HasValue ? PlayersInfo[caller.UserId.Value] : null;
// Attempt to match player based on SteamID
var matches = Helper.GetPlayerFromSteamid64(steamid);
var player = matches.Count == 1 ? matches.FirstOrDefault() : null;
var player = Helper.GetPlayerFromSteamid64(steamid);
if (player != null && player.IsValid)
{
@ -715,8 +708,7 @@ public partial class CS2_SimpleAdmin
var adminInfo = caller != null && caller.UserId.HasValue ? PlayersInfo[caller.UserId.Value] : null;
var matches = Helper.GetPlayerFromSteamid64(steamid.SteamId64.ToString());
var player = matches.Count == 1 ? matches.FirstOrDefault() : null;
var player = Helper.GetPlayerFromSteamid64(steamid.SteamId64.ToString());
if (player != null && player.IsValid)
{
@ -766,8 +758,7 @@ public partial class CS2_SimpleAdmin
// Check if pattern is a valid SteamID64
if (Helper.ValidateSteamId(pattern, out var steamId) && steamId != null)
{
var matches = Helper.GetPlayerFromSteamid64(steamId.SteamId64.ToString());
var player = matches.Count == 1 ? matches.FirstOrDefault() : null;
var player = Helper.GetPlayerFromSteamid64(steamId.SteamId64.ToString());
if (player != null && player.IsValid)
{

View file

@ -27,6 +27,8 @@ public partial class CS2_SimpleAdmin
NoClip(caller, player, callerName);
}
});
Helper.LogCommand(caller, command);
}
internal static void NoClip(CCSPlayerController? caller, CCSPlayerController player, string? callerName = null, CommandInfo? command = null)
@ -53,13 +55,7 @@ public partial class CS2_SimpleAdmin
// Log the command
if (command == null)
{
Helper.LogCommand(caller, $"css_noclip {(string.IsNullOrEmpty(player.PlayerName) ? player.SteamID.ToString() : player.PlayerName)}");
}
else
{
Helper.LogCommand(caller, command);
}
}
[RequiresPermissions("@css/cheats")]
@ -82,6 +78,8 @@ public partial class CS2_SimpleAdmin
God(caller, player, command);
}
});
Helper.LogCommand(caller, command);
}
internal static void God(CCSPlayerController? caller, CCSPlayerController player, CommandInfo? command = null)
@ -100,8 +98,6 @@ public partial class CS2_SimpleAdmin
// Log the command
if (command == null)
Helper.LogCommand(caller, $"css_god {(string.IsNullOrEmpty(player.PlayerName) ? player.SteamID.ToString() : player.PlayerName)}");
else
Helper.LogCommand(caller, command);
// Determine message key and arguments for the god mode notification
var (activityMessageKey, adminActivityArgs) =
@ -133,6 +129,8 @@ public partial class CS2_SimpleAdmin
Freeze(caller, player, time, callerName, command);
}
});
Helper.LogCommand(caller, command);
}
[CommandHelper(1, "<#userid or name> [size]")]
@ -206,8 +204,6 @@ public partial class CS2_SimpleAdmin
// Log the command and send Discord notification
if (command == null)
Helper.LogCommand(caller, $"css_freeze {(string.IsNullOrEmpty(player.PlayerName) ? player.SteamID.ToString() : player.PlayerName)} {time}");
else
Helper.LogCommand(caller, command);
}
[CommandHelper(1, "<#userid or name>")]
@ -224,6 +220,8 @@ public partial class CS2_SimpleAdmin
{
Unfreeze(caller, player, callerName, command);
});
Helper.LogCommand(caller, command);
}
internal static void Unfreeze(CCSPlayerController? caller, CCSPlayerController player, string? callerName = null, CommandInfo? command = null)
@ -251,7 +249,5 @@ public partial class CS2_SimpleAdmin
// Log the command and send Discord notification
if (command == null)
Helper.LogCommand(caller, $"css_unfreeze {(string.IsNullOrEmpty(player.PlayerName) ? player.SteamID.ToString() : player.PlayerName)}");
else
Helper.LogCommand(caller, command);
}
}

View file

@ -28,6 +28,8 @@ public partial class CS2_SimpleAdmin
{
Slay(caller, player, callerName, command);
});
Helper.LogCommand(caller, command);
}
internal static void Slay(CCSPlayerController? caller, CCSPlayerController player, string? callerName = null, CommandInfo? command = null)
@ -55,8 +57,6 @@ public partial class CS2_SimpleAdmin
// Log the command and send Discord notification
if (command == null)
Helper.LogCommand(caller, $"css_slay {(string.IsNullOrEmpty(player.PlayerName) ? player.SteamID.ToString() : player.PlayerName)}");
else
Helper.LogCommand(caller, command);
}
[RequiresPermissions("@css/cheats")]
@ -94,6 +94,8 @@ public partial class CS2_SimpleAdmin
GiveWeapon(caller, player, weaponName, callerName, command);
});
Helper.LogCommand(caller, command);
}
private static void GiveWeapon(CCSPlayerController? caller, CCSPlayerController player, string weaponName, string? callerName = null, CommandInfo? command = null)
@ -122,8 +124,6 @@ public partial class CS2_SimpleAdmin
// Log the command
if (command == null)
Helper.LogCommand(caller, $"css_giveweapon {(string.IsNullOrEmpty(player.PlayerName) ? player.SteamID.ToString() : player.PlayerName)} {weaponName}");
else
Helper.LogCommand(caller, command);
// Determine message keys and arguments for the weapon give notification
var (activityMessageKey, adminActivityArgs) =
@ -150,8 +150,6 @@ public partial class CS2_SimpleAdmin
// Log the command
if (command == null)
Helper.LogCommand(caller, $"css_giveweapon {(string.IsNullOrEmpty(player.PlayerName) ? player.SteamID.ToString() : player.PlayerName)} {weapon.ToString()}");
else
Helper.LogCommand(caller, command);
// Determine message keys and arguments for the weapon give notification
var (activityMessageKey, adminActivityArgs) =
@ -182,6 +180,8 @@ public partial class CS2_SimpleAdmin
StripWeapons(caller, player, callerName, command);
}
});
Helper.LogCommand(caller, command);
}
internal static void StripWeapons(CCSPlayerController? caller, CCSPlayerController player, string? callerName = null, CommandInfo? command = null)
@ -201,8 +201,6 @@ public partial class CS2_SimpleAdmin
// Log the command
if (command == null)
Helper.LogCommand(caller, $"css_strip {(string.IsNullOrEmpty(player.PlayerName) ? player.SteamID.ToString() : player.PlayerName)}");
else
Helper.LogCommand(caller, command);
// Determine message keys and arguments for the weapon strip notification
var (activityMessageKey, adminActivityArgs) =
@ -234,6 +232,8 @@ public partial class CS2_SimpleAdmin
SetHp(caller, player, health, command);
}
});
Helper.LogCommand(caller, command);
}
internal static void SetHp(CCSPlayerController? caller, CCSPlayerController player, int health, CommandInfo? command = null)
@ -250,8 +250,6 @@ public partial class CS2_SimpleAdmin
// Log the command
if (command == null)
Helper.LogCommand(caller, $"css_hp {(string.IsNullOrEmpty(player.PlayerName) ? player.SteamID.ToString() : player.PlayerName)} {health}");
else
Helper.LogCommand(caller, command);
// Determine message keys and arguments for the HP set notification
var (activityMessageKey, adminActivityArgs) =
@ -286,6 +284,8 @@ public partial class CS2_SimpleAdmin
SetSpeed(caller, player, speed, command);
}
});
Helper.LogCommand(caller, command);
}
internal static void SetSpeed(CCSPlayerController? caller, CCSPlayerController player, float speed, CommandInfo? command = null)
@ -306,8 +306,6 @@ public partial class CS2_SimpleAdmin
// Log the command
if (command == null)
Helper.LogCommand(caller, $"css_speed {(string.IsNullOrEmpty(player.PlayerName) ? player.SteamID.ToString() : player.PlayerName)} {speed}");
else
Helper.LogCommand(caller, command);
// Determine message keys and arguments for the speed set notification
var (activityMessageKey, adminActivityArgs) =
@ -342,6 +340,8 @@ public partial class CS2_SimpleAdmin
SetGravity(caller, player, gravity, command);
}
});
Helper.LogCommand(caller, command);
}
internal static void SetGravity(CCSPlayerController? caller, CCSPlayerController player, float gravity, CommandInfo? command = null)
@ -362,8 +362,6 @@ public partial class CS2_SimpleAdmin
// Log the command
if (command == null)
Helper.LogCommand(caller, $"css_gravity {(string.IsNullOrEmpty(player.PlayerName) ? player.SteamID.ToString() : player.PlayerName)} {gravity}");
else
Helper.LogCommand(caller, command);
// Determine message keys and arguments for the gravity set notification
var (activityMessageKey, adminActivityArgs) =
@ -399,6 +397,8 @@ public partial class CS2_SimpleAdmin
SetMoney(caller, player, money, command);
}
});
Helper.LogCommand(caller, command);
}
internal static void SetMoney(CCSPlayerController? caller, CCSPlayerController player, int money, CommandInfo? command = null)
@ -414,8 +414,6 @@ public partial class CS2_SimpleAdmin
// Log the command
if (command == null)
Helper.LogCommand(caller, $"css_money {(string.IsNullOrEmpty(player.PlayerName) ? player.SteamID.ToString() : player.PlayerName)} {money}");
else
Helper.LogCommand(caller, command);
// Determine message keys and arguments for the money set notification
var (activityMessageKey, adminActivityArgs) =
@ -455,6 +453,8 @@ public partial class CS2_SimpleAdmin
Slap(caller, player, damage, command);
}
});
Helper.LogCommand(caller, command);
}
internal static void Slap(CCSPlayerController? caller, CCSPlayerController player, int damage, CommandInfo? command = null)
@ -470,9 +470,7 @@ public partial class CS2_SimpleAdmin
// Log the command
if (command == null)
Helper.LogCommand(caller, $"css_slap {(string.IsNullOrEmpty(player.PlayerName) ? player.SteamID.ToString() : player.PlayerName)} {damage}");
else
Helper.LogCommand(caller, command);
// Determine message key and arguments for the slap notification
var (activityMessageKey, adminActivityArgs) =
("sa_admin_slap_message",
@ -532,6 +530,8 @@ public partial class CS2_SimpleAdmin
{
ChangeTeam(caller, player, _teamName, teamNum, kill, command);
});
Helper.LogCommand(caller, command);
}
internal static void ChangeTeam(CCSPlayerController? caller, CCSPlayerController player, string teamName, CsTeam teamNum, bool kill, CommandInfo? command = null)
@ -570,8 +570,6 @@ public partial class CS2_SimpleAdmin
// Log the command
if (command == null)
Helper.LogCommand(caller, $"css_team {player.PlayerName} {teamName}");
else
Helper.LogCommand(caller, command);
// Determine message key and arguments for the team change notification
var activityMessageKey = "sa_admin_team_message";
@ -698,6 +696,8 @@ public partial class CS2_SimpleAdmin
Respawn(caller, player, callerName, command);
}
});
Helper.LogCommand(caller, command);
}
internal static void Respawn(CCSPlayerController? caller, CCSPlayerController player, string? callerName = null, CommandInfo? command = null)
@ -722,8 +722,6 @@ public partial class CS2_SimpleAdmin
// Log the command
if (command == null)
Helper.LogCommand(caller, $"css_respawn {(string.IsNullOrEmpty(player.PlayerName) ? player.SteamID.ToString() : player.PlayerName)}");
else
Helper.LogCommand(caller, command);
// Determine message key and arguments for the respawn notification
var activityMessageKey = "sa_admin_respawn_message";