mirror of
https://github.com/daffyyyy/CS2-SimpleAdmin.git
synced 2026-02-18 10:43:23 +00:00
1.3.4a
- Minor changes - Escape kick reason @poggu suggestion - Auto-updater for config - Using UTC time - Added expiring IP bans after x days (`ExpireOldIpBans` in config => value = days, 0 = disabled) - Added exception message to database error - Fixed? ungag/unmute/unsilence commands - Updated css version to `178` - Changed `css_adminhelp` command to use new file `admin_help.txt` as output
This commit is contained in:
@@ -60,7 +60,6 @@ namespace CS2_SimpleAdmin
|
||||
if (_database == null) return;
|
||||
|
||||
callerName ??= caller == null ? "Console" : caller.PlayerName;
|
||||
banManager ??= new BanManager(_database, Config);
|
||||
|
||||
if (player.PawnIsAlive)
|
||||
{
|
||||
@@ -85,6 +84,7 @@ namespace CS2_SimpleAdmin
|
||||
|
||||
Task.Run(async () =>
|
||||
{
|
||||
banManager ??= new BanManager(_database, Config);
|
||||
await banManager.BanPlayer(playerInfo, adminInfo, reason, time);
|
||||
});
|
||||
|
||||
@@ -143,6 +143,7 @@ namespace CS2_SimpleAdmin
|
||||
[CommandHelper(minArgs: 1, usage: "<steamid> [time in minutes/0 perm] [reason]", whoCanExecute: CommandUsage.CLIENT_AND_SERVER)]
|
||||
public void OnAddBanCommand(CCSPlayerController? caller, CommandInfo command)
|
||||
{
|
||||
if (_database == null) return;
|
||||
string callerName = caller == null ? "Console" : caller.PlayerName;
|
||||
if (command.ArgCount < 2)
|
||||
return;
|
||||
@@ -243,9 +244,7 @@ namespace CS2_SimpleAdmin
|
||||
|
||||
Task.Run(async () =>
|
||||
{
|
||||
Database database = new Database(dbConnectionString);
|
||||
|
||||
BanManager _banManager = new(database, Config);
|
||||
BanManager _banManager = new(_database, Config);
|
||||
await _banManager.AddBanBySteamid(steamid, adminInfo, reason, time);
|
||||
});
|
||||
|
||||
@@ -257,6 +256,7 @@ namespace CS2_SimpleAdmin
|
||||
[CommandHelper(minArgs: 1, usage: "<ip> [time in minutes/0 perm] [reason]", whoCanExecute: CommandUsage.CLIENT_AND_SERVER)]
|
||||
public void OnBanIp(CCSPlayerController? caller, CommandInfo command)
|
||||
{
|
||||
if (_database == null) return;
|
||||
string callerName = caller == null ? "Console" : caller.PlayerName;
|
||||
|
||||
if (command.ArgCount < 2)
|
||||
@@ -355,9 +355,7 @@ namespace CS2_SimpleAdmin
|
||||
|
||||
Task.Run(async () =>
|
||||
{
|
||||
Database database = new Database(dbConnectionString);
|
||||
|
||||
BanManager _banManager = new(database, Config);
|
||||
BanManager _banManager = new(_database, Config);
|
||||
await _banManager.AddBanByIp(ipAddress, adminInfo, reason, time);
|
||||
});
|
||||
|
||||
@@ -369,6 +367,8 @@ namespace CS2_SimpleAdmin
|
||||
[CommandHelper(minArgs: 1, usage: "<steamid or name or ip>", whoCanExecute: CommandUsage.CLIENT_AND_SERVER)]
|
||||
public void OnUnbanCommand(CCSPlayerController? caller, CommandInfo command)
|
||||
{
|
||||
if (_database == null) return;
|
||||
|
||||
string callerName = caller == null ? "Console" : caller.PlayerName;
|
||||
if (command.GetArg(1).Length <= 1)
|
||||
{
|
||||
@@ -386,11 +386,8 @@ namespace CS2_SimpleAdmin
|
||||
|
||||
string pattern = command.GetArg(1);
|
||||
|
||||
Database database = new Database(dbConnectionString);
|
||||
|
||||
BanManager _banManager = new(database, Config);
|
||||
|
||||
_ = _banManager.UnbanPlayer(pattern);
|
||||
BanManager _banManager = new BanManager(_database, Config);
|
||||
Task.Run(async () => await _banManager.UnbanPlayer(pattern));
|
||||
|
||||
command.ReplyToCommand($"Unbanned player with pattern {pattern}.");
|
||||
}
|
||||
|
||||
@@ -92,10 +92,10 @@ namespace CS2_SimpleAdmin
|
||||
|
||||
playersToTarget.ForEach(player =>
|
||||
{
|
||||
player.PrintToChat(Helper.ReplaceTags($"({caller!.PlayerName}) {utf8String}"));
|
||||
player.PrintToChat(StringExtensions.ReplaceColorTags($"({caller!.PlayerName}) {utf8String}"));
|
||||
});
|
||||
|
||||
command.ReplyToCommand(Helper.ReplaceTags($" Private message sent!"));
|
||||
command.ReplyToCommand(StringExtensions.ReplaceColorTags($" Private message sent!"));
|
||||
}
|
||||
|
||||
[ConsoleCommand("css_csay", "Say to all players (in center).")]
|
||||
@@ -115,7 +115,7 @@ namespace CS2_SimpleAdmin
|
||||
|
||||
Helper.LogCommand(caller, command);
|
||||
|
||||
Helper.PrintToCenterAll(Helper.ReplaceTags(utf8String));
|
||||
Helper.PrintToCenterAll(StringExtensions.ReplaceColorTags(utf8String));
|
||||
}
|
||||
|
||||
[ConsoleCommand("css_hsay", "Say to all players (in hud).")]
|
||||
@@ -137,7 +137,7 @@ namespace CS2_SimpleAdmin
|
||||
|
||||
VirtualFunctions.ClientPrintAll(
|
||||
HudDestination.Alert,
|
||||
Helper.ReplaceTags(utf8String),
|
||||
StringExtensions.ReplaceColorTags(utf8String),
|
||||
0, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,8 +55,9 @@ namespace CS2_SimpleAdmin
|
||||
[RequiresPermissions("@css/generic")]
|
||||
public void OnAdminHelpCommand(CCSPlayerController? caller, CommandInfo command)
|
||||
{
|
||||
if (caller == null || !caller.IsValid) return;
|
||||
//if (caller == null || !caller.IsValid) return;
|
||||
|
||||
/*
|
||||
using (new WithTemporaryCulture(caller.GetLanguage()))
|
||||
{
|
||||
var splitMessage = _localizer!["sa_adminhelp"].ToString().Split(new[] { "\r\n", "\r", "\n" }, StringSplitOptions.None);
|
||||
@@ -65,6 +66,20 @@ namespace CS2_SimpleAdmin
|
||||
{
|
||||
caller.PrintToChat(Helper.ReplaceTags($" {line}"));
|
||||
}
|
||||
} */
|
||||
|
||||
string[] lines = File.ReadAllLines(ModuleDirectory + "/admin_help.txt");
|
||||
|
||||
foreach (string line in lines)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(line))
|
||||
{
|
||||
command.ReplyToCommand(" ");
|
||||
}
|
||||
else
|
||||
{
|
||||
command.ReplyToCommand(StringExtensions.ReplaceColorTags(line));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -244,7 +244,12 @@ namespace CS2_SimpleAdmin
|
||||
playerPenaltyManager.AddPenalty(player!.Slot, PenaltyType.Gag, DateTime.Now.AddMinutes(time), time);
|
||||
}
|
||||
}
|
||||
_ = _muteManager.AddMuteBySteamid(steamid, adminInfo, reason, time, 0);
|
||||
|
||||
Task.Run(async () =>
|
||||
{
|
||||
await _muteManager.AddMuteBySteamid(steamid, adminInfo, reason, time, 0);
|
||||
});
|
||||
|
||||
command.ReplyToCommand($"Gagged player with steamid {steamid}.");
|
||||
}
|
||||
|
||||
@@ -277,6 +282,11 @@ namespace CS2_SimpleAdmin
|
||||
|
||||
PlayerPenaltyManager playerPenaltyManager = new PlayerPenaltyManager();
|
||||
|
||||
Task.Run(async () =>
|
||||
{
|
||||
await _muteManager.UnmutePlayer(pattern, 0); // Unmute by type 0 (gag)
|
||||
});
|
||||
|
||||
if (Helper.IsValidSteamID64(pattern))
|
||||
{
|
||||
List<CCSPlayerController> matches = Helper.GetPlayerFromSteamid64(pattern);
|
||||
@@ -313,12 +323,6 @@ namespace CS2_SimpleAdmin
|
||||
}
|
||||
}
|
||||
}
|
||||
if (found)
|
||||
{
|
||||
_ = _muteManager.UnmutePlayer(pattern, 0); // Unmute by type 0 (gag)
|
||||
command.ReplyToCommand($"Ungaged player with pattern {pattern}.");
|
||||
return;
|
||||
}
|
||||
|
||||
TargetResult? targets = GetTarget(command);
|
||||
if (targets == null) return;
|
||||
@@ -336,7 +340,11 @@ namespace CS2_SimpleAdmin
|
||||
playerPenaltyManager.RemovePenaltiesByType(player!.Slot, PenaltyType.Gag);
|
||||
|
||||
if (player!.SteamID.ToString().Length == 17)
|
||||
_ = _muteManager.UnmutePlayer(player.SteamID.ToString(), 0); // Unmute by type 0 (gag)
|
||||
Task.Run(async () =>
|
||||
{
|
||||
await _muteManager.UnmutePlayer(player.SteamID.ToString(), 0); // Unmute by type 0 (gag)
|
||||
});
|
||||
|
||||
|
||||
if (TagsDetected)
|
||||
Server.ExecuteCommand($"css_tag_unmute {player!.SteamID}");
|
||||
@@ -567,7 +575,12 @@ namespace CS2_SimpleAdmin
|
||||
}
|
||||
}
|
||||
}
|
||||
_ = _muteManager.AddMuteBySteamid(steamid, adminInfo, reason, time, 1);
|
||||
|
||||
Task.Run(async () =>
|
||||
{
|
||||
await _muteManager.AddMuteBySteamid(steamid, adminInfo, reason, time, 1);
|
||||
});
|
||||
|
||||
command.ReplyToCommand($"Muted player with steamid {steamid}.");
|
||||
}
|
||||
|
||||
@@ -598,6 +611,11 @@ namespace CS2_SimpleAdmin
|
||||
MuteManager _muteManager = new(_database);
|
||||
PlayerPenaltyManager playerPenaltyManager = new PlayerPenaltyManager();
|
||||
|
||||
Task.Run(async () =>
|
||||
{
|
||||
await _muteManager.UnmutePlayer(pattern, 1); // Unmute by type 1 (mute)
|
||||
});
|
||||
|
||||
if (Helper.IsValidSteamID64(pattern))
|
||||
{
|
||||
List<CCSPlayerController> matches = Helper.GetPlayerFromSteamid64(pattern);
|
||||
@@ -630,12 +648,12 @@ namespace CS2_SimpleAdmin
|
||||
|
||||
if (found)
|
||||
{
|
||||
_ = _muteManager.UnmutePlayer(pattern, 1); // Unmute by type 1 (mute)
|
||||
command.ReplyToCommand($"Unmuted player with pattern {pattern}.");
|
||||
return;
|
||||
}
|
||||
|
||||
TargetResult? targets = GetTarget(command);
|
||||
if (targets == null) return;
|
||||
List<CCSPlayerController> playersToTarget = targets!.Players.Where(player => player != null && player.IsValid && player.SteamID.ToString().Length == 17 && !player.IsHLTV).ToList();
|
||||
|
||||
if (playersToTarget.Count > 1 && Config.DisableDangerousCommands || playersToTarget.Count == 0)
|
||||
@@ -648,7 +666,10 @@ namespace CS2_SimpleAdmin
|
||||
playersToTarget.ForEach(player =>
|
||||
{
|
||||
if (player.SteamID.ToString().Length == 17)
|
||||
_ = _muteManager.UnmutePlayer(player.SteamID.ToString(), 1); // Unmute by type 1 (mute)
|
||||
Task.Run(async () =>
|
||||
{
|
||||
await _muteManager.UnmutePlayer(player.SteamID.ToString(), 1); // Unmute by type 1 (mute)
|
||||
});
|
||||
|
||||
playerPenaltyManager.RemovePenaltiesByType(player!.Slot, PenaltyType.Mute);
|
||||
player.VoiceFlags = VoiceFlags.Normal;
|
||||
@@ -890,7 +911,11 @@ namespace CS2_SimpleAdmin
|
||||
}
|
||||
}
|
||||
}
|
||||
_ = _muteManager.AddMuteBySteamid(steamid, adminInfo, reason, time, 2);
|
||||
Task.Run(async () =>
|
||||
{
|
||||
await _muteManager.AddMuteBySteamid(steamid, adminInfo, reason, time, 2);
|
||||
});
|
||||
|
||||
command.ReplyToCommand($"Silenced player with steamid {steamid}.");
|
||||
}
|
||||
|
||||
@@ -921,6 +946,11 @@ namespace CS2_SimpleAdmin
|
||||
MuteManager _muteManager = new(_database);
|
||||
PlayerPenaltyManager playerPenaltyManager = new PlayerPenaltyManager();
|
||||
|
||||
Task.Run(async () =>
|
||||
{
|
||||
await _muteManager.UnmutePlayer(pattern, 2); // Unmute by type 2 (silence)
|
||||
});
|
||||
|
||||
if (Helper.IsValidSteamID64(pattern))
|
||||
{
|
||||
List<CCSPlayerController> matches = Helper.GetPlayerFromSteamid64(pattern);
|
||||
@@ -959,12 +989,13 @@ namespace CS2_SimpleAdmin
|
||||
|
||||
if (found)
|
||||
{
|
||||
_ = _muteManager.UnmutePlayer(pattern, 2); // Unmute by type 2 (silence)
|
||||
//Task.Run(async () => { await _muteManager.UnmutePlayer(pattern, 2); }); // Unmute by type 2 (silence)
|
||||
command.ReplyToCommand($"Unsilenced player with pattern {pattern}.");
|
||||
return;
|
||||
}
|
||||
|
||||
TargetResult? targets = GetTarget(command);
|
||||
if (targets == null) return;
|
||||
List<CCSPlayerController> playersToTarget = targets!.Players.Where(player => player != null && player.IsValid && player.SteamID.ToString().Length == 17 && !player.IsHLTV).ToList();
|
||||
|
||||
if (playersToTarget.Count > 1 && Config.DisableDangerousCommands || playersToTarget.Count == 0)
|
||||
@@ -977,7 +1008,7 @@ namespace CS2_SimpleAdmin
|
||||
playersToTarget.ForEach(player =>
|
||||
{
|
||||
if (player.SteamID.ToString().Length == 17)
|
||||
_ = _muteManager.UnmutePlayer(player.SteamID.ToString(), 2); // Unmute by type 2 (silence)
|
||||
Task.Run(async () => { await _muteManager.UnmutePlayer(player.SteamID.ToString(), 2); }); // Unmute by type 2 (silence)
|
||||
|
||||
if (TagsDetected)
|
||||
Server.ExecuteCommand($"css_tag_unmute {player!.SteamID}");
|
||||
|
||||
@@ -52,12 +52,13 @@ namespace CS2_SimpleAdmin
|
||||
}
|
||||
|
||||
voteMenu.PostSelectAction = PostSelectAction.Close;
|
||||
MenuManager.OpenChatMenu(_player, voteMenu);
|
||||
|
||||
Helper.PrintToCenterAll(_localizer!["sa_admin_vote_message", caller == null ? "Console" : caller.PlayerName, question]);
|
||||
StringBuilder sb = new(_localizer!["sa_prefix"]);
|
||||
sb.Append(_localizer["sa_admin_vote_message", caller == null ? "Console" : caller.PlayerName, question]);
|
||||
_player.PrintToChat(sb.ToString());
|
||||
|
||||
MenuManager.OpenChatMenu(_player, voteMenu);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace CS2_SimpleAdmin
|
||||
callerName ??= caller == null ? "Console" : caller.PlayerName;
|
||||
player!.Pawn.Value!.ToggleNoclip();
|
||||
|
||||
Helper.LogCommand(caller, $"css_noclip {player?.PlayerName}");
|
||||
Helper.LogCommand(caller, $"css_noclip {player.PlayerName}");
|
||||
|
||||
if (caller == null || caller != null && !silentPlayers.Contains(caller.Slot))
|
||||
{
|
||||
@@ -90,9 +90,9 @@ namespace CS2_SimpleAdmin
|
||||
{
|
||||
callerName ??= caller == null ? "Console" : caller.PlayerName;
|
||||
|
||||
player!.Pawn.Value!.Freeze();
|
||||
player.Pawn.Value!.Freeze();
|
||||
|
||||
Helper.LogCommand(caller, $"css_freeze {player?.PlayerName}");
|
||||
Helper.LogCommand(caller, $"css_freeze {player.PlayerName}");
|
||||
|
||||
if (time > 0)
|
||||
AddTimer(time, () => player.Pawn.Value!.Unfreeze(), CounterStrikeSharp.API.Modules.Timers.TimerFlags.STOP_ON_MAPCHANGE);
|
||||
@@ -142,7 +142,7 @@ namespace CS2_SimpleAdmin
|
||||
|
||||
player!.Pawn.Value!.Unfreeze();
|
||||
|
||||
Helper.LogCommand(caller, $"css_unfreeze {player?.PlayerName}");
|
||||
Helper.LogCommand(caller, $"css_unfreeze {player.PlayerName}");
|
||||
|
||||
if (caller == null || caller != null && !silentPlayers.Contains(caller.Slot))
|
||||
{
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace CS2_SimpleAdmin
|
||||
|
||||
player.CommitSuicide(false, true);
|
||||
|
||||
Helper.LogCommand(caller, $"css_slay {player?.PlayerName}");
|
||||
Helper.LogCommand(caller, $"css_slay {player.PlayerName}");
|
||||
|
||||
if (caller == null || caller != null && !silentPlayers.Contains(caller.Slot))
|
||||
{
|
||||
@@ -182,7 +182,7 @@ namespace CS2_SimpleAdmin
|
||||
|
||||
player.RemoveWeapons();
|
||||
|
||||
Helper.LogCommand(caller, $"css_strip {player?.PlayerName}");
|
||||
Helper.LogCommand(caller, $"css_strip {player.PlayerName}");
|
||||
|
||||
if (caller == null || caller != null && !silentPlayers.Contains(caller.Slot))
|
||||
{
|
||||
@@ -236,7 +236,7 @@ namespace CS2_SimpleAdmin
|
||||
|
||||
player.SetHp(health);
|
||||
|
||||
Helper.LogCommand(caller, $"css_hp {player?.PlayerName} {health}");
|
||||
Helper.LogCommand(caller, $"css_hp {player.PlayerName} {health}");
|
||||
|
||||
if (caller == null || caller != null && !silentPlayers.Contains(caller.Slot))
|
||||
{
|
||||
@@ -408,7 +408,7 @@ namespace CS2_SimpleAdmin
|
||||
callerName ??= caller == null ? "Console" : caller.PlayerName;
|
||||
player!.Pawn.Value!.Slap(damage);
|
||||
|
||||
Helper.LogCommand(caller, $"css_slap {player?.PlayerName} {damage}");
|
||||
Helper.LogCommand(caller, $"css_slap {player.PlayerName} {damage}");
|
||||
|
||||
if (caller == null || caller != null && !silentPlayers.Contains(caller.Slot))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user