mirror of
https://github.com/daffyyyy/CS2-SimpleAdmin.git
synced 2026-02-18 10:43:23 +00:00
1.3.6a
- Minor changes - Added `css_gravity` command - Added `css_money` command - Changed Utc time to LocalTime - Updated translations (ChatGPT generated) - Updated css version
This commit is contained in:
@@ -20,7 +20,7 @@ namespace CS2_SimpleAdmin
|
||||
if (command.ArgCount < 2)
|
||||
return;
|
||||
|
||||
string reason = "Unknown";
|
||||
string reason = CS2_SimpleAdmin._localizer?["sa_unknown"] ?? "Unknown";
|
||||
|
||||
TargetResult? targets = GetTarget(command);
|
||||
if (targets == null) return;
|
||||
@@ -68,9 +68,9 @@ namespace CS2_SimpleAdmin
|
||||
|
||||
PlayerInfo playerInfo = new PlayerInfo
|
||||
{
|
||||
SteamId = player?.SteamID.ToString(),
|
||||
Name = player?.PlayerName,
|
||||
IpAddress = player?.IpAddress?.Split(":")[0]
|
||||
SteamId = player.SteamID.ToString(),
|
||||
Name = player.PlayerName,
|
||||
IpAddress = player.IpAddress?.Split(":")[0]
|
||||
};
|
||||
|
||||
PlayerInfo adminInfo = new PlayerInfo
|
||||
@@ -80,7 +80,7 @@ namespace CS2_SimpleAdmin
|
||||
IpAddress = caller?.IpAddress?.Split(":")[0]
|
||||
};
|
||||
|
||||
Helper.LogCommand(caller, $"css_ban {player?.SteamID} {time} {reason}");
|
||||
Helper.LogCommand(caller, $"css_ban {player.SteamID} {time} {reason}");
|
||||
|
||||
Task.Run(async () =>
|
||||
{
|
||||
@@ -88,7 +88,8 @@ namespace CS2_SimpleAdmin
|
||||
await banManager.BanPlayer(playerInfo, adminInfo, reason, time);
|
||||
});
|
||||
|
||||
AddTimer(Config.KickTime, () => Helper.KickPlayer((ushort)player!.UserId!), CounterStrikeSharp.API.Modules.Timers.TimerFlags.STOP_ON_MAPCHANGE);
|
||||
if (player.UserId.HasValue)
|
||||
AddTimer(Config.KickTime, () => Helper.KickPlayer(player.UserId.Value), CounterStrikeSharp.API.Modules.Timers.TimerFlags.STOP_ON_MAPCHANGE);
|
||||
|
||||
if (playerInfo.IpAddress != null && !bannedPlayers.Contains(playerInfo.IpAddress))
|
||||
bannedPlayers.Add(playerInfo.IpAddress);
|
||||
@@ -163,7 +164,7 @@ namespace CS2_SimpleAdmin
|
||||
_discordWebhookClientLog.SendMessageAsync(Helper.GenerateMessageDiscord(_localizer["sa_discord_log_command", $"[{callerName}]({communityUrl})", command.GetCommandString]));
|
||||
}
|
||||
|
||||
string reason = "Unknown";
|
||||
string reason = CS2_SimpleAdmin._localizer?["sa_unknown"] ?? "Unknown";
|
||||
|
||||
Database database = new Database(dbConnectionString);
|
||||
|
||||
@@ -196,7 +197,8 @@ namespace CS2_SimpleAdmin
|
||||
}
|
||||
|
||||
player!.Pawn.Value!.Freeze();
|
||||
AddTimer(Config.KickTime, () => Helper.KickPlayer((ushort)player.UserId!), CounterStrikeSharp.API.Modules.Timers.TimerFlags.STOP_ON_MAPCHANGE);
|
||||
if (player.UserId.HasValue)
|
||||
AddTimer(Config.KickTime, () => Helper.KickPlayer(player.UserId.Value), CounterStrikeSharp.API.Modules.Timers.TimerFlags.STOP_ON_MAPCHANGE);
|
||||
|
||||
if (time == 0)
|
||||
{
|
||||
@@ -277,7 +279,7 @@ namespace CS2_SimpleAdmin
|
||||
_discordWebhookClientLog.SendMessageAsync(Helper.GenerateMessageDiscord(_localizer["sa_discord_log_command", $"[{callerName}]({communityUrl})", command.GetCommandString]));
|
||||
}
|
||||
|
||||
string reason = "Unknown";
|
||||
string reason = CS2_SimpleAdmin._localizer?["sa_unknown"] ?? "Unknown";
|
||||
|
||||
PlayerInfo adminInfo = new PlayerInfo
|
||||
{
|
||||
@@ -349,7 +351,8 @@ namespace CS2_SimpleAdmin
|
||||
}
|
||||
}
|
||||
|
||||
AddTimer(Config.KickTime, () => Helper.KickPlayer((ushort)player.UserId!, "Banned"), CounterStrikeSharp.API.Modules.Timers.TimerFlags.STOP_ON_MAPCHANGE);
|
||||
if (player.UserId.HasValue)
|
||||
AddTimer(Config.KickTime, () => Helper.KickPlayer(player.UserId.Value, "Banned"), CounterStrikeSharp.API.Modules.Timers.TimerFlags.STOP_ON_MAPCHANGE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ 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()))
|
||||
@@ -286,11 +286,12 @@ namespace CS2_SimpleAdmin
|
||||
|
||||
playersToTarget.ForEach(player =>
|
||||
{
|
||||
if (!player.UserId.HasValue) return;
|
||||
if (caller!.CanTarget(player))
|
||||
{
|
||||
PlayerInfo playerInfo = new()
|
||||
{
|
||||
UserId = player.UserId,
|
||||
UserId = player.UserId.Value,
|
||||
Index = (int)player.Index,
|
||||
SteamId = player?.SteamID.ToString(),
|
||||
Name = player?.PlayerName,
|
||||
@@ -369,7 +370,7 @@ namespace CS2_SimpleAdmin
|
||||
public void OnKickCommand(CCSPlayerController? caller, CommandInfo command)
|
||||
{
|
||||
string callerName = caller == null ? "Console" : caller.PlayerName;
|
||||
string reason = "Unknown";
|
||||
string reason = CS2_SimpleAdmin._localizer?["sa_unknown"] ?? "Unknown";
|
||||
|
||||
TargetResult? targets = GetTarget(command);
|
||||
|
||||
@@ -412,6 +413,8 @@ namespace CS2_SimpleAdmin
|
||||
player.Pawn.Value!.Freeze();
|
||||
}
|
||||
|
||||
reason = CS2_SimpleAdmin._localizer?["sa_unknown"] ?? "Unknown";
|
||||
|
||||
Helper.LogCommand(caller, $"css_kick {player.PlayerName} {reason}");
|
||||
|
||||
if (string.IsNullOrEmpty(reason) == false)
|
||||
@@ -421,11 +424,13 @@ namespace CS2_SimpleAdmin
|
||||
{
|
||||
player.PrintToCenter(_localizer!["sa_player_kick_message", reason, caller == null ? "Console" : caller.PlayerName]);
|
||||
}
|
||||
AddTimer(Config.KickTime, () => Helper.KickPlayer((ushort)player.UserId!, reason), CounterStrikeSharp.API.Modules.Timers.TimerFlags.STOP_ON_MAPCHANGE);
|
||||
if (player.UserId.HasValue)
|
||||
AddTimer(Config.KickTime, () => Helper.KickPlayer(player.UserId.Value, reason), CounterStrikeSharp.API.Modules.Timers.TimerFlags.STOP_ON_MAPCHANGE);
|
||||
}
|
||||
else
|
||||
{
|
||||
AddTimer(Config.KickTime, () => Helper.KickPlayer((ushort)player.UserId!), CounterStrikeSharp.API.Modules.Timers.TimerFlags.STOP_ON_MAPCHANGE);
|
||||
if (player.UserId.HasValue)
|
||||
AddTimer(Config.KickTime, () => Helper.KickPlayer(player.UserId.Value), CounterStrikeSharp.API.Modules.Timers.TimerFlags.STOP_ON_MAPCHANGE);
|
||||
}
|
||||
|
||||
if (caller == null || caller != null && caller.UserId != null && !silentPlayers.Contains(caller.Slot))
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace CS2_SimpleAdmin
|
||||
string callerName = caller == null ? "Console" : caller.PlayerName;
|
||||
|
||||
int time = 0;
|
||||
string reason = "Unknown";
|
||||
string reason = CS2_SimpleAdmin._localizer?["sa_unknown"] ?? "Unknown";
|
||||
|
||||
TargetResult? targets = GetTarget(command);
|
||||
if (targets == null) return;
|
||||
@@ -164,7 +164,7 @@ namespace CS2_SimpleAdmin
|
||||
}
|
||||
|
||||
int time = 0;
|
||||
string reason = "Unknown";
|
||||
string reason = CS2_SimpleAdmin._localizer?["sa_unknown"] ?? "Unknown";
|
||||
|
||||
MuteManager _muteManager = new(_database);
|
||||
PlayerPenaltyManager playerPenaltyManager = new PlayerPenaltyManager();
|
||||
@@ -339,7 +339,7 @@ namespace CS2_SimpleAdmin
|
||||
/*
|
||||
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();
|
||||
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)
|
||||
{
|
||||
@@ -377,7 +377,7 @@ namespace CS2_SimpleAdmin
|
||||
string callerName = caller == null ? "Console" : caller.PlayerName;
|
||||
|
||||
int time = 0;
|
||||
string reason = "Unknown";
|
||||
string reason = CS2_SimpleAdmin._localizer?["sa_unknown"] ?? "Unknown";
|
||||
|
||||
TargetResult? targets = GetTarget(command);
|
||||
if (targets == null) return;
|
||||
@@ -515,7 +515,7 @@ namespace CS2_SimpleAdmin
|
||||
Helper.LogCommand(caller, command);
|
||||
|
||||
int time = 0;
|
||||
string reason = "Unknown";
|
||||
string reason = CS2_SimpleAdmin._localizer?["sa_unknown"] ?? "Unknown";
|
||||
|
||||
MuteManager _muteManager = new(_database);
|
||||
PlayerPenaltyManager playerPenaltyManager = new PlayerPenaltyManager();
|
||||
@@ -674,7 +674,7 @@ namespace CS2_SimpleAdmin
|
||||
/*
|
||||
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();
|
||||
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)
|
||||
{
|
||||
@@ -707,7 +707,7 @@ namespace CS2_SimpleAdmin
|
||||
string callerName = caller == null ? "Console" : caller.PlayerName;
|
||||
|
||||
int time = 0;
|
||||
string reason = "Unknown";
|
||||
string reason = CS2_SimpleAdmin._localizer?["sa_unknown"] ?? "Unknown";
|
||||
|
||||
TargetResult? targets = GetTarget(command);
|
||||
if (targets == null) return;
|
||||
@@ -853,7 +853,7 @@ namespace CS2_SimpleAdmin
|
||||
Helper.LogCommand(caller, command);
|
||||
|
||||
int time = 0;
|
||||
string reason = "Unknown";
|
||||
string reason = CS2_SimpleAdmin._localizer?["sa_unknown"] ?? "Unknown";
|
||||
|
||||
MuteManager _muteManager = new(_database);
|
||||
PlayerPenaltyManager playerPenaltyManager = new PlayerPenaltyManager();
|
||||
@@ -1021,7 +1021,7 @@ namespace CS2_SimpleAdmin
|
||||
/*
|
||||
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();
|
||||
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)
|
||||
{
|
||||
|
||||
@@ -306,6 +306,114 @@ namespace CS2_SimpleAdmin
|
||||
}
|
||||
}
|
||||
|
||||
[ConsoleCommand("css_gravity")]
|
||||
[RequiresPermissions("@css/slay")]
|
||||
[CommandHelper(minArgs: 1, usage: "<#userid or name> <gravity>", whoCanExecute: CommandUsage.CLIENT_AND_SERVER)]
|
||||
public void OnGravityCommand(CCSPlayerController? caller, CommandInfo command)
|
||||
{
|
||||
string callerName = caller == null ? "Console" : caller.PlayerName;
|
||||
double gravity = 1.0;
|
||||
double.TryParse(command.GetArg(2), out gravity);
|
||||
|
||||
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 =>
|
||||
{
|
||||
if (!player.IsBot && player.SteamID.ToString().Length != 17)
|
||||
return;
|
||||
|
||||
if (caller!.CanTarget(player))
|
||||
{
|
||||
SetGravity(caller, player, gravity, callerName);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void SetGravity(CCSPlayerController? caller, CCSPlayerController player, double gravity, string? callerName = null)
|
||||
{
|
||||
callerName ??= caller == null ? "Console" : caller.PlayerName;
|
||||
|
||||
player.SetGravity((float)gravity);
|
||||
|
||||
Helper.LogCommand(caller, $"css_gravity {player?.PlayerName} {gravity}");
|
||||
|
||||
if (caller == null || caller != null && !silentPlayers.Contains(caller.Slot))
|
||||
{
|
||||
foreach (CCSPlayerController _player in Helper.GetValidPlayers())
|
||||
{
|
||||
using (new WithTemporaryCulture(_player.GetLanguage()))
|
||||
{
|
||||
StringBuilder sb = new(_localizer!["sa_prefix"]);
|
||||
sb.Append(_localizer["sa_admin_gravity_message", callerName, player!.PlayerName]);
|
||||
_player.PrintToChat(sb.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[ConsoleCommand("css_money")]
|
||||
[RequiresPermissions("@css/slay")]
|
||||
[CommandHelper(minArgs: 1, usage: "<#userid or name> <money>", whoCanExecute: CommandUsage.CLIENT_AND_SERVER)]
|
||||
public void OnMoneyCommand(CCSPlayerController? caller, CommandInfo command)
|
||||
{
|
||||
string callerName = caller == null ? "Console" : caller.PlayerName;
|
||||
int money = 0;
|
||||
int.TryParse(command.GetArg(2), out money);
|
||||
|
||||
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 =>
|
||||
{
|
||||
if (!player.IsBot && player.SteamID.ToString().Length != 17)
|
||||
return;
|
||||
|
||||
if (caller!.CanTarget(player))
|
||||
{
|
||||
SetMoney(caller, player, money, callerName);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void SetMoney(CCSPlayerController? caller, CCSPlayerController player, int money, string? callerName = null)
|
||||
{
|
||||
callerName ??= caller == null ? "Console" : caller.PlayerName;
|
||||
|
||||
player.SetMoney(money);
|
||||
|
||||
Helper.LogCommand(caller, $"css_money {player?.PlayerName} {money}");
|
||||
|
||||
if (caller == null || caller != null && !silentPlayers.Contains(caller.Slot))
|
||||
{
|
||||
foreach (CCSPlayerController _player in Helper.GetValidPlayers())
|
||||
{
|
||||
using (new WithTemporaryCulture(_player.GetLanguage()))
|
||||
{
|
||||
StringBuilder sb = new(_localizer!["sa_prefix"]);
|
||||
sb.Append(_localizer["sa_admin_money_message", callerName, player!.PlayerName]);
|
||||
_player.PrintToChat(sb.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[ConsoleCommand("css_god")]
|
||||
[RequiresPermissions("@css/cheats")]
|
||||
[CommandHelper(minArgs: 1, usage: "<#userid or name>", whoCanExecute: CommandUsage.CLIENT_AND_SERVER)]
|
||||
|
||||
Reference in New Issue
Block a user