mirror of
https://github.com/daffyyyy/CS2-SimpleAdmin.git
synced 2026-02-18 02:41:55 +00:00
1.5.0a
- Fixed immunity in menu - Added new command `css_prename` to perm rename player (until the server restarts - don't set new name to remove perm rename) // @css/ban)
This commit is contained in:
@@ -51,6 +51,8 @@ namespace CS2_SimpleAdmin
|
||||
internal void Ban(CCSPlayerController? caller, CCSPlayerController? player, int time, string reason, string? callerName = null, BanManager? banManager = null, CommandInfo? command = null)
|
||||
{
|
||||
if (_database == null || player is null || !player.IsValid) return;
|
||||
if (!caller.CanTarget(player)) return;
|
||||
|
||||
|
||||
if (CheckValidBan(caller, time) == false)
|
||||
return;
|
||||
|
||||
@@ -534,6 +534,7 @@ namespace CS2_SimpleAdmin
|
||||
public void Kick(CCSPlayerController? caller, CCSPlayerController? player, string? reason = "Unknown", string? callerName = null, CommandInfo? command = null)
|
||||
{
|
||||
if (player == null || !player.IsValid) return;
|
||||
if (!caller.CanTarget(player)) return;
|
||||
|
||||
callerName ??= caller == null ? "Console" : caller.PlayerName;
|
||||
reason ??= _localizer?["sa_unknown"] ?? "Unknown";
|
||||
|
||||
@@ -49,6 +49,8 @@ namespace CS2_SimpleAdmin
|
||||
internal static void Gag(CCSPlayerController? caller, CCSPlayerController? player, int time, string reason, string? callerName = null, MuteManager? muteManager = null, PlayerPenaltyManager? playerPenaltyManager = null, CommandInfo? command = null)
|
||||
{
|
||||
if (_database == null) return;
|
||||
if (!caller.CanTarget(player)) return;
|
||||
|
||||
callerName ??= caller == null ? "Console" : caller.PlayerName;
|
||||
muteManager ??= new MuteManager(_database);
|
||||
|
||||
@@ -388,6 +390,8 @@ namespace CS2_SimpleAdmin
|
||||
internal void Mute(CCSPlayerController? caller, CCSPlayerController? player, int time, string reason, string? callerName = null, MuteManager? muteManager = null, PlayerPenaltyManager? playerPenaltyManager = null, CommandInfo? command = null)
|
||||
{
|
||||
if (_database == null) return;
|
||||
if (!caller.CanTarget(player)) return;
|
||||
|
||||
callerName ??= caller == null ? "Console" : caller.PlayerName;
|
||||
muteManager ??= new MuteManager(_database);
|
||||
|
||||
@@ -706,6 +710,8 @@ namespace CS2_SimpleAdmin
|
||||
internal void Silence(CCSPlayerController? caller, CCSPlayerController? player, int time, string reason, string? callerName = null, MuteManager? muteManager = null, PlayerPenaltyManager? playerPenaltyManager = null, CommandInfo? command = null)
|
||||
{
|
||||
if (_database == null) return;
|
||||
if (!caller.CanTarget(player)) return;
|
||||
|
||||
callerName ??= caller == null ? "Console" : caller.PlayerName;
|
||||
muteManager ??= new MuteManager(_database);
|
||||
|
||||
|
||||
@@ -35,6 +35,8 @@ namespace CS2_SimpleAdmin
|
||||
|
||||
public void NoClip(CCSPlayerController? caller, CCSPlayerController? player, string? callerName = null)
|
||||
{
|
||||
if (!caller.CanTarget(player)) return;
|
||||
|
||||
callerName ??= caller == null ? "Console" : caller.PlayerName;
|
||||
player!.Pawn.Value!.ToggleNoclip();
|
||||
|
||||
@@ -77,6 +79,8 @@ namespace CS2_SimpleAdmin
|
||||
|
||||
public void Freeze(CCSPlayerController? caller, CCSPlayerController? player, int time, string? callerName = null)
|
||||
{
|
||||
if (!caller.CanTarget(player)) return;
|
||||
|
||||
callerName ??= caller == null ? "Console" : caller.PlayerName;
|
||||
|
||||
player?.Pawn.Value!.Freeze();
|
||||
@@ -117,6 +121,8 @@ namespace CS2_SimpleAdmin
|
||||
|
||||
public void Unfreeze(CCSPlayerController? caller, CCSPlayerController? player, string? callerName = null, CommandInfo? command = null)
|
||||
{
|
||||
if (!caller.CanTarget(player)) return;
|
||||
|
||||
callerName ??= caller == null ? "Console" : caller.PlayerName;
|
||||
|
||||
player!.Pawn.Value!.Unfreeze();
|
||||
|
||||
@@ -33,6 +33,8 @@ namespace CS2_SimpleAdmin
|
||||
{
|
||||
if (player == null || !player.IsValid || player.Connected != PlayerConnectedState.PlayerConnected)
|
||||
return;
|
||||
if (!caller.CanTarget(player)) return;
|
||||
|
||||
|
||||
callerName ??= caller == null ? "Console" : caller.PlayerName;
|
||||
|
||||
@@ -103,6 +105,8 @@ namespace CS2_SimpleAdmin
|
||||
|
||||
public void GiveWeapon(CCSPlayerController? caller, CCSPlayerController player, CsItem weapon, string? callerName = null)
|
||||
{
|
||||
if (!caller.CanTarget(player)) return;
|
||||
|
||||
Helper.LogCommand(caller, $"css_give {player.PlayerName} {weapon.ToString()}");
|
||||
|
||||
player.GiveNamedItem(weapon);
|
||||
@@ -111,6 +115,8 @@ namespace CS2_SimpleAdmin
|
||||
|
||||
private void GiveWeapon(CCSPlayerController? caller, CCSPlayerController player, string weaponName, string? callerName = null, CommandInfo? command = null)
|
||||
{
|
||||
if (!caller.CanTarget(player)) return;
|
||||
|
||||
if (command != null)
|
||||
{
|
||||
Helper.LogCommand(caller, command);
|
||||
@@ -123,6 +129,8 @@ namespace CS2_SimpleAdmin
|
||||
|
||||
private void SubGiveWeapon(CCSPlayerController? caller, CCSPlayerController player, string weaponName, string? callerName = null)
|
||||
{
|
||||
if (!caller.CanTarget(player)) return;
|
||||
|
||||
callerName ??= caller == null ? "Console" : caller.PlayerName;
|
||||
|
||||
if (caller != null && (SilentPlayers.Contains(caller.Slot))) return;
|
||||
@@ -159,6 +167,8 @@ namespace CS2_SimpleAdmin
|
||||
|
||||
public void StripWeapons(CCSPlayerController? caller, CCSPlayerController? player, string? callerName = null, CommandInfo? command = null)
|
||||
{
|
||||
if (!caller.CanTarget(player)) return;
|
||||
|
||||
callerName ??= caller == null ? "Console" : caller.PlayerName;
|
||||
|
||||
if (player == null || !player.IsValid || !player.PawnIsAlive || player.Connected != PlayerConnectedState.PlayerConnected)
|
||||
@@ -210,6 +220,8 @@ namespace CS2_SimpleAdmin
|
||||
if (player == null || !player.IsValid || player.IsHLTV)
|
||||
return;
|
||||
|
||||
if (!caller.CanTarget(player)) return;
|
||||
|
||||
var callerName = caller == null ? "Console" : caller.PlayerName;
|
||||
|
||||
player.SetHp(health);
|
||||
@@ -259,6 +271,8 @@ namespace CS2_SimpleAdmin
|
||||
|
||||
public void SetSpeed(CCSPlayerController? caller, CCSPlayerController? player, double speed, string? callerName = null, CommandInfo? command = null)
|
||||
{
|
||||
if (!caller.CanTarget(player)) return;
|
||||
|
||||
callerName ??= caller == null ? "Console" : caller.PlayerName;
|
||||
|
||||
player.SetSpeed((float)speed);
|
||||
@@ -310,6 +324,8 @@ namespace CS2_SimpleAdmin
|
||||
|
||||
public void SetGravity(CCSPlayerController? caller, CCSPlayerController? player, double gravity, string? callerName = null, CommandInfo? command = null)
|
||||
{
|
||||
if (!caller.CanTarget(player)) return;
|
||||
|
||||
callerName ??= caller == null ? "Console" : caller.PlayerName;
|
||||
|
||||
player.SetGravity((float)gravity);
|
||||
@@ -359,6 +375,8 @@ namespace CS2_SimpleAdmin
|
||||
|
||||
public void SetMoney(CCSPlayerController? caller, CCSPlayerController? player, int money, string? callerName = null, CommandInfo? command = null)
|
||||
{
|
||||
if (!caller.CanTarget(player)) return;
|
||||
|
||||
callerName ??= caller == null ? "Console" : caller.PlayerName;
|
||||
|
||||
player.SetMoney(money);
|
||||
@@ -406,6 +424,8 @@ namespace CS2_SimpleAdmin
|
||||
|
||||
public void God(CCSPlayerController? caller, CCSPlayerController? player, string? callerName = null, CommandInfo? command = null)
|
||||
{
|
||||
if (!caller.CanTarget(player)) return;
|
||||
|
||||
callerName ??= caller == null ? "Console" : caller.PlayerName;
|
||||
|
||||
if (player == null) return;
|
||||
@@ -467,6 +487,8 @@ namespace CS2_SimpleAdmin
|
||||
|
||||
public void Slap(CCSPlayerController? caller, CCSPlayerController? player, int damage, CommandInfo? command = null)
|
||||
{
|
||||
if (!caller.CanTarget(player)) return;
|
||||
|
||||
var callerName = caller == null ? "Console" : caller.PlayerName;
|
||||
player!.Pawn.Value!.Slap(damage);
|
||||
|
||||
@@ -481,7 +503,7 @@ namespace CS2_SimpleAdmin
|
||||
return;
|
||||
|
||||
if (caller != null && SilentPlayers.Contains(caller.Slot)) return;
|
||||
|
||||
|
||||
foreach (var controller in Helper.GetValidPlayers().Where(controller => controller is { IsValid: true, IsBot: false }))
|
||||
{
|
||||
using (new WithTemporaryCulture(controller.GetLanguage()))
|
||||
@@ -546,6 +568,8 @@ namespace CS2_SimpleAdmin
|
||||
if (player == null || !player.IsValid || player.Connected != PlayerConnectedState.PlayerConnected)
|
||||
return;
|
||||
|
||||
if (!caller.CanTarget(player)) return;
|
||||
|
||||
callerName ??= caller == null ? "Console" : caller.PlayerName;
|
||||
|
||||
if (!teamName.Equals("swap"))
|
||||
@@ -631,6 +655,53 @@ namespace CS2_SimpleAdmin
|
||||
});
|
||||
}
|
||||
|
||||
[ConsoleCommand("css_prename", "Permanent rename a player.")]
|
||||
[CommandHelper(1, "<#userid or name> <new name>")]
|
||||
[RequiresPermissions("@css/ban")]
|
||||
public void OnPRenameCommand(CCSPlayerController? caller, CommandInfo command)
|
||||
{
|
||||
var callerName = caller == null ? "Console" : caller.PlayerName;
|
||||
var newName = command.GetArg(2);
|
||||
|
||||
var targets = GetTarget(command);
|
||||
if (targets == null) return;
|
||||
var playersToTarget = targets.Players.Where(player => player is { IsValid: true, IsHLTV: false }).ToList();
|
||||
|
||||
Helper.LogCommand(caller, command);
|
||||
Helper.SendDiscordLogMessage(caller, command, DiscordWebhookClientLog, _localizer);
|
||||
|
||||
playersToTarget.ForEach(player =>
|
||||
{
|
||||
if (player.Connected != PlayerConnectedState.PlayerConnected)
|
||||
return;
|
||||
|
||||
if (!caller!.CanTarget(player)) return;
|
||||
if (caller == null || !SilentPlayers.Contains(caller.Slot) && !string.IsNullOrEmpty(newName))
|
||||
{
|
||||
foreach (var controller in Helper.GetValidPlayers().Where(controller => controller is { IsValid: true, IsBot: false }))
|
||||
{
|
||||
using (new WithTemporaryCulture(controller.GetLanguage()))
|
||||
{
|
||||
StringBuilder sb = new(_localizer!["sa_prefix"]);
|
||||
sb.Append(_localizer["sa_admin_rename_message", callerName, player.PlayerName, newName]);
|
||||
controller.PrintToChat(sb.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(newName))
|
||||
{
|
||||
RenamedPlayers[player.SteamID] = newName;
|
||||
}
|
||||
else
|
||||
{
|
||||
RenamedPlayers.Remove(player.SteamID);
|
||||
}
|
||||
|
||||
player.Rename(newName);
|
||||
});
|
||||
}
|
||||
|
||||
[ConsoleCommand("css_respawn", "Respawn a dead player.")]
|
||||
[CommandHelper(1, "<#userid or name>")]
|
||||
[RequiresPermissions("@css/cheats")]
|
||||
@@ -656,6 +727,8 @@ namespace CS2_SimpleAdmin
|
||||
|
||||
public void Respawn(CCSPlayerController? caller, CCSPlayerController? player, string? callerName = null, CommandInfo? command = null)
|
||||
{
|
||||
if (!caller.CanTarget(player)) return;
|
||||
|
||||
callerName ??= caller == null ? "Console" : caller.PlayerName;
|
||||
|
||||
if (_cBasePlayerControllerSetPawnFunc == null || player?.PlayerPawn.Value == null || !player.PlayerPawn.IsValid) return;
|
||||
|
||||
Reference in New Issue
Block a user