Files
plugin/utils/info.cs
2026-07-07 16:36:30 +02:00

53 lines
1.2 KiB
C#

using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Modules.Menu;
namespace Porning;
class Info
{
private string message = "";
private BasePlugin plugin = null!;
private CenterHtmlMenu? menu = null;
private Action? callback = null;
public Info(BasePlugin plugin, string message)
{
this.plugin = plugin;
this.message = $"<font color=\"red\">Porning</font><br>{message}";
}
public void Show(CCSPlayerController? player=null)
{
menu = new CenterHtmlMenu(message, plugin)
{
ExitButton = false
};
if (player !=null)
{
MenuManager.OpenCenterHtmlMenu(plugin, player, menu);
} else
{
foreach (CCSPlayerController p in Utilities.GetPlayers())
{
MenuManager.OpenCenterHtmlMenu(plugin, p, menu);
}
}
plugin.AddTimer(5.0f, Close);
}
public void Close()
{
foreach (CCSPlayerController player in Utilities.GetPlayers())
{
MenuManager.CloseActiveMenu(player);
}
callback?.Invoke();
}
public void OnClose(Action callback)
{
this.callback = callback;
}
}