void OnServerInitialized() => BasePlayer.activePlayerList.ForEach(p => OnPlayerInit(p));
void OnPlayerInit(BasePlayer player)
{
if (player.IsReceivingSnapshot)
{
timer.In(1f, () => OnPlayerInit(player));
return;
}
RenderUI(player);
}
private void RenderUI(BasePlayer player)
{
CuiHelper.DestroyUi(player, "DownTextLayer");
CuiElementContainer Container = new CuiElementContainer();
Container.Add(new CuiElement
{
Name = "DownTextLayer",
Parent = "Hud",
Components =
{
new CuiTextComponent
{
Text = "My Text",
Align = TextAnchor.MiddleCenter,
FontSize = 14,
Font = "robotocondensed-bold.ttf"
},
new CuiRectTransformComponent
{
AnchorMin = "0.5 0",
AnchorMax = "0.5 0",
OffsetMin = "-200 0",
OffsetMax = "200 20"
}
}
});
CuiHelper.AddUi(player, Container);
}