mirror of
https://github.com/daffyyyy/CS2-SimpleAdmin.git
synced 2026-02-17 18:39:07 +00:00
Merge pull request #85 from Dliix66/main
Fixed Discord web hooks with the menu and several bug fixes/improvments on the menus
This commit is contained in:
@@ -31,12 +31,6 @@ namespace CS2_SimpleAdmin
|
||||
return;
|
||||
}
|
||||
|
||||
if (_discordWebhookClientLog != null && _localizer != null)
|
||||
{
|
||||
string communityUrl = caller != null ? "<" + new SteamID(caller.SteamID).ToCommunityUrl().ToString() + ">" : "<https://steamcommunity.com/profiles/0>";
|
||||
_discordWebhookClientLog.SendMessageAsync(Helper.GenerateMessageDiscord(_localizer["sa_discord_log_command", $"[{callerName}]({communityUrl})", command.GetCommandString]));
|
||||
}
|
||||
|
||||
Database database = new Database(dbConnectionString);
|
||||
|
||||
BanManager _banManager = new(database, Config);
|
||||
@@ -80,7 +74,9 @@ namespace CS2_SimpleAdmin
|
||||
IpAddress = caller?.IpAddress?.Split(":")[0]
|
||||
};
|
||||
|
||||
Helper.LogCommand(caller, $"css_ban {player.SteamID} {time} {reason}");
|
||||
string commandName = $"css_ban {player.SteamID} {time} {reason}";
|
||||
Helper.LogCommand(caller, commandName);
|
||||
Helper.TryLogCommandOnDiscord(caller, commandName);
|
||||
|
||||
Task.Run(async () =>
|
||||
{
|
||||
|
||||
@@ -122,12 +122,6 @@ namespace CS2_SimpleAdmin
|
||||
return;
|
||||
}
|
||||
|
||||
if (_discordWebhookClientLog != null && _localizer != null)
|
||||
{
|
||||
string communityUrl = caller != null ? "<" + new SteamID(caller.SteamID).ToCommunityUrl().ToString() + ">" : "<https://steamcommunity.com/profiles/0>";
|
||||
_discordWebhookClientLog.SendMessageAsync(Helper.GenerateMessageDiscord(_localizer["sa_discord_log_command", $"[{callerName}]({communityUrl})", command.GetCommandString]));
|
||||
}
|
||||
|
||||
string steamid = command.GetArg(1);
|
||||
string name = command.GetArg(2);
|
||||
string flags = command.GetArg(3);
|
||||
@@ -146,7 +140,9 @@ namespace CS2_SimpleAdmin
|
||||
AdminSQLManager _adminManager = new(_database);
|
||||
_ = _adminManager.AddAdminBySteamId(steamid, name, flags, immunity, time, globalAdmin);
|
||||
|
||||
Helper.LogCommand(caller, $"css_addadmin {steamid} {name} {flags} {immunity} {time}");
|
||||
string commandName = $"css_addadmin {steamid} {name} {flags} {immunity} {time}";
|
||||
Helper.TryLogCommandOnDiscord(caller, commandName);
|
||||
Helper.LogCommand(caller, commandName);
|
||||
|
||||
string msg = $"Added '{flags}' flags to '{name}' ({steamid})";
|
||||
if (command != null)
|
||||
@@ -171,12 +167,6 @@ namespace CS2_SimpleAdmin
|
||||
return;
|
||||
}
|
||||
|
||||
if (_discordWebhookClientLog != null && _localizer != null)
|
||||
{
|
||||
string communityUrl = caller != null ? "<" + new SteamID(caller.SteamID).ToCommunityUrl().ToString() + ">" : "<https://steamcommunity.com/profiles/0>";
|
||||
_discordWebhookClientLog.SendMessageAsync(Helper.GenerateMessageDiscord(_localizer["sa_discord_log_command", $"[{callerName}]({communityUrl})", command.GetCommandString]));
|
||||
}
|
||||
|
||||
string steamid = command.GetArg(1);
|
||||
bool globalDelete = command.GetArg(2).ToLower().Equals("-g");
|
||||
|
||||
@@ -203,7 +193,9 @@ namespace CS2_SimpleAdmin
|
||||
}
|
||||
}, CounterStrikeSharp.API.Modules.Timers.TimerFlags.STOP_ON_MAPCHANGE);
|
||||
|
||||
Helper.LogCommand(caller, $"css_deladmin {steamid}");
|
||||
string commandName = $"css_deladmin {steamid}";
|
||||
Helper.TryLogCommandOnDiscord(caller, commandName);
|
||||
Helper.LogCommand(caller, commandName);
|
||||
|
||||
string msg = $"Removed flags from '{steamid}'";
|
||||
if (command != null)
|
||||
@@ -221,15 +213,18 @@ namespace CS2_SimpleAdmin
|
||||
{
|
||||
if (_database == null) return;
|
||||
|
||||
ReloadAdmins();
|
||||
ReloadAdmins(caller);
|
||||
|
||||
command.ReplyToCommand("Reloaded sql admins");
|
||||
}
|
||||
|
||||
public void ReloadAdmins()
|
||||
public void ReloadAdmins(CCSPlayerController? caller)
|
||||
{
|
||||
if (_database == null) return;
|
||||
|
||||
|
||||
string commandName = "css_reladmin";
|
||||
Helper.TryLogCommandOnDiscord(caller, commandName);
|
||||
|
||||
foreach (SteamID steamId in AdminSQLManager._adminCache.Keys.ToList())
|
||||
{
|
||||
if (AdminSQLManager._adminCache.TryRemove(steamId, out _))
|
||||
@@ -397,12 +392,6 @@ namespace CS2_SimpleAdmin
|
||||
return;
|
||||
}
|
||||
|
||||
if (_discordWebhookClientLog != null && _localizer != null)
|
||||
{
|
||||
string communityUrl = caller != null ? "<" + new SteamID(caller.SteamID).ToCommunityUrl().ToString() + ">" : "<https://steamcommunity.com/profiles/0>";
|
||||
_discordWebhookClientLog.SendMessageAsync(Helper.GenerateMessageDiscord(_localizer["sa_discord_log_command", $"[{callerName}]({communityUrl})", command.GetCommandString]));
|
||||
}
|
||||
|
||||
if (command.ArgCount >= 2 && command.GetArg(2).Length > 0)
|
||||
reason = command.GetArg(2);
|
||||
|
||||
@@ -427,8 +416,10 @@ namespace CS2_SimpleAdmin
|
||||
}
|
||||
|
||||
reason = reason ?? CS2_SimpleAdmin._localizer?["sa_unknown"] ?? "Unknown";
|
||||
|
||||
Helper.LogCommand(caller, $"css_kick {player.PlayerName} {reason}");
|
||||
|
||||
string commandName = $"css_kick {player.PlayerName} {reason}";
|
||||
Helper.LogCommand(caller, commandName);
|
||||
Helper.TryLogCommandOnDiscord(caller, commandName);
|
||||
|
||||
if (string.IsNullOrEmpty(reason) == false)
|
||||
{
|
||||
@@ -488,12 +479,8 @@ namespace CS2_SimpleAdmin
|
||||
_command = $"ds_workshop_changelevel {map.Replace("ws:", "")}";
|
||||
}
|
||||
|
||||
if (_discordWebhookClientLog != null && _localizer != null)
|
||||
{
|
||||
string communityUrl = caller != null ? "<" + new SteamID(caller.SteamID).ToCommunityUrl().ToString() + ">" : "<https://steamcommunity.com/profiles/0>";
|
||||
string commandName = command?.GetCommandString ?? "css_changemap";
|
||||
_discordWebhookClientLog.SendMessageAsync(Helper.GenerateMessageDiscord(_localizer["sa_discord_log_command", $"[{callerName}]({communityUrl})", commandName]));
|
||||
}
|
||||
string commandName = command?.GetCommandString ?? $"css_changewsmap {map}";
|
||||
Helper.TryLogCommandOnDiscord(caller, commandName);
|
||||
if (command is not null)
|
||||
Helper.LogCommand(caller, command);
|
||||
|
||||
@@ -532,6 +519,9 @@ namespace CS2_SimpleAdmin
|
||||
|
||||
if (!map.StartsWith("ws:"))
|
||||
{
|
||||
string commandName = command?.GetCommandString ?? $"css_changemap {map}";
|
||||
Helper.TryLogCommandOnDiscord(caller, commandName);
|
||||
|
||||
AddTimer(2.0f, () =>
|
||||
{
|
||||
Server.ExecuteCommand($"changelevel {map}");
|
||||
@@ -578,13 +568,9 @@ namespace CS2_SimpleAdmin
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (_discordWebhookClientLog != null && _localizer != null)
|
||||
{
|
||||
string communityUrl = caller != null ? "<" + new SteamID(caller.SteamID).ToCommunityUrl().ToString() + ">" : "<https://steamcommunity.com/profiles/0>";
|
||||
string commandName = command?.GetCommandString ?? "css_changewsmap";
|
||||
_discordWebhookClientLog.SendMessageAsync(Helper.GenerateMessageDiscord(_localizer["sa_discord_log_command", $"[{callerName}]({communityUrl})", commandName]));
|
||||
}
|
||||
|
||||
string commandName = command?.GetCommandString ?? $"css_changewsmap {map}";
|
||||
Helper.TryLogCommandOnDiscord(caller, commandName);
|
||||
if (command is not null)
|
||||
Helper.LogCommand(caller, command);
|
||||
|
||||
@@ -663,10 +649,13 @@ namespace CS2_SimpleAdmin
|
||||
|
||||
public static void RestartGame(CCSPlayerController? admin)
|
||||
{
|
||||
Helper.LogCommand(admin, "css_restartgame");
|
||||
|
||||
// TODO: Localize
|
||||
var name = admin == null ? "Console" : admin.PlayerName;
|
||||
string name = admin == null ? "Console" : admin.PlayerName;
|
||||
|
||||
string commandName = "css_restartgame";
|
||||
Helper.TryLogCommandOnDiscord(admin, commandName);
|
||||
Helper.LogCommand(admin, commandName);
|
||||
|
||||
Server.PrintToChatAll($"[SA] {name}: Restarting game...");
|
||||
Server.ExecuteCommand("mp_restartgame 2");
|
||||
}
|
||||
|
||||
@@ -32,12 +32,6 @@ namespace CS2_SimpleAdmin
|
||||
return;
|
||||
}
|
||||
|
||||
if (_discordWebhookClientLog != null && _localizer != null)
|
||||
{
|
||||
string communityUrl = caller != null ? "<" + new SteamID(caller.SteamID).ToCommunityUrl().ToString() + ">" : "<https://steamcommunity.com/profiles/0>";
|
||||
_discordWebhookClientLog.SendMessageAsync(Helper.GenerateMessageDiscord(_localizer["sa_discord_log_command", $"[{callerName}]({communityUrl})", command.GetCommandString]));
|
||||
}
|
||||
|
||||
int.TryParse(command.GetArg(2), out time);
|
||||
|
||||
if (command.ArgCount >= 3 && command.GetArg(3).Length > 0)
|
||||
@@ -75,8 +69,10 @@ namespace CS2_SimpleAdmin
|
||||
Name = caller?.PlayerName,
|
||||
IpAddress = caller?.IpAddress?.Split(":")[0]
|
||||
};
|
||||
|
||||
Helper.LogCommand(caller, $"css_gag {player?.SteamID} {time} {reason}");
|
||||
|
||||
string commandName = $"css_gag {player?.SteamID} {time} {reason}";
|
||||
Helper.LogCommand(caller, commandName);
|
||||
Helper.TryLogCommandOnDiscord(caller, commandName);
|
||||
|
||||
Task.Run(async () =>
|
||||
{
|
||||
@@ -387,12 +383,6 @@ namespace CS2_SimpleAdmin
|
||||
return;
|
||||
}
|
||||
|
||||
if (_discordWebhookClientLog != null && _localizer != null)
|
||||
{
|
||||
string communityUrl = caller != null ? "<" + new SteamID(caller.SteamID).ToCommunityUrl().ToString() + ">" : "<https://steamcommunity.com/profiles/0>";
|
||||
_discordWebhookClientLog.SendMessageAsync(Helper.GenerateMessageDiscord(_localizer["sa_discord_log_command", $"[{callerName}]({communityUrl})", command.GetCommandString]));
|
||||
}
|
||||
|
||||
int.TryParse(command.GetArg(2), out time);
|
||||
|
||||
if (command.ArgCount >= 3 && command.GetArg(3).Length > 0)
|
||||
@@ -430,8 +420,10 @@ namespace CS2_SimpleAdmin
|
||||
Name = caller?.PlayerName,
|
||||
IpAddress = caller?.IpAddress?.Split(":")[0]
|
||||
};
|
||||
|
||||
Helper.LogCommand(caller, $"css_mute {player?.SteamID} {time} {reason}");
|
||||
|
||||
string commandName = $"css_mute {player?.SteamID} {time} {reason}";
|
||||
Helper.LogCommand(caller, commandName);
|
||||
Helper.TryLogCommandOnDiscord(caller, commandName);
|
||||
|
||||
player!.VoiceFlags = VoiceFlags.Muted;
|
||||
|
||||
@@ -716,12 +708,6 @@ namespace CS2_SimpleAdmin
|
||||
return;
|
||||
}
|
||||
|
||||
if (_discordWebhookClientLog != null && _localizer != null)
|
||||
{
|
||||
string communityUrl = caller != null ? "<" + new SteamID(caller.SteamID).ToCommunityUrl().ToString() + ">" : "<https://steamcommunity.com/profiles/0>";
|
||||
_discordWebhookClientLog.SendMessageAsync(Helper.GenerateMessageDiscord(_localizer["sa_discord_log_command", $"[{callerName}]({communityUrl})", command.GetCommandString]));
|
||||
}
|
||||
|
||||
int.TryParse(command.GetArg(2), out time);
|
||||
|
||||
if (command.ArgCount >= 3 && command.GetArg(3).Length > 0)
|
||||
@@ -759,8 +745,10 @@ namespace CS2_SimpleAdmin
|
||||
Name = caller?.PlayerName,
|
||||
IpAddress = caller?.IpAddress?.Split(":")[0]
|
||||
};
|
||||
|
||||
Helper.LogCommand(caller, $"css_silence {player?.SteamID} {time} {reason}");
|
||||
|
||||
string commandName = $"css_silence {player?.SteamID} {time} {reason}";
|
||||
Helper.LogCommand(caller, commandName);
|
||||
Helper.TryLogCommandOnDiscord(caller, commandName);
|
||||
|
||||
Task.Run(async () =>
|
||||
{
|
||||
|
||||
@@ -21,12 +21,6 @@ namespace CS2_SimpleAdmin
|
||||
TargetResult? targets = GetTarget(command);
|
||||
List<CCSPlayerController> playersToTarget = targets!.Players.Where(player => player != null && player.IsValid && player.SteamID.ToString().Length == 17 && player.PawnIsAlive && !player.IsHLTV).ToList();
|
||||
|
||||
if (_discordWebhookClientLog != null && _localizer != null)
|
||||
{
|
||||
string communityUrl = caller != null ? "<" + new SteamID(caller.SteamID).ToCommunityUrl().ToString() + ">" : "<https://steamcommunity.com/profiles/0>";
|
||||
_discordWebhookClientLog.SendMessageAsync(Helper.GenerateMessageDiscord(_localizer["sa_discord_log_command", $"[{callerName}]({communityUrl})", command.GetCommandString]));
|
||||
}
|
||||
|
||||
playersToTarget.ForEach(player =>
|
||||
{
|
||||
if (caller!.CanTarget(player))
|
||||
@@ -41,7 +35,9 @@ namespace CS2_SimpleAdmin
|
||||
callerName ??= caller == null ? "Console" : caller.PlayerName;
|
||||
player!.Pawn.Value!.ToggleNoclip();
|
||||
|
||||
Helper.LogCommand(caller, $"css_noclip {player.PlayerName}");
|
||||
string commandName = $"css_noclip {player.PlayerName}";
|
||||
Helper.TryLogCommandOnDiscord(caller, commandName);
|
||||
Helper.LogCommand(caller, commandName);
|
||||
|
||||
if (caller == null || caller != null && !silentPlayers.Contains(caller.Slot))
|
||||
{
|
||||
@@ -68,12 +64,6 @@ namespace CS2_SimpleAdmin
|
||||
TargetResult? targets = GetTarget(command);
|
||||
List<CCSPlayerController> playersToTarget = targets!.Players.Where(player => player != null && player.IsValid && player.PawnIsAlive && !player.IsHLTV).ToList();
|
||||
|
||||
if (_discordWebhookClientLog != null && _localizer != null)
|
||||
{
|
||||
string communityUrl = caller != null ? "<" + new SteamID(caller.SteamID).ToCommunityUrl().ToString() + ">" : "<https://steamcommunity.com/profiles/0>";
|
||||
_discordWebhookClientLog.SendMessageAsync(Helper.GenerateMessageDiscord(_localizer["sa_discord_log_command", $"[{callerName}]({communityUrl})", command.GetCommandString]));
|
||||
}
|
||||
|
||||
playersToTarget.ForEach(player =>
|
||||
{
|
||||
if (!player.IsBot && player.SteamID.ToString().Length != 17)
|
||||
@@ -92,7 +82,9 @@ namespace CS2_SimpleAdmin
|
||||
|
||||
player.Pawn.Value!.Freeze();
|
||||
|
||||
Helper.LogCommand(caller, $"css_freeze {player.PlayerName}");
|
||||
string commandName = $"css_freeze {player.PlayerName}";
|
||||
Helper.TryLogCommandOnDiscord(caller, commandName);
|
||||
Helper.LogCommand(caller, commandName);
|
||||
|
||||
if (time > 0)
|
||||
AddTimer(time, () => player.Pawn.Value!.Unfreeze(), CounterStrikeSharp.API.Modules.Timers.TimerFlags.STOP_ON_MAPCHANGE);
|
||||
@@ -121,12 +113,6 @@ namespace CS2_SimpleAdmin
|
||||
TargetResult? targets = GetTarget(command);
|
||||
List<CCSPlayerController> playersToTarget = targets!.Players.Where(player => player != null && player.IsValid && player.PawnIsAlive && !player.IsHLTV).ToList();
|
||||
|
||||
if (_discordWebhookClientLog != null && _localizer != null)
|
||||
{
|
||||
string communityUrl = caller != null ? "<" + new SteamID(caller.SteamID).ToCommunityUrl().ToString() + ">" : "<https://steamcommunity.com/profiles/0>";
|
||||
_discordWebhookClientLog.SendMessageAsync(Helper.GenerateMessageDiscord(_localizer["sa_discord_log_command", $"[{callerName}]({communityUrl})", command.GetCommandString]));
|
||||
}
|
||||
|
||||
playersToTarget.ForEach(player =>
|
||||
{
|
||||
if (!player.IsBot && player.SteamID.ToString().Length != 17)
|
||||
@@ -142,7 +128,9 @@ namespace CS2_SimpleAdmin
|
||||
|
||||
player!.Pawn.Value!.Unfreeze();
|
||||
|
||||
Helper.LogCommand(caller, $"css_unfreeze {player.PlayerName}");
|
||||
string commandName = $"css_unfreeze {player.PlayerName}";
|
||||
Helper.TryLogCommandOnDiscord(caller, commandName);
|
||||
Helper.LogCommand(caller, commandName);
|
||||
|
||||
if (caller == null || caller != null && !silentPlayers.Contains(caller.Slot))
|
||||
{
|
||||
|
||||
@@ -23,12 +23,6 @@ namespace CS2_SimpleAdmin
|
||||
TargetResult? targets = GetTarget(command);
|
||||
if (targets == null) return;
|
||||
|
||||
if (_discordWebhookClientLog != null && _localizer != null)
|
||||
{
|
||||
string communityUrl = caller != null ? "<" + new SteamID(caller.SteamID).ToCommunityUrl().ToString() + ">" : "<https://steamcommunity.com/profiles/0>";
|
||||
_discordWebhookClientLog.SendMessageAsync(Helper.GenerateMessageDiscord(_localizer["sa_discord_log_command", $"[{callerName}]({communityUrl})", command.GetCommandString]));
|
||||
}
|
||||
|
||||
List<CCSPlayerController> playersToTarget = targets!.Players.Where(player => player != null && player.IsValid && player.PawnIsAlive && !player.IsHLTV).ToList();
|
||||
|
||||
playersToTarget.ForEach(player =>
|
||||
@@ -46,7 +40,9 @@ namespace CS2_SimpleAdmin
|
||||
|
||||
player.CommitSuicide(false, true);
|
||||
|
||||
Helper.LogCommand(caller, $"css_slay {player.PlayerName}");
|
||||
string commandName = $"css_slay {player.PlayerName}";
|
||||
Helper.LogCommand(caller, commandName);
|
||||
Helper.TryLogCommandOnDiscord(caller, commandName);
|
||||
|
||||
if (caller == null || caller != null && !silentPlayers.Contains(caller.Slot))
|
||||
{
|
||||
@@ -98,12 +94,6 @@ namespace CS2_SimpleAdmin
|
||||
}
|
||||
}
|
||||
|
||||
if (_discordWebhookClientLog != null && _localizer != null)
|
||||
{
|
||||
string communityUrl = caller != null ? "<" + new SteamID(caller.SteamID).ToCommunityUrl().ToString() + ">" : "<https://steamcommunity.com/profiles/0>";
|
||||
_discordWebhookClientLog.SendMessageAsync(Helper.GenerateMessageDiscord(_localizer["sa_discord_log_command", $"[{callerName}]({communityUrl})", command.GetCommandString]));
|
||||
}
|
||||
|
||||
playersToTarget.ForEach(player =>
|
||||
{
|
||||
if (!player.IsBot && player.SteamID.ToString().Length != 17)
|
||||
@@ -132,7 +122,11 @@ namespace CS2_SimpleAdmin
|
||||
public void SubGiveWeapon(CCSPlayerController? caller, CCSPlayerController player, string weaponName, string? callerName = null)
|
||||
{
|
||||
callerName ??= caller == null ? "Console" : caller.PlayerName;
|
||||
|
||||
|
||||
string commandName = $"css_give {player.PlayerName} {weaponName}";
|
||||
Helper.TryLogCommandOnDiscord(caller, commandName);
|
||||
Helper.LogCommand(caller, commandName);
|
||||
|
||||
if (caller == null || caller != null && !silentPlayers.Contains(caller.Slot))
|
||||
{
|
||||
foreach (CCSPlayerController _player in Helper.GetValidPlayers())
|
||||
@@ -156,12 +150,6 @@ namespace CS2_SimpleAdmin
|
||||
TargetResult? targets = GetTarget(command);
|
||||
if (targets == null) return;
|
||||
|
||||
if (_discordWebhookClientLog != null && _localizer != null)
|
||||
{
|
||||
string communityUrl = caller != null ? "<" + new SteamID(caller.SteamID).ToCommunityUrl().ToString() + ">" : "<https://steamcommunity.com/profiles/0>";
|
||||
_discordWebhookClientLog.SendMessageAsync(Helper.GenerateMessageDiscord(_localizer["sa_discord_log_command", $"[{callerName}]({communityUrl})", command.GetCommandString]));
|
||||
}
|
||||
|
||||
List<CCSPlayerController> playersToTarget = targets!.Players.Where(player => player != null && player.IsValid && player.PawnIsAlive && !player.IsHLTV).ToList();
|
||||
|
||||
playersToTarget.ForEach(player =>
|
||||
@@ -182,7 +170,9 @@ namespace CS2_SimpleAdmin
|
||||
|
||||
player.RemoveWeapons();
|
||||
|
||||
Helper.LogCommand(caller, $"css_strip {player.PlayerName}");
|
||||
string commandName = $"css_strip {player.PlayerName}";
|
||||
Helper.TryLogCommandOnDiscord(caller, commandName);
|
||||
Helper.LogCommand(caller, commandName);
|
||||
|
||||
if (caller == null || caller != null && !silentPlayers.Contains(caller.Slot))
|
||||
{
|
||||
@@ -210,12 +200,6 @@ namespace CS2_SimpleAdmin
|
||||
TargetResult? targets = GetTarget(command);
|
||||
if (targets == null) return;
|
||||
|
||||
if (_discordWebhookClientLog != null && _localizer != null)
|
||||
{
|
||||
string communityUrl = caller != null ? "<" + new SteamID(caller.SteamID).ToCommunityUrl().ToString() + ">" : "<https://steamcommunity.com/profiles/0>";
|
||||
_discordWebhookClientLog.SendMessageAsync(Helper.GenerateMessageDiscord(_localizer["sa_discord_log_command", $"[{callerName}]({communityUrl})", command.GetCommandString]));
|
||||
}
|
||||
|
||||
List<CCSPlayerController> playersToTarget = targets!.Players.Where(player => player != null && player.IsValid && player.PawnIsAlive && !player.IsHLTV).ToList();
|
||||
|
||||
playersToTarget.ForEach(player =>
|
||||
@@ -236,7 +220,9 @@ namespace CS2_SimpleAdmin
|
||||
|
||||
player.SetHp(health);
|
||||
|
||||
Helper.LogCommand(caller, $"css_hp {player.PlayerName} {health}");
|
||||
string commandName = $"css_hp {player.PlayerName} {health}";
|
||||
Helper.TryLogCommandOnDiscord(caller, commandName);
|
||||
Helper.LogCommand(caller, commandName);
|
||||
|
||||
if (caller == null || caller != null && !silentPlayers.Contains(caller.Slot))
|
||||
{
|
||||
@@ -264,12 +250,6 @@ namespace CS2_SimpleAdmin
|
||||
TargetResult? targets = GetTarget(command);
|
||||
if (targets == null) return;
|
||||
|
||||
if (_discordWebhookClientLog != null && _localizer != null)
|
||||
{
|
||||
string communityUrl = caller != null ? "<" + new SteamID(caller.SteamID).ToCommunityUrl().ToString() + ">" : "<https://steamcommunity.com/profiles/0>";
|
||||
_discordWebhookClientLog.SendMessageAsync(Helper.GenerateMessageDiscord(_localizer["sa_discord_log_command", $"[{callerName}]({communityUrl})", command.GetCommandString]));
|
||||
}
|
||||
|
||||
List<CCSPlayerController> playersToTarget = targets!.Players.Where(player => player != null && player.IsValid && player.PawnIsAlive && !player.IsHLTV).ToList();
|
||||
|
||||
playersToTarget.ForEach(player =>
|
||||
@@ -290,7 +270,9 @@ namespace CS2_SimpleAdmin
|
||||
|
||||
player.SetSpeed((float)speed);
|
||||
|
||||
Helper.LogCommand(caller, $"css_speed {player?.PlayerName} {speed}");
|
||||
string commandName = $"css_speed {player?.PlayerName} {speed}";
|
||||
Helper.TryLogCommandOnDiscord(caller, commandName);
|
||||
Helper.LogCommand(caller, commandName);
|
||||
|
||||
if (caller == null || caller != null && !silentPlayers.Contains(caller.Slot))
|
||||
{
|
||||
@@ -318,12 +300,6 @@ namespace CS2_SimpleAdmin
|
||||
TargetResult? targets = GetTarget(command);
|
||||
if (targets == null) return;
|
||||
|
||||
if (_discordWebhookClientLog != null && _localizer != null)
|
||||
{
|
||||
string communityUrl = caller != null ? "<" + new SteamID(caller.SteamID).ToCommunityUrl().ToString() + ">" : "<https://steamcommunity.com/profiles/0>";
|
||||
_discordWebhookClientLog.SendMessageAsync(Helper.GenerateMessageDiscord(_localizer["sa_discord_log_command", $"[{callerName}]({communityUrl})", command.GetCommandString]));
|
||||
}
|
||||
|
||||
List<CCSPlayerController> playersToTarget = targets!.Players.Where(player => player != null && player.IsValid && player.PawnIsAlive && !player.IsHLTV).ToList();
|
||||
|
||||
playersToTarget.ForEach(player =>
|
||||
@@ -344,7 +320,9 @@ namespace CS2_SimpleAdmin
|
||||
|
||||
player.SetGravity((float)gravity);
|
||||
|
||||
Helper.LogCommand(caller, $"css_gravity {player?.PlayerName} {gravity}");
|
||||
string commandName = $"css_gravity {player?.PlayerName} {gravity}";
|
||||
Helper.TryLogCommandOnDiscord(caller, commandName);
|
||||
Helper.LogCommand(caller, commandName);
|
||||
|
||||
if (caller == null || caller != null && !silentPlayers.Contains(caller.Slot))
|
||||
{
|
||||
@@ -372,12 +350,6 @@ namespace CS2_SimpleAdmin
|
||||
TargetResult? targets = GetTarget(command);
|
||||
if (targets == null) return;
|
||||
|
||||
if (_discordWebhookClientLog != null && _localizer != null)
|
||||
{
|
||||
string communityUrl = caller != null ? "<" + new SteamID(caller.SteamID).ToCommunityUrl().ToString() + ">" : "<https://steamcommunity.com/profiles/0>";
|
||||
_discordWebhookClientLog.SendMessageAsync(Helper.GenerateMessageDiscord(_localizer["sa_discord_log_command", $"[{callerName}]({communityUrl})", command.GetCommandString]));
|
||||
}
|
||||
|
||||
List<CCSPlayerController> playersToTarget = targets!.Players.Where(player => player != null && player.IsValid && player.PawnIsAlive && !player.IsHLTV).ToList();
|
||||
|
||||
playersToTarget.ForEach(player =>
|
||||
@@ -398,7 +370,9 @@ namespace CS2_SimpleAdmin
|
||||
|
||||
player.SetMoney(money);
|
||||
|
||||
Helper.LogCommand(caller, $"css_money {player?.PlayerName} {money}");
|
||||
string commandName = $"css_money {player?.PlayerName} {money}";
|
||||
Helper.TryLogCommandOnDiscord(caller, commandName);
|
||||
Helper.LogCommand(caller, commandName);
|
||||
|
||||
if (caller == null || caller != null && !silentPlayers.Contains(caller.Slot))
|
||||
{
|
||||
@@ -423,12 +397,6 @@ namespace CS2_SimpleAdmin
|
||||
TargetResult? targets = GetTarget(command);
|
||||
if (targets == null) return;
|
||||
|
||||
if (_discordWebhookClientLog != null && _localizer != null)
|
||||
{
|
||||
string communityUrl = caller != null ? "<" + new SteamID(caller.SteamID).ToCommunityUrl().ToString() + ">" : "<https://steamcommunity.com/profiles/0>";
|
||||
_discordWebhookClientLog.SendMessageAsync(Helper.GenerateMessageDiscord(_localizer["sa_discord_log_command", $"[{callerName}]({communityUrl})", command.GetCommandString]));
|
||||
}
|
||||
|
||||
List<CCSPlayerController> playersToTarget = targets!.Players.Where(player => player != null && player.IsValid && player.PawnIsAlive && !player.IsHLTV).ToList();
|
||||
|
||||
playersToTarget.ForEach(player =>
|
||||
@@ -447,29 +415,31 @@ namespace CS2_SimpleAdmin
|
||||
{
|
||||
callerName ??= caller == null ? "Console" : caller.PlayerName;
|
||||
|
||||
if (player != null)
|
||||
if (player == null || player.IsValid == false)
|
||||
return;
|
||||
|
||||
string commandName = $"css_god {player.PlayerName}";
|
||||
Helper.TryLogCommandOnDiscord(caller, commandName);
|
||||
Helper.LogCommand(caller, callerName);
|
||||
|
||||
if (!godPlayers.Contains(player.Slot))
|
||||
{
|
||||
Helper.LogCommand(caller, $"css_god {player.PlayerName}");
|
||||
godPlayers.Add(player.Slot);
|
||||
}
|
||||
else
|
||||
{
|
||||
RemoveFromConcurrentBag(godPlayers, player.Slot);
|
||||
}
|
||||
|
||||
if (!godPlayers.Contains(player.Slot))
|
||||
if (caller == null || !silentPlayers.Contains(caller.Slot))
|
||||
{
|
||||
foreach (CCSPlayerController _player in Helper.GetValidPlayers())
|
||||
{
|
||||
godPlayers.Add(player.Slot);
|
||||
}
|
||||
else
|
||||
{
|
||||
RemoveFromConcurrentBag(godPlayers, player.Slot);
|
||||
}
|
||||
|
||||
if (caller == null || caller != null && !silentPlayers.Contains(caller.Slot))
|
||||
{
|
||||
foreach (CCSPlayerController _player in Helper.GetValidPlayers())
|
||||
using (new WithTemporaryCulture(_player.GetLanguage()))
|
||||
{
|
||||
using (new WithTemporaryCulture(_player.GetLanguage()))
|
||||
{
|
||||
StringBuilder sb = new(_localizer!["sa_prefix"]);
|
||||
sb.Append(_localizer["sa_admin_god_message", callerName, player.PlayerName]);
|
||||
_player.PrintToChat(sb.ToString());
|
||||
}
|
||||
StringBuilder sb = new(_localizer!["sa_prefix"]);
|
||||
sb.Append(_localizer["sa_admin_god_message", callerName, player.PlayerName]);
|
||||
_player.PrintToChat(sb.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -486,12 +456,6 @@ namespace CS2_SimpleAdmin
|
||||
TargetResult? targets = GetTarget(command);
|
||||
if (targets == null) return;
|
||||
|
||||
if (_discordWebhookClientLog != null && _localizer != null)
|
||||
{
|
||||
string communityUrl = caller != null ? "<" + new SteamID(caller.SteamID).ToCommunityUrl().ToString() + ">" : "<https://steamcommunity.com/profiles/0>";
|
||||
_discordWebhookClientLog.SendMessageAsync(Helper.GenerateMessageDiscord(_localizer["sa_discord_log_command", $"[{callerName}]({communityUrl})", command.GetCommandString]));
|
||||
}
|
||||
|
||||
List<CCSPlayerController> playersToTarget = targets!.Players.Where(player => player != null && player.IsValid && player.PawnIsAlive && !player.IsHLTV).ToList();
|
||||
|
||||
if (command.ArgCount >= 2)
|
||||
@@ -516,7 +480,9 @@ namespace CS2_SimpleAdmin
|
||||
callerName ??= caller == null ? "Console" : caller.PlayerName;
|
||||
player!.Pawn.Value!.Slap(damage);
|
||||
|
||||
Helper.LogCommand(caller, $"css_slap {player.PlayerName} {damage}");
|
||||
string commandName = $"css_slap {player.PlayerName} {damage}";
|
||||
Helper.LogCommand(caller, callerName);
|
||||
Helper.TryLogCommandOnDiscord(caller, commandName);
|
||||
|
||||
if (caller == null || caller != null && !silentPlayers.Contains(caller.Slot))
|
||||
{
|
||||
@@ -545,12 +511,6 @@ namespace CS2_SimpleAdmin
|
||||
TargetResult? targets = GetTarget(command);
|
||||
if (targets == null) return;
|
||||
|
||||
if (_discordWebhookClientLog != null && _localizer != null)
|
||||
{
|
||||
string communityUrl = caller != null ? "<" + new SteamID(caller.SteamID).ToCommunityUrl().ToString() + ">" : "<https://steamcommunity.com/profiles/0>";
|
||||
_discordWebhookClientLog.SendMessageAsync(Helper.GenerateMessageDiscord(_localizer["sa_discord_log_command", $"[{callerName}]({communityUrl})", command.GetCommandString]));
|
||||
}
|
||||
|
||||
List<CCSPlayerController> playersToTarget = targets!.Players.Where(player => player != null && player.IsValid && !player.IsHLTV).ToList();
|
||||
|
||||
switch (teamName)
|
||||
@@ -594,6 +554,9 @@ namespace CS2_SimpleAdmin
|
||||
return;
|
||||
|
||||
callerName ??= caller == null ? "Console" : caller.PlayerName;
|
||||
string commandName = $"css_team {player.PlayerName} {teamName} {teamNum} {kill}";
|
||||
Helper.LogCommand(caller, commandName);
|
||||
Helper.TryLogCommandOnDiscord(caller, commandName);
|
||||
|
||||
if (!teamName.Equals("swap"))
|
||||
{
|
||||
@@ -691,12 +654,6 @@ namespace CS2_SimpleAdmin
|
||||
TargetResult? targets = GetTarget(command);
|
||||
List<CCSPlayerController> playersToTarget = targets!.Players.Where(player => player != null && player.IsValid && !player.IsHLTV).ToList();
|
||||
|
||||
if (_discordWebhookClientLog != null && _localizer != null)
|
||||
{
|
||||
string communityUrl = caller != null ? "<" + new SteamID(caller.SteamID).ToCommunityUrl().ToString() + ">" : "<https://steamcommunity.com/profiles/0>";
|
||||
_discordWebhookClientLog.SendMessageAsync(Helper.GenerateMessageDiscord(_localizer["sa_discord_log_command", $"[{callerName}]({communityUrl})", command.GetCommandString]));
|
||||
}
|
||||
|
||||
playersToTarget.ForEach(player =>
|
||||
{
|
||||
if (!player.IsBot && player.SteamID.ToString().Length != 17)
|
||||
@@ -715,12 +672,14 @@ namespace CS2_SimpleAdmin
|
||||
|
||||
if (CBasePlayerController_SetPawnFunc == null || player.PlayerPawn.Value == null || !player.PlayerPawn.IsValid) return;
|
||||
|
||||
var playerPawn = player.PlayerPawn.Value;
|
||||
CCSPlayerPawn? playerPawn = player.PlayerPawn.Value;
|
||||
CBasePlayerController_SetPawnFunc.Invoke(player, playerPawn, true, false);
|
||||
VirtualFunction.CreateVoid<CCSPlayerController>(player.Handle,
|
||||
GameData.GetOffset("CCSPlayerController_Respawn"))(player);
|
||||
|
||||
Helper.LogCommand(caller, $"css_respawn {player.PlayerName}");
|
||||
string commandName = $"css_respawn {player.PlayerName}";
|
||||
Helper.TryLogCommandOnDiscord(caller, commandName);
|
||||
Helper.LogCommand(caller, commandName);
|
||||
|
||||
if (caller == null || caller != null && !silentPlayers.Contains(caller.Slot))
|
||||
{
|
||||
|
||||
@@ -22,6 +22,9 @@ namespace CS2_SimpleAdmin
|
||||
|
||||
[JsonPropertyName("Command")]
|
||||
public string Command { get; set; } = "";
|
||||
|
||||
[JsonPropertyName("ExecuteOnClient")]
|
||||
public bool ExecuteOnClient { get; set; } = false;
|
||||
}
|
||||
|
||||
public class CS2_SimpleAdminConfig : BasePluginConfig
|
||||
|
||||
13
Helper.cs
13
Helper.cs
@@ -223,6 +223,19 @@ namespace CS2_SimpleAdmin
|
||||
var updatedJsonContent = JsonSerializer.Serialize(config, new JsonSerializerOptions { WriteIndented = true, Encoder = System.Text.Encodings.Web.JavaScriptEncoder.UnsafeRelaxedJsonEscaping });
|
||||
File.WriteAllText(CfgPath, updatedJsonContent);
|
||||
}
|
||||
|
||||
public static void TryLogCommandOnDiscord(CCSPlayerController? caller, string commandString)
|
||||
{
|
||||
if (CS2_SimpleAdmin._discordWebhookClientLog == null || CS2_SimpleAdmin._localizer == null)
|
||||
return;
|
||||
|
||||
if (caller != null && caller.IsValid == false)
|
||||
caller = null;
|
||||
|
||||
string callerName = caller == null ? "Console" : caller.PlayerName;
|
||||
string communityUrl = caller != null ? "<" + new SteamID(caller.SteamID).ToCommunityUrl().ToString() + ">" : "<https://steamcommunity.com/profiles/0>";
|
||||
CS2_SimpleAdmin._discordWebhookClientLog.SendMessageAsync(GenerateMessageDiscord(CS2_SimpleAdmin._localizer["sa_discord_log_command", $"[{callerName}]({communityUrl})", commandString]));
|
||||
}
|
||||
}
|
||||
|
||||
public class SchemaString<SchemaClass> : NativeObject where SchemaClass : NativeObject
|
||||
|
||||
@@ -44,6 +44,12 @@ namespace CS2_SimpleAdmin.Menus
|
||||
new ChatMenuOptionData("Manage Server", () => ManageServerMenu.OpenMenu(admin)),
|
||||
new ChatMenuOptionData("Fun actions", () => FunActionsMenu.OpenMenu(admin)),
|
||||
};
|
||||
|
||||
List<CustomServerCommandData> customCommands = CS2_SimpleAdmin.Instance.Config.CustomServerCommands;
|
||||
if (customCommands.Count > 0)
|
||||
{
|
||||
options.Add(new ChatMenuOptionData("Custom Commands", () => CustomCommandsMenu.OpenMenu(admin)));
|
||||
}
|
||||
|
||||
if (AdminManager.PlayerHasPermissions(admin, "@css/root"))
|
||||
options.Add(new ChatMenuOptionData("Manage Admins", () => ManageAdminsMenu.OpenMenu(admin)));
|
||||
|
||||
55
Menus/CustomCommandsMenu.cs
Normal file
55
Menus/CustomCommandsMenu.cs
Normal file
@@ -0,0 +1,55 @@
|
||||
using CounterStrikeSharp.API;
|
||||
using CounterStrikeSharp.API.Core;
|
||||
using CounterStrikeSharp.API.Modules.Admin;
|
||||
using CounterStrikeSharp.API.Modules.Menu;
|
||||
|
||||
namespace CS2_SimpleAdmin.Menus
|
||||
{
|
||||
public static class CustomCommandsMenu
|
||||
{
|
||||
public static void OpenMenu(CCSPlayerController admin)
|
||||
{
|
||||
if (admin == null || admin.IsValid == false)
|
||||
return;
|
||||
|
||||
if (AdminManager.PlayerHasPermissions(admin, "@css/generic") == false)
|
||||
{
|
||||
// TODO: Localize
|
||||
admin.PrintToChat("[Simple Admin] You do not have permissions to use this command.");
|
||||
return;
|
||||
}
|
||||
|
||||
BaseMenu menu = AdminMenu.CreateMenu("Custom Commands");
|
||||
List<ChatMenuOptionData> options = new();
|
||||
|
||||
List<CustomServerCommandData> customCommands = CS2_SimpleAdmin.Instance.Config.CustomServerCommands;
|
||||
foreach (CustomServerCommandData customCommand in customCommands)
|
||||
{
|
||||
if (string.IsNullOrEmpty(customCommand.DisplayName) || string.IsNullOrEmpty(customCommand.Command))
|
||||
continue;
|
||||
|
||||
bool hasRights = AdminManager.PlayerHasPermissions(admin, customCommand.Flag);
|
||||
if (!hasRights)
|
||||
continue;
|
||||
|
||||
options.Add(new ChatMenuOptionData(customCommand.DisplayName, () =>
|
||||
{
|
||||
Helper.TryLogCommandOnDiscord(admin, customCommand.Command);
|
||||
|
||||
if (customCommand.ExecuteOnClient)
|
||||
admin.ExecuteClientCommand(customCommand.Command);
|
||||
else
|
||||
Server.ExecuteCommand(customCommand.Command);
|
||||
}));
|
||||
}
|
||||
|
||||
foreach (ChatMenuOptionData menuOptionData in options)
|
||||
{
|
||||
string menuName = menuOptionData.name;
|
||||
menu.AddMenuOption(menuName, (_, _) => { menuOptionData.action?.Invoke(); }, menuOptionData.disabled);
|
||||
}
|
||||
|
||||
AdminMenu.OpenMenu(admin, menu);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -21,7 +21,8 @@ namespace CS2_SimpleAdmin.Menus
|
||||
_weaponsCache = new();
|
||||
foreach (CsItem item in weaponsArray)
|
||||
{
|
||||
if (item == CsItem.Tablet) continue;
|
||||
if (item == CsItem.Tablet)
|
||||
continue;
|
||||
|
||||
_weaponsCache[(int)item] = item;
|
||||
}
|
||||
@@ -57,7 +58,7 @@ namespace CS2_SimpleAdmin.Menus
|
||||
{
|
||||
options.Add(new ChatMenuOptionData("God Mode", () => PlayersMenu.OpenAliveMenu(admin, "God Mode", GodMode)));
|
||||
options.Add(new ChatMenuOptionData("No Clip", () => PlayersMenu.OpenAliveMenu(admin, "No Clip", NoClip)));
|
||||
options.Add(new ChatMenuOptionData("Respawn", () => PlayersMenu.OpenAliveMenu(admin, "Respawn", Respawn)));
|
||||
options.Add(new ChatMenuOptionData("Respawn", () => PlayersMenu.OpenDeadMenu(admin, "Respawn", Respawn)));
|
||||
options.Add(new ChatMenuOptionData("Give Weapon", () => PlayersMenu.OpenAliveMenu(admin, "Give Weapon", GiveWeaponMenu)));
|
||||
}
|
||||
|
||||
@@ -67,6 +68,8 @@ namespace CS2_SimpleAdmin.Menus
|
||||
options.Add(new ChatMenuOptionData("Freeze", () => PlayersMenu.OpenAliveMenu(admin, "Freeze", Freeze)));
|
||||
options.Add(new ChatMenuOptionData("HP", () => PlayersMenu.OpenAliveMenu(admin, "HP", SetHpMenu)));
|
||||
options.Add(new ChatMenuOptionData("Speed", () => PlayersMenu.OpenAliveMenu(admin, "Speed", SetSpeedMenu)));
|
||||
options.Add(new ChatMenuOptionData("Gravity", () => PlayersMenu.OpenAliveMenu(admin, "Gravity", SetGravityMenu)));
|
||||
options.Add(new ChatMenuOptionData("Set Money", () => PlayersMenu.OpenMenu(admin, "Set Money", SetMoneyMenu)));
|
||||
}
|
||||
|
||||
foreach (ChatMenuOptionData menuOptionData in options)
|
||||
@@ -117,7 +120,8 @@ namespace CS2_SimpleAdmin.Menus
|
||||
|
||||
private static void Freeze(CCSPlayerController admin, CCSPlayerController player)
|
||||
{
|
||||
if (!(player.PlayerPawn?.Value?.IsValid ?? false)) return;
|
||||
if (!(player.PlayerPawn?.Value?.IsValid ?? false))
|
||||
return;
|
||||
|
||||
if (player.PlayerPawn.Value.MoveType != MoveType_t.MOVETYPE_OBSOLETE)
|
||||
CS2_SimpleAdmin.Instance.Freeze(admin, player, -1);
|
||||
@@ -184,5 +188,61 @@ namespace CS2_SimpleAdmin.Menus
|
||||
{
|
||||
CS2_SimpleAdmin.Instance.SetSpeed(admin, player, speed);
|
||||
}
|
||||
|
||||
private static void SetGravityMenu(CCSPlayerController admin, CCSPlayerController player)
|
||||
{
|
||||
Tuple<string, float>[] _gravityArray = new[]
|
||||
{
|
||||
new Tuple<string, float>("0.1", .1f),
|
||||
new Tuple<string, float>("0.25", .25f),
|
||||
new Tuple<string, float>("0.5", .5f),
|
||||
new Tuple<string, float>("0.75", .75f),
|
||||
new Tuple<string, float>("1", 1),
|
||||
new Tuple<string, float>("2", 2)
|
||||
};
|
||||
|
||||
BaseMenu menu = AdminMenu.CreateMenu($"Set Gravity: {player.PlayerName}");
|
||||
|
||||
foreach (Tuple<string, float> gravityTuple in _gravityArray)
|
||||
{
|
||||
string optionName = gravityTuple.Item1;
|
||||
menu.AddMenuOption(optionName, (_, _) => { SetGravity(admin, player, gravityTuple.Item2); });
|
||||
}
|
||||
|
||||
AdminMenu.OpenMenu(admin, menu);
|
||||
}
|
||||
|
||||
private static void SetGravity(CCSPlayerController admin, CCSPlayerController player, float gravity)
|
||||
{
|
||||
CS2_SimpleAdmin.Instance.SetGravity(admin, player, gravity);
|
||||
}
|
||||
|
||||
private static void SetMoneyMenu(CCSPlayerController admin, CCSPlayerController player)
|
||||
{
|
||||
Tuple<string, int>[] _moneyArray = new[]
|
||||
{
|
||||
new Tuple<string, int>("$0", 0),
|
||||
new Tuple<string, int>("$1000", 1000),
|
||||
new Tuple<string, int>("$2500", 2500),
|
||||
new Tuple<string, int>("$5000", 5000),
|
||||
new Tuple<string, int>("$10000", 10000),
|
||||
new Tuple<string, int>("$16000", 16000)
|
||||
};
|
||||
|
||||
BaseMenu menu = AdminMenu.CreateMenu($"Set Money: {player.PlayerName}");
|
||||
|
||||
foreach (Tuple<string, int> moneyTuple in _moneyArray)
|
||||
{
|
||||
string optionName = moneyTuple.Item1;
|
||||
menu.AddMenuOption(optionName, (_, _) => { SetMoney(admin, player, moneyTuple.Item2); });
|
||||
}
|
||||
|
||||
AdminMenu.OpenMenu(admin, menu);
|
||||
}
|
||||
|
||||
private static void SetMoney(CCSPlayerController admin, CCSPlayerController player, int money)
|
||||
{
|
||||
CS2_SimpleAdmin.Instance.SetMoney(admin, player, money);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,9 +24,9 @@ namespace CS2_SimpleAdmin.Menus
|
||||
// TODO: Localize options
|
||||
// options added in order
|
||||
|
||||
options.Add(new ChatMenuOptionData("Add Admin", () => PlayersMenu.OpenAliveMenu(admin, "Add Admin", AddAdminMenu)));
|
||||
options.Add(new ChatMenuOptionData("Remove Admin", () => PlayersMenu.OpenAliveMenu(admin, "Remove Admin", RemoveAdmin, player => player != admin && admin.CanTarget(player))));
|
||||
options.Add(new ChatMenuOptionData("Reload Admins", ReloadAdmins));
|
||||
options.Add(new ChatMenuOptionData("Add Admin", () => PlayersMenu.OpenRealPlayersMenu(admin, "Add Admin", AddAdminMenu)));
|
||||
options.Add(new ChatMenuOptionData("Remove Admin", () => PlayersMenu.OpenAdminPlayersMenu(admin, "Remove Admin", RemoveAdmin, player => player != admin && admin.CanTarget(player))));
|
||||
options.Add(new ChatMenuOptionData("Reload Admins", () => ReloadAdmins(admin)));
|
||||
|
||||
foreach (ChatMenuOptionData menuOptionData in options)
|
||||
{
|
||||
@@ -77,9 +77,9 @@ namespace CS2_SimpleAdmin.Menus
|
||||
CS2_SimpleAdmin.Instance.RemoveAdmin(admin, player.SteamID.ToString());
|
||||
}
|
||||
|
||||
private static void ReloadAdmins()
|
||||
private static void ReloadAdmins(CCSPlayerController admin)
|
||||
{
|
||||
CS2_SimpleAdmin.Instance.ReloadAdmins();
|
||||
CS2_SimpleAdmin.Instance.ReloadAdmins(admin);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -44,14 +44,14 @@ namespace CS2_SimpleAdmin.Menus
|
||||
|
||||
if (hasBan)
|
||||
{
|
||||
options.Add(new ChatMenuOptionData("Ban", () => PlayersMenu.OpenMenu(admin, "Ban", (admin, player) => DurationMenu.OpenMenu(admin, $"Ban: {player.PlayerName}", player, BanMenu))));
|
||||
options.Add(new ChatMenuOptionData("Ban", () => PlayersMenu.OpenRealPlayersMenu(admin, "Ban", (admin, player) => DurationMenu.OpenMenu(admin, $"Ban: {player.PlayerName}", player, BanMenu))));
|
||||
}
|
||||
|
||||
if (hasChat)
|
||||
{
|
||||
options.Add(new ChatMenuOptionData("Gag", () => PlayersMenu.OpenMenu(admin, "Gag", (admin, player) => DurationMenu.OpenMenu(admin, $"Gag: {player.PlayerName}", player, GagMenu))));
|
||||
options.Add(new ChatMenuOptionData("Mute", () => PlayersMenu.OpenMenu(admin, "Mute", (admin, player) => DurationMenu.OpenMenu(admin, $"Mute: {player.PlayerName}", player, MuteMenu))));
|
||||
options.Add(new ChatMenuOptionData("Silence", () => PlayersMenu.OpenMenu(admin, "Silence", (admin, player) => DurationMenu.OpenMenu(admin, $"Silence: {player.PlayerName}", player, SilenceMenu))));
|
||||
options.Add(new ChatMenuOptionData("Gag", () => PlayersMenu.OpenRealPlayersMenu(admin, "Gag", (admin, player) => DurationMenu.OpenMenu(admin, $"Gag: {player.PlayerName}", player, GagMenu))));
|
||||
options.Add(new ChatMenuOptionData("Mute", () => PlayersMenu.OpenRealPlayersMenu(admin, "Mute", (admin, player) => DurationMenu.OpenMenu(admin, $"Mute: {player.PlayerName}", player, MuteMenu))));
|
||||
options.Add(new ChatMenuOptionData("Silence", () => PlayersMenu.OpenRealPlayersMenu(admin, "Silence", (admin, player) => DurationMenu.OpenMenu(admin, $"Silence: {player.PlayerName}", player, SilenceMenu))));
|
||||
}
|
||||
|
||||
if (hasKick)
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
using CounterStrikeSharp.API;
|
||||
using CounterStrikeSharp.API.Core;
|
||||
using CounterStrikeSharp.API.Modules.Admin;
|
||||
using CounterStrikeSharp.API.Modules.Menu;
|
||||
@@ -35,19 +34,6 @@ namespace CS2_SimpleAdmin.Menus
|
||||
|
||||
options.Add(new ChatMenuOptionData("Restart Game", () => CS2_SimpleAdmin.RestartGame(admin)));
|
||||
|
||||
List<CustomServerCommandData> customCommands = CS2_SimpleAdmin.Instance.Config.CustomServerCommands;
|
||||
foreach (CustomServerCommandData customCommand in customCommands)
|
||||
{
|
||||
if (string.IsNullOrEmpty(customCommand.DisplayName) || string.IsNullOrEmpty(customCommand.Command))
|
||||
continue;
|
||||
|
||||
bool hasRights = AdminManager.PlayerHasPermissions(admin, customCommand.Flag);
|
||||
if (!hasRights)
|
||||
continue;
|
||||
|
||||
options.Add(new ChatMenuOptionData(customCommand.DisplayName, () => Server.ExecuteCommand(customCommand.Command)));
|
||||
}
|
||||
|
||||
foreach (ChatMenuOptionData menuOptionData in options)
|
||||
{
|
||||
string menuName = menuOptionData.name;
|
||||
|
||||
@@ -1,15 +1,32 @@
|
||||
using System.Web;
|
||||
using CounterStrikeSharp.API.Core;
|
||||
using CounterStrikeSharp.API.Modules.Admin;
|
||||
using CounterStrikeSharp.API.Modules.Menu;
|
||||
|
||||
namespace CS2_SimpleAdmin.Menus
|
||||
{
|
||||
public static class PlayersMenu
|
||||
{
|
||||
public static void OpenRealPlayersMenu(CCSPlayerController admin, string menuName, Action<CCSPlayerController, CCSPlayerController> onSelectAction, Func<CCSPlayerController, bool>? enableFilter = null)
|
||||
{
|
||||
OpenMenu(admin, menuName, onSelectAction, p => p.IsBot == false);
|
||||
}
|
||||
|
||||
public static void OpenAdminPlayersMenu(CCSPlayerController admin, string menuName, Action<CCSPlayerController, CCSPlayerController> onSelectAction, Func<CCSPlayerController, bool>? enableFilter = null)
|
||||
{
|
||||
OpenMenu(admin, menuName, onSelectAction, p => AdminManager.GetPlayerAdminData(p)?.Flags?.Count > 0);
|
||||
}
|
||||
|
||||
public static void OpenAliveMenu(CCSPlayerController admin, string menuName, Action<CCSPlayerController, CCSPlayerController> onSelectAction, Func<CCSPlayerController, bool>? enableFilter = null)
|
||||
{
|
||||
OpenMenu(admin, menuName, onSelectAction, p => p.PawnIsAlive);
|
||||
}
|
||||
|
||||
public static void OpenDeadMenu(CCSPlayerController admin, string menuName, Action<CCSPlayerController, CCSPlayerController> onSelectAction, Func<CCSPlayerController, bool>? enableFilter = null)
|
||||
{
|
||||
OpenMenu(admin, menuName, onSelectAction, p => p.PawnIsAlive == false);
|
||||
}
|
||||
|
||||
public static void OpenMenu(CCSPlayerController admin, string menuName, Action<CCSPlayerController, CCSPlayerController> onSelectAction, Func<CCSPlayerController, bool>? enableFilter = null)
|
||||
{
|
||||
BaseMenu menu = AdminMenu.CreateMenu(menuName);
|
||||
@@ -17,14 +34,15 @@ namespace CS2_SimpleAdmin.Menus
|
||||
IEnumerable<CCSPlayerController> players = Helper.GetValidPlayersWithBots();
|
||||
foreach (CCSPlayerController player in players)
|
||||
{
|
||||
string optionName = player.PlayerName;
|
||||
string optionName = HttpUtility.HtmlEncode(player.PlayerName);
|
||||
if (enableFilter != null && enableFilter(player) == false)
|
||||
continue;
|
||||
|
||||
bool enabled = admin.CanTarget(player);
|
||||
if (enableFilter != null)
|
||||
enabled &= enableFilter(player);
|
||||
menu.AddMenuOption(optionName, (_, _) => { onSelectAction?.Invoke(admin, player); }, enabled == false);
|
||||
}
|
||||
|
||||
AdminMenu.OpenMenu(admin, menu);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,8 +31,8 @@
|
||||
"sa_admin_slap_message": "Admin {lightred}{0}{default} slapped {lightred}{1}{default}!",
|
||||
"sa_admin_changemap_message": "Admin {lightred}{0}{default} changed map to {lightred}{1}{default}!",
|
||||
"sa_admin_noclip_message": "Admin {lightred}{0}{default} toggled noclip for {lightred}{1}{default}!",
|
||||
"sa_admin_freeze_message": "Admin {lightred}{0}{default} freezed {lightred}{1}{default}!",
|
||||
"sa_admin_unfreeze_message": "Admin {lightred}{0}{default} umfreezed {lightred}{1}{default}!",
|
||||
"sa_admin_freeze_message": "Admin {lightred}{0}{default} froze {lightred}{1}{default}!",
|
||||
"sa_admin_unfreeze_message": "Admin {lightred}{0}{default} unfroze {lightred}{1}{default}!",
|
||||
"sa_admin_rename_message": "Admin {lightred}{0}{default} changed {lightred}{1}{default} nickname to {lightred}{2}{default}!",
|
||||
"sa_admin_respawn_message": "Admin {lightred}{0}{default} respawned {lightred}{1}{default}!",
|
||||
"sa_admin_tp_message": "Admin {lightred}{0}{default} teleported to {lightred}{1}{default}!",
|
||||
|
||||
Reference in New Issue
Block a user