As when clicking on the button, call the command on behalf of the player?
ex. backpack.open
Cui button command
Discussion in 'Rust Development' started by eed, May 31, 2017.
-
This is a part of one of my plugins. You pretty much just add Command = "", to the button
Code:alarmbuttons.Add(new CuiButton{ Button ={Command = "rustalerts.close all",Color = "0 255 0 0"}, RectTransform ={AnchorMin = GetPercent(1449,210),AnchorMax = GetPercent(1481,178)}, Text ={Text = "",FontSize = 22,Align = TextAnchor.MiddleCenter} },"buttonoverlay");
-
hook press inventory button dont work? Solved - Listening for key input? | Oxide -
Code:FORWARD BACKWARD LEFT RIGHT JUMP DUCK SPRINT USE FIRE_PRIMARY FIRE_SECONDARY RELOAD FIRE_THIRD
-
refresh or remove cui
Superimposed on each other
Code:private void tpCdShow(BasePlayer player) { timer.Once(1f, () => tpCdShow(player)); string scd = NTeleportation?.CallHook("GetCooldownRemaining",player, "home").ToString(); //Puts(NTeleportation?.CallHook("GetCooldownRemaining",player, "home").ToString()); if(scd == null) return; //Puts("123"); var elements = new CuiElementContainer(); elements.Add(new CuiLabel { Text = { Text = scd, FontSize = 18, }, RectTransform = { AnchorMin = "0 0", AnchorMax = "1 1" } }); //Puts(NTeleportation?.CallHook("GetCooldownRemaining",player, "home").ToString()); CuiHelper.AddUi(player, elements); CuiHelper.DestroyUi(player, "elements"); }
Attached Files:
-
-
Code:CuiHelper.DestroyUi(player, "elements"); CuiHelper.AddUi(player, elements);
-
Screenshot -
-
example cui+timer pls. -
Code:
var alarmdataui = new CuiElementContainer(); alarmdataui.Add(new CuiPanel{ Image ={Color = "0.1 0.1 0.1 0"}, RectTransform ={AnchorMin = "0 0",AnchorMax = "1 1"} }, "Hud", "cuinameexample"); CuiHelper.DestroyUi(player,"cuinameexample"); timer.Once(0.1f, () => { if(AlarmGui.stage!=2){ CuiHelper.AddUi(player,alarmdataui); } });
-
dont destroy
Code:private void tpCdShow(BasePlayer player) { timer.Once(1f, () => tpCdShow(player)); string scd = NTeleportation?.CallHook("GetCooldownRemaining", player, "home").ToString(); if (scd == null) return; var teleportcd = new CuiElementContainer(); teleportcd.Add(new CuiPanel{ Image ={Color = "0.1 0.1 0.1 0"}, RectTransform ={AnchorMin = "0 0",AnchorMax = "1 1"} }, "Hud", "cuinameexample"); teleportcd.Add(new CuiLabel { Text = { Text = i.ToString(), FontSize = 18, }, RectTransform = { AnchorMin = "0 0", AnchorMax = "1 1" } }); i++; CuiHelper.DestroyUi(player, "cuinameexample"); CuiHelper.AddUi(player, teleportcd); }
-
You need to parent thelabel to cuinameexample
-
Screenshot
With this figured out, thank you. But does this affect FPS?Last edited by a moderator: Jun 3, 2017 -
if its like "hud", "teleportcd" hud is the parent teleportcd is the name you don't need to put a name for everything, but it is good to put a parent. So all you have to do for the second one is just add }, "teleportcd" and don't have another part and then "teleportcd" would be the parent
[DOUBLEPOST=1496472282][/DOUBLEPOST]Its better to reply then update an old post imo. Im on and off my computer right now, but you shouldn't have them both the same name if i recall -
Code:
var mainName = elements.Add(new CuiPanel { Image = { //Url = "http://gamestores.ru/img/plugin_new.png" Color = "0.1 0.1 0.1 0.7" }, RectTransform = { // слева - длина AnchorMin = "0.000 0.90", // снизу - высота AnchorMax = "0.077 0.925" }, CursorEnabled = false }, "Hud", "mainName2"); elements.Add(new CuiElement() { Parent = "mainName2", Name = "ui.store.buttonimage", Components = { //vk new CuiRawImageComponent { Sprite = "assets/content/textures/generic/fulltransparent.tga", Url = "https://s8.hostingkartinok.com/uploads/images/2017/06/34b4d26b5f0cf6380692da0750aa9e6f.png" }, new CuiRectTransformComponent() { AnchorMin = "0.02 0.14", AnchorMax = "0.17 0.86" } } }); elements.Add(new CuiLabel { Text = { Text = "/athreemrustserver", FontSize = 10, }, RectTransform = { AnchorMin = "0.015 0.905", AnchorMax = "0.097 0.920" } }, "Hud", "mainName2");
Code:CuiHelper.DestroyUi(player, "mainName2");
-
try this i'm not inigame yet to see what the problem is, but i think the problem was that you where namaing something twice
Code:var mainName = elements.Add(new CuiPanel { Image = { //Url = "http://gamestores.ru/img/plugin_new.png" Color = "0.1 0.1 0.1 0.7" }, RectTransform = { // слева - длина AnchorMin = "0.000 0.90", // снизу - высота AnchorMax = "0.077 0.925" }, CursorEnabled = false }, "Hud", "mainName2"); elements.Add(new CuiElement() { Parent = "mainName2", Name = "ui.store.buttonimage", Components = { //vk new CuiRawImageComponent { Sprite = "assets/content/textures/generic/fulltransparent.tga", Url = "https://s8.hostingkartinok.com/uploads/images/2017/06/34b4d26b5f0cf6380692da0750aa9e6f.png" }, new CuiRectTransformComponent() { AnchorMin = "0.02 0.14", AnchorMax = "0.17 0.86" } } }); elements.Add(new CuiLabel { Text = { Text = "/athreemrustserver", FontSize = 10, }, RectTransform = { AnchorMin = "0.015 0.905", AnchorMax = "0.097 0.920" } },"mainName2");