Skip to content
This repository has been archived by the owner on Feb 9, 2025. It is now read-only.

Commit

Permalink
1.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
oqyh authored May 12, 2024
1 parent c394d5b commit 9868a14
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 6 deletions.
2 changes: 2 additions & 0 deletions Config/Configs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ public class ConfigData
{
public bool MVP_UseMySql { get; set; }
public bool MVP_ForceDisableDefaultMVP_ToAll { get; set; }
public bool MVP_ChangeMVPMenuFromChatToCentre { get; set; }
public string MVP_InGameMenu { get; set; }
public string MVP_VipMusicKit { get; set; }
public string MVP_OnlyAllowTheseGroupsCanMVP { get; set; }
Expand All @@ -106,6 +107,7 @@ public ConfigData()
{
MVP_UseMySql = false;
MVP_ForceDisableDefaultMVP_ToAll = false;
MVP_ChangeMVPMenuFromChatToCentre = true;
MVP_InGameMenu = "!mvp,!mvps,!mvpsound";
MVP_VipMusicKit = "@css/root,@css/admin,@css/vip,#css/admin,#css/vip";
MVP_OnlyAllowTheseGroupsCanMVP = "";
Expand Down
56 changes: 50 additions & 6 deletions MVP-Sounds-GoldKingZ.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace MVP_Sounds_GoldKingZ;
public class MVPSoundsGoldKingZ : BasePlugin
{
public override string ModuleName => "Custom MVP Sounds (Custom MVP Sounds + Vips)";
public override string ModuleVersion => "1.0.0";
public override string ModuleVersion => "1.0.1";
public override string ModuleAuthor => "Gold KingZ";
public override string ModuleDescription => "https://github.com/oqyh";
internal static IStringLocalizer? Stringlocalizer;
Expand Down Expand Up @@ -178,7 +178,15 @@ public HookResult OnEventPlayerChat(EventPlayerChat @event, GameEventInfo info)
string jsonData = File.ReadAllText(jsonFilePath);
var data = JsonConvert.DeserializeObject<Dictionary<string, Dictionary<string, string>>>(jsonData);
if (data == null) return HookResult.Continue;
var VoteGameModeMenu = new CenterHtmlMenu(Localizer["menu.music"]);
IMenu VoteGameModeMenu;
if (Configs.GetConfigData().MVP_ChangeMVPMenuFromChatToCentre)
{
VoteGameModeMenu = new CenterHtmlMenu(Localizer["menu.music"]);
}
else
{
VoteGameModeMenu = new ChatMenu(Localizer["menu.music"]);
}
VoteGameModeMenu.AddMenuOption(Localizer["menu.disabled"], (Player, option) => HandleMenu(Player, option, string.Empty, false, false));
foreach (var key in data.Keys)
{
Expand All @@ -187,8 +195,21 @@ public HookResult OnEventPlayerChat(EventPlayerChat @event, GameEventInfo info)
bool isPreviewAble = data[key].ContainsKey("CanBePreview") && bool.TryParse(data[key]["CanBePreview"].ToString(), out bool PreviewValue) ? PreviewValue : false;
VoteGameModeMenu.AddMenuOption(ChoosenKitKey, (Player, option) => HandleMenu(Player, option, key, isVIP, isPreviewAble));
}

MenuManager.OpenCenterHtmlMenu(this, Player, VoteGameModeMenu);
if (Configs.GetConfigData().MVP_ChangeMVPMenuFromChatToCentre)
{
if (VoteGameModeMenu is CenterHtmlMenu centerHtmlMenu)
{
MenuManager.OpenCenterHtmlMenu(this, Player, centerHtmlMenu);
}
}
else
{
if (VoteGameModeMenu is ChatMenu chatMenu)
{
MenuManager.OpenChatMenu(Player, chatMenu);
}
}

}catch{}
}
return HookResult.Continue;
Expand Down Expand Up @@ -248,14 +269,37 @@ private void HandleMenu(CCSPlayerController Player, ChatMenuOption option, strin
if(isPreviewAble)
{
var choosedkit = option.Text;
var VoteGameModeMenu = new CenterHtmlMenu(Localizer["menu.are.you.sure", choosedkit]);

IMenu VoteGameModeMenu;
if (Configs.GetConfigData().MVP_ChangeMVPMenuFromChatToCentre)
{
VoteGameModeMenu = new CenterHtmlMenu(Localizer["menu.are.you.sure", choosedkit]);
}
else
{
VoteGameModeMenu = new ChatMenu(Localizer["menu.are.you.sure", choosedkit]);
}

string[] answers = { Localizer["menu.answer.yes"], Localizer["menu.answer.no"]};

foreach (string answer in answers)
{
VoteGameModeMenu.AddMenuOption(answer, (Player, option) => HandleMenu2(Player, option, ChoosenKitKey, isVIP, isPreviewAble, choosedkit));
}
MenuManager.OpenCenterHtmlMenu(this, Player, VoteGameModeMenu);
if (Configs.GetConfigData().MVP_ChangeMVPMenuFromChatToCentre)
{
if (VoteGameModeMenu is CenterHtmlMenu centerHtmlMenu)
{
MenuManager.OpenCenterHtmlMenu(this, Player, centerHtmlMenu);
}
}
else
{
if (VoteGameModeMenu is ChatMenu chatMenu)
{
MenuManager.OpenChatMenu(Player, chatMenu);
}
}
return;
}
if (!Globals.Choosed_MVP.ContainsKey(Player.SteamID))
Expand Down

0 comments on commit 9868a14

Please sign in to comment.