Skip to content

Commit

Permalink
css_admin command
Browse files Browse the repository at this point in the history
Added css_admin command for displaying all commands
  • Loading branch information
daffyyyy committed Dec 2, 2023
1 parent 0a0c0cf commit 68a446a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
18 changes: 16 additions & 2 deletions CS2-SimpleAdmin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
public override string ModuleName => "CS2-SimpleAdmin";
public override string ModuleDescription => "";
public override string ModuleAuthor => "daffyy";
public override string ModuleVersion => "1.0.0";
public override string ModuleVersion => "1.0.1";

public CS2_SimpleAdminConfig Config { get; set; } = new();

Expand Down Expand Up @@ -80,6 +80,20 @@ public void OnConfigParsed(CS2_SimpleAdminConfig config)
Config = config;
}

[ConsoleCommand("css_admin")]
[RequiresPermissions("@css/generic")]
public void OnAdminCommand(CCSPlayerController? caller, CommandInfo command)
{
if (caller == null || !caller.IsValid) return;

var splitMessage = Config.Messages.AdminHelpCommand.Split(new[] { "\r\n", "\r", "\n" }, StringSplitOptions.None);

foreach (var line in splitMessage)
{
caller.PrintToChat(Helper.ReplaceTags($" {line}"));
}
}

[ConsoleCommand("css_kick")]
[RequiresPermissions("@css/kick")]
[CommandHelper(minArgs: 1, usage: "<#userid or name> [reason]", whoCanExecute: CommandUsage.CLIENT_AND_SERVER)]
Expand Down Expand Up @@ -211,7 +225,7 @@ public void OnMapCommand(CCSPlayerController? caller, CommandInfo command)
[RequiresPermissions("@css/chat")]
public void OnAdminSayCommand(CCSPlayerController? caller, CommandInfo command)
{
Server.PrintToChatAll(Helper.ReplaceTags(Config.Messages.AdminSayPrefix + command.GetCommandString[command.GetCommandString.IndexOf(' ')..]));
Server.PrintToChatAll(Helper.ReplaceTags($" {Config.Messages.AdminSayPrefix} {command.GetCommandString[command.GetCommandString.IndexOf(' ')..]}"));
}

[ConsoleCommand("css_psay", "Private message a player.")]
Expand Down
7 changes: 5 additions & 2 deletions Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,11 @@ public class Messages
[JsonPropertyName("AdminChangeMap")]
public string AdminChangeMap { get; set; } = "Admin {ADMIN} changed map to {MAP}!";
[JsonPropertyName("AdminSayPrefix")]
public string AdminSayPrefix { get; set; } = "{RED}ADMIN: {DEFAULT}!";

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";
}

public class CS2_SimpleAdminConfig : BasePluginConfig
Expand Down

0 comments on commit 68a446a

Please sign in to comment.