mirror of
https://github.com/daffyyyy/CS2-SimpleAdmin.git
synced 2026-02-17 18:39:07 +00:00
Additional commands
This commit is contained in:
@@ -3,8 +3,10 @@ using CounterStrikeSharp.API.Core;
|
||||
using CounterStrikeSharp.API.Core.Attributes.Registration;
|
||||
using CounterStrikeSharp.API.Modules.Admin;
|
||||
using CounterStrikeSharp.API.Modules.Commands;
|
||||
using CounterStrikeSharp.API.Modules.Cvars;
|
||||
using CounterStrikeSharp.API.Modules.Memory;
|
||||
using CounterStrikeSharp.API.Modules.Utils;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using MySqlConnector;
|
||||
using static System.Net.Mime.MediaTypeNames;
|
||||
|
||||
@@ -188,7 +190,6 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
||||
|
||||
int damage = 0;
|
||||
|
||||
|
||||
if (command.ArgCount >= 2)
|
||||
{
|
||||
int.TryParse(command.GetArg(2), out damage);
|
||||
@@ -262,6 +263,102 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
|
||||
0, 0, 0, 0);
|
||||
}
|
||||
|
||||
[ConsoleCommand("css_noclip", "Noclip a player.")]
|
||||
[CommandHelper(1, "<#userid or name>")]
|
||||
[RequiresPermissions("@css/cheats")]
|
||||
public void OnNoclipCommand(CCSPlayerController? caller, CommandInfo command)
|
||||
{
|
||||
if (!GetTarget(command, out var player))
|
||||
return;
|
||||
|
||||
player!.Pawn.Value!.ToggleNoclip();
|
||||
|
||||
Server.PrintToChatAll(Helper.ReplaceTags($" {Config.Prefix} {Config.Messages.AdminNoclipMessage}".Replace("{ADMIN}", caller?.PlayerName == null ? "Console" : caller.PlayerName).Replace("{PLAYER}", player.PlayerName)));
|
||||
}
|
||||
|
||||
[ConsoleCommand("css_freeze", "Freeze a player.")]
|
||||
[CommandHelper(1, "<#userid or name> [duration]")]
|
||||
[RequiresPermissions("@css/slay")]
|
||||
public void OnFreezeCommand(CCSPlayerController? caller, CommandInfo command)
|
||||
{
|
||||
if (!GetTarget(command, out var player))
|
||||
return;
|
||||
|
||||
int time = 0;
|
||||
int.TryParse(command.GetArg(2), out time);
|
||||
|
||||
player!.Pawn.Value!.Freeze();
|
||||
|
||||
if (time > 0)
|
||||
AddTimer(time, () => player.Pawn.Value!.Unfreeze());
|
||||
|
||||
Server.PrintToChatAll(Helper.ReplaceTags($" {Config.Prefix} {Config.Messages.AdminFreezeMessage}".Replace("{ADMIN}", caller?.PlayerName == null ? "Console" : caller.PlayerName).Replace("{PLAYER}", player.PlayerName)));
|
||||
}
|
||||
|
||||
[ConsoleCommand("css_unfreeze", "Unfreeze a player.")]
|
||||
[CommandHelper(1, "<#userid or name>")]
|
||||
[RequiresPermissions("@css/slay")]
|
||||
public void OnUnfreezeCommand(CCSPlayerController? caller, CommandInfo command)
|
||||
{
|
||||
if (!GetTarget(command, out var player))
|
||||
return;
|
||||
|
||||
player!.Pawn.Value!.Unfreeze();
|
||||
|
||||
Server.PrintToChatAll(Helper.ReplaceTags($" {Config.Prefix} {Config.Messages.AdminUnFreezeMessage}".Replace("{ADMIN}", caller?.PlayerName == null ? "Console" : caller.PlayerName).Replace("{PLAYER}", player.PlayerName)));
|
||||
}
|
||||
|
||||
[ConsoleCommand("css_respawn", "Respawn a dead player.")]
|
||||
[CommandHelper(1, "<#userid or name>")]
|
||||
[RequiresPermissions("@css/cheats")]
|
||||
public void OnRespawnCommand(CCSPlayerController? caller, CommandInfo command)
|
||||
{
|
||||
if (!GetTarget(command, out var player))
|
||||
return;
|
||||
|
||||
player!.Respawn();
|
||||
|
||||
Server.PrintToChatAll(Helper.ReplaceTags($" {Config.Prefix} {Config.Messages.AdminRespawnMessage}".Replace("{ADMIN}", caller?.PlayerName == null ? "Console" : caller.PlayerName).Replace("{PLAYER}", player.PlayerName)));
|
||||
}
|
||||
|
||||
[ConsoleCommand("css_cvar", "Change a cvar.")]
|
||||
[CommandHelper(2, "<cvar> <value>")]
|
||||
[RequiresPermissions("@css/cvar")]
|
||||
public void OnCvarCommand(CCSPlayerController? caller, CommandInfo command)
|
||||
{
|
||||
var cvar = ConVar.Find(command.GetArg(1));
|
||||
|
||||
if (cvar == null)
|
||||
{
|
||||
command.ReplyToCommand($"Cvar \"{command.GetArg(1)}\" not found.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (cvar.Name.Equals("sv_cheats") && !AdminManager.PlayerHasPermissions(caller, "@css/cheats"))
|
||||
{
|
||||
command.ReplyToCommand($"You don't have permissions to change \"{command.GetArg(1)}\".");
|
||||
return;
|
||||
}
|
||||
|
||||
var value = command.GetArg(2);
|
||||
|
||||
Server.ExecuteCommand($"{cvar.Name} {value}");
|
||||
|
||||
command.ReplyToCommand($"{caller!.PlayerName} changed cvar {cvar.Name} to {value}.");
|
||||
Logger.LogInformation($"{caller.PlayerName} changed cvar {cvar.Name} to {value}.");
|
||||
}
|
||||
|
||||
[ConsoleCommand("css_rcon", "Run a server console command.")]
|
||||
[CommandHelper(1, "<command>")]
|
||||
[RequiresPermissions("@css/rcon")]
|
||||
public void OnRcomCommand(CCSPlayerController? caller, CommandInfo command)
|
||||
{
|
||||
Server.ExecuteCommand(command.ArgString);
|
||||
|
||||
Logger.LogInformation($"{caller!.PlayerName} executed command ({command.ArgString}).");
|
||||
}
|
||||
|
||||
|
||||
|
||||
private static bool GetTarget(CommandInfo command, out CCSPlayerController? player)
|
||||
{
|
||||
|
||||
12
Config.cs
12
Config.cs
@@ -24,12 +24,22 @@ namespace CS2_SimpleAdmin
|
||||
public string AdminSlapMessage { get; set; } = "Admin {ADMIN} slapped {PLAYER}!";
|
||||
[JsonPropertyName("AdminChangeMap")]
|
||||
public string AdminChangeMap { get; set; } = "Admin {ADMIN} changed map to {MAP}!";
|
||||
[JsonPropertyName("AdminNoclipMessage")]
|
||||
public string AdminNoclipMessage { get; set; } = "Admin {ADMIN} toggled noclip for {PLAYER}!";
|
||||
[JsonPropertyName("AdminFreezeMessage")]
|
||||
public string AdminFreezeMessage { get; set; } = "Admin {ADMIN} freezed {PLAYER}!";
|
||||
[JsonPropertyName("AdminUnFreezeMessage")]
|
||||
public string AdminUnFreezeMessage { get; set; } = "Admin {ADMIN} unfreezed {PLAYER}!";
|
||||
[JsonPropertyName("AdminRespawnMessage")]
|
||||
public string AdminRespawnMessage { get; set; } = "Admin {ADMIN} respawned {PLAYER}!";
|
||||
[JsonPropertyName("AdminSayPrefix")]
|
||||
public string AdminSayPrefix { get; set; } = "{RED}ADMIN: {DEFAULT}";
|
||||
[JsonPropertyName("AdminHelpCommand")]
|
||||
public string AdminHelpCommand { get; set; } = "{GREEN}[ CS2-SimpleAdmin HELP ]{DEFAULT}\n- css_ban <#userid or name> [time in minutes/0 perm] [reason] - Ban player\n- css_kick <#userid or name> [reason] - Kick player\n" +
|
||||
"- css_slay <#userid or name> - Kill player\n- css_slap <#userid or name> [damage] - Slap player\n- css_map <mapname> - Change map\n- css_say <message> - Say message as admin in chat\n" +
|
||||
"- css_psay <#userid or name> <message> - Sends private message to player\n- css_csay <message> - Say message as admin in center\n- css_hsay <message> - Say message as admin in hud";
|
||||
"- css_psay <#userid or name> <message> - Sends private message to player\n- css_csay <message> - Say message as admin in center\n- css_hsay <message> - Say message as admin in hud\n" +
|
||||
"- css_noclip <#userid or name> - Toggle noclip for player\n- css_freeze <#userid or name> [duration] - Freeze player\n- css_unfreeze <#userid or name> - Unfreeze player\n" +
|
||||
"- css_respawn <#userid or name> - Respawn player\n- css_cvar <cvar> <value> - Change cvar value\n- css_rcon <command> - Run command as server";
|
||||
}
|
||||
|
||||
public class CS2_SimpleAdminConfig : BasePluginConfig
|
||||
|
||||
25
README.md
25
README.md
@@ -7,15 +7,22 @@ Manage your Counter-Strike 2 server by simple commands :)
|
||||
It's only plugin base, I don't have much time for more extensive development, so if you want to help, do it :)
|
||||
|
||||
### Commands
|
||||
- css_ban <#userid or name> [time in minutes/0 perm] [reason] - Ban player
|
||||
- css_kick <#userid or name> [reason] - Kick player
|
||||
- css_slay <#userid or name> - Kill player
|
||||
- css_slap <#userid or name> [damage] - Slap player
|
||||
- css_map <mapname> - Change map
|
||||
- css_say <message> - Say message as admin in chat
|
||||
- css_psay <#userid or name> <message> - Sends private message to player
|
||||
- css_csay <message> - Say message as admin in center
|
||||
- css_hsay <message> - Say message as admin in hud
|
||||
- css_admin - Display all admin commands // @css/generic
|
||||
- css_ban <#userid or name> [time in minutes/0 perm] [reason] - Ban player // @css/ban
|
||||
- css_kick <#userid or name> [reason] - Kick player / @css/kick
|
||||
- css_slay <#userid or name> - Kill player // @css/slay
|
||||
- css_slap <#userid or name> [damage] - Slap player // @css/slay
|
||||
- css_map <mapname> - Change map // @css/map
|
||||
- css_say <message> - Say message as admin in chat // @css/chat
|
||||
- css_psay <#userid or name> <message> - Sends private message to player // @css/chat
|
||||
- css_csay <message> - Say message as admin in center // @css/chat
|
||||
- css_hsay <message> - Say message as admin in hud // @css/chat
|
||||
- css_noclip <#userid or name> - Toggle noclip for player // @css/cheats
|
||||
- css_freeze <#userid or name> [duration] - Freeze player // @css/slay
|
||||
- css_unfreeze <#userid or name> - Unfreeze player // @css/slay
|
||||
- css_respawn <#userid or name> - Respawn player // @css/cheats
|
||||
- css_cvar <cvar> <value> - Change cvar value // @css/cvar
|
||||
- css_rcon <command> - Run command as server // @css/rcon
|
||||
|
||||
|
||||
### Requirments
|
||||
|
||||
Reference in New Issue
Block a user