mirror of
https://github.com/daffyyyy/CS2-SimpleAdmin.git
synced 2026-02-17 18:39:07 +00:00
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
|
||||||
{
|
{
|
||||||
[JsonPropertyName("ConfigVersion")] public override int Version { get; set; } = 7;
|
[JsonPropertyName("ConfigVersion")] public override int Version { get; set; } = 7;
|
||||||
@@ -57,5 +67,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)));
|
||||||
|
|||||||
Reference in New Issue
Block a user