mirror of
https://github.com/daffyyyy/CS2-SimpleAdmin.git
synced 2026-09-27 20:17:04 +02:00
Working custom server commands
This commit is contained in:
parent
5bf966f9cd
commit
5d58465c74
2 changed files with 28 additions and 1 deletions
13
Config.cs
13
Config.cs
|
|
@ -12,6 +12,16 @@ namespace CS2_SimpleAdmin
|
||||||
public string DiscordPenaltyWebhook { get; set; } = "";
|
public string DiscordPenaltyWebhook { get; set; } = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class CustomServerCommandData
|
||||||
|
{
|
||||||
|
[JsonPropertyName("Flag")]
|
||||||
|
public string Flag { get; set; } = "@css/generic";
|
||||||
|
[JsonPropertyName("DisplayName")]
|
||||||
|
public string DisplayName { get; set; } = "";
|
||||||
|
[JsonPropertyName("Command")]
|
||||||
|
public string Command { get; set; } = "";
|
||||||
|
}
|
||||||
|
|
||||||
public class CS2_SimpleAdminConfig : BasePluginConfig
|
public class CS2_SimpleAdminConfig : BasePluginConfig
|
||||||
{
|
{
|
||||||
public override int Version { get; set; } = 6;
|
public override int Version { get; set; } = 6;
|
||||||
|
|
@ -54,5 +64,8 @@ namespace CS2_SimpleAdmin
|
||||||
|
|
||||||
[JsonPropertyName("WorkshopMaps")]
|
[JsonPropertyName("WorkshopMaps")]
|
||||||
public List<string> WorkshopMaps { get; set; } = new List<string>();
|
public List<string> WorkshopMaps { get; set; } = new List<string>();
|
||||||
|
|
||||||
|
[JsonPropertyName("CustomServerCommands")]
|
||||||
|
public List<CustomServerCommandData> CustomServerCommands { get; set; } = new List<CustomServerCommandData>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
using CounterStrikeSharp.API;
|
||||||
using CounterStrikeSharp.API.Core;
|
using CounterStrikeSharp.API.Core;
|
||||||
using CounterStrikeSharp.API.Modules.Admin;
|
using CounterStrikeSharp.API.Modules.Admin;
|
||||||
using CounterStrikeSharp.API.Modules.Menu;
|
using CounterStrikeSharp.API.Modules.Menu;
|
||||||
|
|
@ -34,6 +35,19 @@ namespace CS2_SimpleAdmin.Menus
|
||||||
|
|
||||||
options.Add(new ChatMenuOptionData("Restart Game", () => CS2_SimpleAdmin.RestartGame(admin)));
|
options.Add(new ChatMenuOptionData("Restart Game", () => CS2_SimpleAdmin.RestartGame(admin)));
|
||||||
|
|
||||||
|
List<CustomServerCommandData> customCommands = CS2_SimpleAdmin.Instance.Config.CustomServerCommands;
|
||||||
|
foreach (CustomServerCommandData customCommand in customCommands)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(customCommand.DisplayName) || string.IsNullOrEmpty(customCommand.Command))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
bool hasRights = AdminManager.PlayerHasPermissions(admin, customCommand.Flag);
|
||||||
|
if (!hasRights)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
options.Add(new ChatMenuOptionData(customCommand.DisplayName, () => Server.ExecuteCommand(customCommand.Command)));
|
||||||
|
}
|
||||||
|
|
||||||
foreach (ChatMenuOptionData menuOptionData in options)
|
foreach (ChatMenuOptionData menuOptionData in options)
|
||||||
{
|
{
|
||||||
string menuName = menuOptionData.name;
|
string menuName = menuOptionData.name;
|
||||||
|
|
@ -48,7 +62,7 @@ namespace CS2_SimpleAdmin.Menus
|
||||||
BaseMenu menu = AdminMenu.CreateMenu($"Change Map");
|
BaseMenu menu = AdminMenu.CreateMenu($"Change Map");
|
||||||
List<ChatMenuOptionData> options = new();
|
List<ChatMenuOptionData> options = new();
|
||||||
|
|
||||||
List<string> maps = CS2_SimpleAdmin.Instance.Config.DefaultMaps;//Server.GetMapList();
|
List<string> maps = CS2_SimpleAdmin.Instance.Config.DefaultMaps;
|
||||||
foreach (string map in maps)
|
foreach (string map in maps)
|
||||||
{
|
{
|
||||||
options.Add(new ChatMenuOptionData(map, () => ExecuteChangeMap(admin, map, false)));
|
options.Add(new ChatMenuOptionData(map, () => ExecuteChangeMap(admin, map, false)));
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue