mirror of
https://github.com/daffyyyy/CS2-SimpleAdmin.git
synced 2026-02-18 02:41:55 +00:00
Discord webhook from 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 () =>
|
||||
{
|
||||
|
||||
@@ -109,12 +109,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);
|
||||
@@ -133,7 +127,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)
|
||||
@@ -158,12 +154,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");
|
||||
|
||||
@@ -190,7 +180,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)
|
||||
@@ -208,15 +200,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 _))
|
||||
@@ -384,12 +379,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);
|
||||
|
||||
@@ -414,8 +403,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)
|
||||
{
|
||||
@@ -475,12 +466,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);
|
||||
|
||||
@@ -519,6 +506,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}");
|
||||
@@ -565,13 +555,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);
|
||||
|
||||
@@ -650,10 +636,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"))
|
||||
{
|
||||
@@ -690,12 +653,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)
|
||||
@@ -714,12 +671,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))
|
||||
{
|
||||
|
||||
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
|
||||
|
||||
@@ -34,6 +34,8 @@ namespace CS2_SimpleAdmin.Menus
|
||||
|
||||
options.Add(new ChatMenuOptionData(customCommand.DisplayName, () =>
|
||||
{
|
||||
Helper.TryLogCommandOnDiscord(admin, customCommand.Command);
|
||||
|
||||
if (customCommand.ExecuteOnClient)
|
||||
admin.ExecuteClientCommand(customCommand.Command);
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user