void GenerateMenu(BasePlayer player)
{
string time = GetTime();
UpdatePlayers();
var players = currentplayers;
var max = maxplayers;
var sleepers = currentsleepers;
string bradleycol = GetBradCol();
string helicol = GetHeliCol();
var main = "box";
var container = new CuiElementContainer();
var panel = container.Add(new CuiPanel
{
Image =
{
Color = "0.4 0.4 0.4 1"
},
RectTransform =
{
AnchorMin = "0 0.90",
AnchorMax = "0.05 1"
}
}, "Overlay", main);
var clockimage = new CuiElement
{
Name = CuiHelper.GetGuid(),
Parent = panel,
Components =
{
new CuiRawImageComponent{Url = "https://i.imgur.com/cSykHxd.png"},
new CuiRectTransformComponent{AnchorMin = "0.1 0.80", AnchorMax = "0.25 0.92"},
}
};
container.Add(clockimage);
var paneltime = new CuiElement
{
Name = CuiHelper.GetGuid(),
Parent = panel,
Components =
{
new CuiTextComponent{Text = time, Color = "1 1 1 1", FontSize = 10, Align = TextAnchor.MiddleCenter},
new CuiRectTransformComponent{AnchorMin = "0.2 0.70", AnchorMax = "1 1"},
}
};
container.Add(paneltime);
var playerimage = new CuiElement
{
Name = CuiHelper.GetGuid(),
Parent = panel,
Components =
{
new CuiRawImageComponent{Url = "https://i.imgur.com/TP01GYf.png"},
new CuiRectTransformComponent{AnchorMin = "0.1 0.60", AnchorMax = "0.25 0.72"}
}
};
container.Add(playerimage);
var panelplayers = new CuiElement
{
Name = CuiHelper.GetGuid(),
Parent = panel,
Components =
{
new CuiTextComponent{Text = $"{players}/{max}", Color = "1 1 1 1", FontSize = 10, Align = TextAnchor.MiddleCenter},
new CuiRectTransformComponent{AnchorMin = "0.2 0.50", AnchorMax = "1 0.85"},
}
};
container.Add(panelplayers);
var sleeperimage = new CuiElement
{
Name = CuiHelper.GetGuid(),
Parent = panel,
Components =
{
new CuiRawImageComponent{Url = "https://i.imgur.com/spdF7sR.png"},
new CuiRectTransformComponent{AnchorMin = "0.1 0.40", AnchorMax = "0.25 0.52"}
}
};
container.Add(sleeperimage);
var panelsleepers = new CuiElement
{
Name = CuiHelper.GetGuid(),
Parent = panel,
Components =
{
new CuiTextComponent{Text = sleepers.ToString(), Color = "1 1 1 1", FontSize = 10, Align = TextAnchor.MiddleCenter},
new CuiRectTransformComponent{AnchorMin = "0.2 0.30", AnchorMax = "1 0.65"},
}
};
container.Add(panelsleepers);
var bradleyimage = new CuiElement
{
Name = CuiHelper.GetGuid(),
Parent = panel,
Components =
{
new CuiRawImageComponent{Url = "https://i.imgur.com/VrYPrKI.png", Color = bradleycol},
new CuiRectTransformComponent{AnchorMin = "0.1 0.15", AnchorMax = "0.30 0.32"}
}
};
container.Add(bradleyimage);
var heliimage = new CuiElement
{
Name = CuiHelper.GetGuid(),
Parent = panel,
Components =
{
new CuiRawImageComponent{Url = "https://i.imgur.com/hTTyTTx.png", Color = helicol},
new CuiRectTransformComponent{AnchorMin = "0.4 0.15", AnchorMax = "0.60 0.32"}
}
};
container.Add(heliimage);
CuiHelper.AddUi(player, container);
}
void MakeMenu(BasePlayer player)
{
GenerateMenu(player);
}
void DestroyMenu(BasePlayer player)
{
CuiHelper.DestroyUi(player, "box");
}
void UpdateUI(BasePlayer player)
{
DestroyMenu(player);
MakeMenu(player);
}I have this ui and in it there is a clock that displays the current in game time. I need this to refresh every 4.5 seconds. I did that by adding a timer to excecute the updateui function. However as the ui has pictures, when it refreshes every 4.5 seconds, the pictures lag the ui. I want to make it so just the clock text (paneltime) updates, but I have no clue how to go about it. Can anybody help me?