mirror of
https://github.com/daffyyyy/CS2-SimpleAdmin.git
synced 2026-02-23 04:00:38 +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:
@@ -20,8 +20,9 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
public static readonly Dictionary<string, int> VoteAnswers = [];
|
public static readonly Dictionary<string, int> VoteAnswers = [];
|
||||||
private static readonly HashSet<int> GodPlayers = [];
|
private static readonly HashSet<int> GodPlayers = [];
|
||||||
private static readonly HashSet<int> SilentPlayers = [];
|
private static readonly HashSet<int> SilentPlayers = [];
|
||||||
//private static readonly ConcurrentBag<int> SilentPlayers = [];
|
|
||||||
private static readonly ConcurrentBag<string> BannedPlayers = [];
|
private static readonly ConcurrentBag<string> BannedPlayers = [];
|
||||||
|
private static readonly Dictionary<ulong, string> RenamedPlayers = [];
|
||||||
|
//private static readonly ConcurrentBag<int> SilentPlayers = [];
|
||||||
private static bool _tagsDetected;
|
private static bool _tagsDetected;
|
||||||
public static bool VoteInProgress = false;
|
public static bool VoteInProgress = false;
|
||||||
public static int? ServerId = null;
|
public static int? ServerId = null;
|
||||||
@@ -39,7 +40,7 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
public override string ModuleName => "CS2-SimpleAdmin" + (Helper.IsDebugBuild ? " (DEBUG)" : " (RELEASE)");
|
public override string ModuleName => "CS2-SimpleAdmin" + (Helper.IsDebugBuild ? " (DEBUG)" : " (RELEASE)");
|
||||||
public override string ModuleDescription => "Simple admin plugin for Counter-Strike 2 :)";
|
public override string ModuleDescription => "Simple admin plugin for Counter-Strike 2 :)";
|
||||||
public override string ModuleAuthor => "daffyy & Dliix66";
|
public override string ModuleAuthor => "daffyy & Dliix66";
|
||||||
public override string ModuleVersion => "1.4.9a";
|
public override string ModuleVersion => "1.5.0a";
|
||||||
|
|
||||||
public CS2_SimpleAdminConfig Config { get; set; } = new();
|
public CS2_SimpleAdminConfig Config { get; set; } = new();
|
||||||
|
|
||||||
@@ -112,9 +113,9 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
|||||||
{
|
{
|
||||||
Directory.CreateDirectory(ModuleDirectory + "/data");
|
Directory.CreateDirectory(ModuleDirectory + "/data");
|
||||||
}
|
}
|
||||||
|
|
||||||
_localizer = Localizer;
|
_localizer = Localizer;
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(Config.Discord.DiscordLogWebhook))
|
if (!string.IsNullOrEmpty(Config.Discord.DiscordLogWebhook))
|
||||||
DiscordWebhookClientLog = new DiscordWebhookClient(Config.Discord.DiscordLogWebhook);
|
DiscordWebhookClientLog = new DiscordWebhookClient(Config.Discord.DiscordLogWebhook);
|
||||||
if (!string.IsNullOrEmpty(Config.Discord.DiscordPenaltyWebhook))
|
if (!string.IsNullOrEmpty(Config.Discord.DiscordPenaltyWebhook))
|
||||||
|
|||||||
@@ -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)
|
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 (_database == null || player is null || !player.IsValid) return;
|
||||||
|
if (!caller.CanTarget(player)) return;
|
||||||
|
|
||||||
|
|
||||||
if (CheckValidBan(caller, time) == false)
|
if (CheckValidBan(caller, time) == false)
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -534,6 +534,7 @@ namespace CS2_SimpleAdmin
|
|||||||
public void Kick(CCSPlayerController? caller, CCSPlayerController? player, string? reason = "Unknown", string? callerName = null, CommandInfo? command = null)
|
public void Kick(CCSPlayerController? caller, CCSPlayerController? player, string? reason = "Unknown", string? callerName = null, CommandInfo? command = null)
|
||||||
{
|
{
|
||||||
if (player == null || !player.IsValid) return;
|
if (player == null || !player.IsValid) return;
|
||||||
|
if (!caller.CanTarget(player)) return;
|
||||||
|
|
||||||
callerName ??= caller == null ? "Console" : caller.PlayerName;
|
callerName ??= caller == null ? "Console" : caller.PlayerName;
|
||||||
reason ??= _localizer?["sa_unknown"] ?? "Unknown";
|
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)
|
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 (_database == null) return;
|
||||||
|
if (!caller.CanTarget(player)) return;
|
||||||
|
|
||||||
callerName ??= caller == null ? "Console" : caller.PlayerName;
|
callerName ??= caller == null ? "Console" : caller.PlayerName;
|
||||||
muteManager ??= new MuteManager(_database);
|
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)
|
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 (_database == null) return;
|
||||||
|
if (!caller.CanTarget(player)) return;
|
||||||
|
|
||||||
callerName ??= caller == null ? "Console" : caller.PlayerName;
|
callerName ??= caller == null ? "Console" : caller.PlayerName;
|
||||||
muteManager ??= new MuteManager(_database);
|
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)
|
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 (_database == null) return;
|
||||||
|
if (!caller.CanTarget(player)) return;
|
||||||
|
|
||||||
callerName ??= caller == null ? "Console" : caller.PlayerName;
|
callerName ??= caller == null ? "Console" : caller.PlayerName;
|
||||||
muteManager ??= new MuteManager(_database);
|
muteManager ??= new MuteManager(_database);
|
||||||
|
|
||||||
|
|||||||
@@ -35,6 +35,8 @@ namespace CS2_SimpleAdmin
|
|||||||
|
|
||||||
public void NoClip(CCSPlayerController? caller, CCSPlayerController? player, string? callerName = null)
|
public void NoClip(CCSPlayerController? caller, CCSPlayerController? player, string? callerName = null)
|
||||||
{
|
{
|
||||||
|
if (!caller.CanTarget(player)) return;
|
||||||
|
|
||||||
callerName ??= caller == null ? "Console" : caller.PlayerName;
|
callerName ??= caller == null ? "Console" : caller.PlayerName;
|
||||||
player!.Pawn.Value!.ToggleNoclip();
|
player!.Pawn.Value!.ToggleNoclip();
|
||||||
|
|
||||||
@@ -77,6 +79,8 @@ namespace CS2_SimpleAdmin
|
|||||||
|
|
||||||
public void Freeze(CCSPlayerController? caller, CCSPlayerController? player, int time, string? callerName = null)
|
public void Freeze(CCSPlayerController? caller, CCSPlayerController? player, int time, string? callerName = null)
|
||||||
{
|
{
|
||||||
|
if (!caller.CanTarget(player)) return;
|
||||||
|
|
||||||
callerName ??= caller == null ? "Console" : caller.PlayerName;
|
callerName ??= caller == null ? "Console" : caller.PlayerName;
|
||||||
|
|
||||||
player?.Pawn.Value!.Freeze();
|
player?.Pawn.Value!.Freeze();
|
||||||
@@ -117,6 +121,8 @@ namespace CS2_SimpleAdmin
|
|||||||
|
|
||||||
public void Unfreeze(CCSPlayerController? caller, CCSPlayerController? player, string? callerName = null, CommandInfo? command = null)
|
public void Unfreeze(CCSPlayerController? caller, CCSPlayerController? player, string? callerName = null, CommandInfo? command = null)
|
||||||
{
|
{
|
||||||
|
if (!caller.CanTarget(player)) return;
|
||||||
|
|
||||||
callerName ??= caller == null ? "Console" : caller.PlayerName;
|
callerName ??= caller == null ? "Console" : caller.PlayerName;
|
||||||
|
|
||||||
player!.Pawn.Value!.Unfreeze();
|
player!.Pawn.Value!.Unfreeze();
|
||||||
|
|||||||
@@ -33,6 +33,8 @@ namespace CS2_SimpleAdmin
|
|||||||
{
|
{
|
||||||
if (player == null || !player.IsValid || player.Connected != PlayerConnectedState.PlayerConnected)
|
if (player == null || !player.IsValid || player.Connected != PlayerConnectedState.PlayerConnected)
|
||||||
return;
|
return;
|
||||||
|
if (!caller.CanTarget(player)) return;
|
||||||
|
|
||||||
|
|
||||||
callerName ??= caller == null ? "Console" : caller.PlayerName;
|
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)
|
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()}");
|
Helper.LogCommand(caller, $"css_give {player.PlayerName} {weapon.ToString()}");
|
||||||
|
|
||||||
player.GiveNamedItem(weapon);
|
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)
|
private void GiveWeapon(CCSPlayerController? caller, CCSPlayerController player, string weaponName, string? callerName = null, CommandInfo? command = null)
|
||||||
{
|
{
|
||||||
|
if (!caller.CanTarget(player)) return;
|
||||||
|
|
||||||
if (command != null)
|
if (command != null)
|
||||||
{
|
{
|
||||||
Helper.LogCommand(caller, command);
|
Helper.LogCommand(caller, command);
|
||||||
@@ -123,6 +129,8 @@ namespace CS2_SimpleAdmin
|
|||||||
|
|
||||||
private void SubGiveWeapon(CCSPlayerController? caller, CCSPlayerController player, string weaponName, string? callerName = null)
|
private void SubGiveWeapon(CCSPlayerController? caller, CCSPlayerController player, string weaponName, string? callerName = null)
|
||||||
{
|
{
|
||||||
|
if (!caller.CanTarget(player)) return;
|
||||||
|
|
||||||
callerName ??= caller == null ? "Console" : caller.PlayerName;
|
callerName ??= caller == null ? "Console" : caller.PlayerName;
|
||||||
|
|
||||||
if (caller != null && (SilentPlayers.Contains(caller.Slot))) return;
|
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)
|
public void StripWeapons(CCSPlayerController? caller, CCSPlayerController? player, string? callerName = null, CommandInfo? command = null)
|
||||||
{
|
{
|
||||||
|
if (!caller.CanTarget(player)) return;
|
||||||
|
|
||||||
callerName ??= caller == null ? "Console" : caller.PlayerName;
|
callerName ??= caller == null ? "Console" : caller.PlayerName;
|
||||||
|
|
||||||
if (player == null || !player.IsValid || !player.PawnIsAlive || player.Connected != PlayerConnectedState.PlayerConnected)
|
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)
|
if (player == null || !player.IsValid || player.IsHLTV)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (!caller.CanTarget(player)) return;
|
||||||
|
|
||||||
var callerName = caller == null ? "Console" : caller.PlayerName;
|
var callerName = caller == null ? "Console" : caller.PlayerName;
|
||||||
|
|
||||||
player.SetHp(health);
|
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)
|
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;
|
callerName ??= caller == null ? "Console" : caller.PlayerName;
|
||||||
|
|
||||||
player.SetSpeed((float)speed);
|
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)
|
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;
|
callerName ??= caller == null ? "Console" : caller.PlayerName;
|
||||||
|
|
||||||
player.SetGravity((float)gravity);
|
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)
|
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;
|
callerName ??= caller == null ? "Console" : caller.PlayerName;
|
||||||
|
|
||||||
player.SetMoney(money);
|
player.SetMoney(money);
|
||||||
@@ -406,6 +424,8 @@ namespace CS2_SimpleAdmin
|
|||||||
|
|
||||||
public void God(CCSPlayerController? caller, CCSPlayerController? player, string? callerName = null, CommandInfo? command = null)
|
public void God(CCSPlayerController? caller, CCSPlayerController? player, string? callerName = null, CommandInfo? command = null)
|
||||||
{
|
{
|
||||||
|
if (!caller.CanTarget(player)) return;
|
||||||
|
|
||||||
callerName ??= caller == null ? "Console" : caller.PlayerName;
|
callerName ??= caller == null ? "Console" : caller.PlayerName;
|
||||||
|
|
||||||
if (player == null) return;
|
if (player == null) return;
|
||||||
@@ -467,6 +487,8 @@ namespace CS2_SimpleAdmin
|
|||||||
|
|
||||||
public void Slap(CCSPlayerController? caller, CCSPlayerController? player, int damage, CommandInfo? command = null)
|
public void Slap(CCSPlayerController? caller, CCSPlayerController? player, int damage, CommandInfo? command = null)
|
||||||
{
|
{
|
||||||
|
if (!caller.CanTarget(player)) return;
|
||||||
|
|
||||||
var callerName = caller == null ? "Console" : caller.PlayerName;
|
var callerName = caller == null ? "Console" : caller.PlayerName;
|
||||||
player!.Pawn.Value!.Slap(damage);
|
player!.Pawn.Value!.Slap(damage);
|
||||||
|
|
||||||
@@ -481,7 +503,7 @@ namespace CS2_SimpleAdmin
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (caller != null && SilentPlayers.Contains(caller.Slot)) return;
|
if (caller != null && SilentPlayers.Contains(caller.Slot)) return;
|
||||||
|
|
||||||
foreach (var controller in Helper.GetValidPlayers().Where(controller => controller is { IsValid: true, IsBot: false }))
|
foreach (var controller in Helper.GetValidPlayers().Where(controller => controller is { IsValid: true, IsBot: false }))
|
||||||
{
|
{
|
||||||
using (new WithTemporaryCulture(controller.GetLanguage()))
|
using (new WithTemporaryCulture(controller.GetLanguage()))
|
||||||
@@ -546,6 +568,8 @@ namespace CS2_SimpleAdmin
|
|||||||
if (player == null || !player.IsValid || player.Connected != PlayerConnectedState.PlayerConnected)
|
if (player == null || !player.IsValid || player.Connected != PlayerConnectedState.PlayerConnected)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (!caller.CanTarget(player)) return;
|
||||||
|
|
||||||
callerName ??= caller == null ? "Console" : caller.PlayerName;
|
callerName ??= caller == null ? "Console" : caller.PlayerName;
|
||||||
|
|
||||||
if (!teamName.Equals("swap"))
|
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.")]
|
[ConsoleCommand("css_respawn", "Respawn a dead player.")]
|
||||||
[CommandHelper(1, "<#userid or name>")]
|
[CommandHelper(1, "<#userid or name>")]
|
||||||
[RequiresPermissions("@css/cheats")]
|
[RequiresPermissions("@css/cheats")]
|
||||||
@@ -656,6 +727,8 @@ namespace CS2_SimpleAdmin
|
|||||||
|
|
||||||
public void Respawn(CCSPlayerController? caller, CCSPlayerController? player, string? callerName = null, CommandInfo? command = null)
|
public void Respawn(CCSPlayerController? caller, CCSPlayerController? player, string? callerName = null, CommandInfo? command = null)
|
||||||
{
|
{
|
||||||
|
if (!caller.CanTarget(player)) return;
|
||||||
|
|
||||||
callerName ??= caller == null ? "Console" : caller.PlayerName;
|
callerName ??= caller == null ? "Console" : caller.PlayerName;
|
||||||
|
|
||||||
if (_cBasePlayerControllerSetPawnFunc == null || player?.PlayerPawn.Value == null || !player.PlayerPawn.IsValid) return;
|
if (_cBasePlayerControllerSetPawnFunc == null || player?.PlayerPawn.Value == null || !player.PlayerPawn.IsValid) return;
|
||||||
|
|||||||
24
Events.cs
24
Events.cs
@@ -282,6 +282,11 @@ public partial class CS2_SimpleAdmin
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (RenamedPlayers.TryGetValue(player.SteamID, out var name))
|
||||||
|
{
|
||||||
|
player.Rename(name);
|
||||||
|
}
|
||||||
|
|
||||||
return HookResult.Continue;
|
return HookResult.Continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -527,4 +532,23 @@ public partial class CS2_SimpleAdmin
|
|||||||
|
|
||||||
return HookResult.Continue;
|
return HookResult.Continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[GameEventHandler]
|
||||||
|
public HookResult OnChangedName(EventPlayerChangename @event, GameEventInfo _)
|
||||||
|
{
|
||||||
|
CCSPlayerController? player = @event.Userid;
|
||||||
|
|
||||||
|
if (player is null || !player.IsValid || player.IsBot)
|
||||||
|
return HookResult.Continue;
|
||||||
|
|
||||||
|
if (RenamedPlayers.TryGetValue(player.SteamID, out var name))
|
||||||
|
{
|
||||||
|
if (@event.Newname.Equals(name))
|
||||||
|
return HookResult.Continue;
|
||||||
|
|
||||||
|
player.Rename(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
return HookResult.Continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -28,8 +28,8 @@ public static class PlayerExtensions
|
|||||||
if (target.IsBot) return true;
|
if (target.IsBot) return true;
|
||||||
|
|
||||||
return AdminManager.CanPlayerTarget(controller, target) ||
|
return AdminManager.CanPlayerTarget(controller, target) ||
|
||||||
AdminManager.CanPlayerTarget(new SteamID(controller.SteamID),
|
AdminManager.CanPlayerTarget(new SteamID(controller.SteamID),
|
||||||
new SteamID(target.SteamID));
|
new SteamID(target.SteamID));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void SetSpeed(this CCSPlayerController? controller, float speed)
|
public static void SetSpeed(this CCSPlayerController? controller, float speed)
|
||||||
@@ -62,7 +62,7 @@ public static class PlayerExtensions
|
|||||||
{
|
{
|
||||||
if (controller == null) return;
|
if (controller == null) return;
|
||||||
if ((health <= 0 || !controller.PawnIsAlive || controller.PlayerPawn.Value == null)) return;
|
if ((health <= 0 || !controller.PawnIsAlive || controller.PlayerPawn.Value == null)) return;
|
||||||
|
|
||||||
controller.PlayerPawn.Value.Health = health;
|
controller.PlayerPawn.Value.Health = health;
|
||||||
|
|
||||||
if (health > 100)
|
if (health > 100)
|
||||||
@@ -121,7 +121,7 @@ public static class PlayerExtensions
|
|||||||
|
|
||||||
public static void Rename(this CCSPlayerController? controller, string newName = "Unknown")
|
public static void Rename(this CCSPlayerController? controller, string newName = "Unknown")
|
||||||
{
|
{
|
||||||
newName = newName ?? CS2_SimpleAdmin._localizer?["sa_unknown"] ?? "Unknown";
|
newName ??= CS2_SimpleAdmin._localizer?["sa_unknown"] ?? "Unknown";
|
||||||
|
|
||||||
if (controller != null)
|
if (controller != null)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -53,6 +53,7 @@ Manage your Counter-Strike 2 server by simple commands :)
|
|||||||
- css_freeze <#userid or name> [duration] - Freeze player // @css/slay
|
- css_freeze <#userid or name> [duration] - Freeze player // @css/slay
|
||||||
- css_unfreeze <#userid or name> - Unfreeze player // @css/slay
|
- css_unfreeze <#userid or name> - Unfreeze player // @css/slay
|
||||||
- css_rename <#userid or name> <new name> - Rename player // @css/kick
|
- css_rename <#userid or name> <new name> - Rename player // @css/kick
|
||||||
|
- css_prename <#userid or name> <new name> - Permanently rename player (until the server restarts - don't set new name to remove perm rename) // @css/ban
|
||||||
- css_respawn <#userid or name> - Respawn player // @css/cheats
|
- css_respawn <#userid or name> - Respawn player // @css/cheats
|
||||||
- css_cvar <cvar> <value> - Change cvar value // @css/cvar
|
- css_cvar <cvar> <value> - Change cvar value // @css/cvar
|
||||||
- css_rcon <command> - Run command as server // @css/rcon
|
- css_rcon <command> - Run command as server // @css/rcon
|
||||||
|
|||||||
Reference in New Issue
Block a user