1. miRror

    miRror Shack Builder Plugin Developer

    Code (Text):
    /*
    * Basic example to use CountDown and InputField
    *
    * Countdown: /ui.countdown
    * InputField: /ui.inputfield
    *
    */

    using Oxide.Game.Rust.Cui;

    namespace Oxide.Plugins
    {
        [Info("CommunityUI", "miRror", "1.0.0")]

        public class CommunityUI : RustPlugin
        {
            private string uiCountDown = @"
            [{
                ""name"": ""uiCountDown"",
                ""components"":
                [
                    {
                        ""type"": ""CountDown"",
                        ""align"": ""MiddleCenter"",                
                        ""wrapperText"": ""Left %TIME_LEFT% seconds"",
                        ""timeLeft"": ""10"",                
                        ""fontSize"": ""30"",
                        ""font"": ""RobotoCondensed-Bold.ttf"",                
                        ""color"": ""0 0.7 0.5 1"",
                        ""command"": ""cui.test""
                    },
                    {
                        ""type"":""RectTransform"",
                        ""anchormin"": ""0 0"",
                        ""anchormax"": ""1 1""
                    }
                ]
            }]";

            private string uiInputField = @"
            [{
                ""name"": ""uiInputField"",
                ""parent"": ""Overlay"",
                ""components"":
                [
                    {
                         ""type"": ""UnityEngine.UI.Image"",
                         ""material"": ""assets/icons/greyout.mat"",
                         ""color"": ""0.1 0.1 0.1 0.97"",
                    },
                    {
                        ""type"": ""RectTransform"",
                        ""anchormin"": ""0.4 0.45"",
                        ""anchormax"": ""0.6 0.55""
                    },
                    {
                        ""type"": ""NeedsCursor""
                    }
                ]
            },    
            {
                ""parent"": ""uiInputField"",
                ""components"":
                [
                    {
                        ""type"":""UnityEngine.UI.Text"",
                        ""text"":""Enter message..."",
                        ""fontSize"": 30,
                        ""align"": ""MiddleCenter"",
                    },        
                    {
                        ""type"": ""InputField"",
                        ""command"": ""yourcommand "",
                    },
                    {
                        ""type"":""RectTransform"",
                        ""anchormin"": ""0 0"",
                        ""anchormax"": ""1 1""
                    }
                ]
            }]";
       
       
            private void Unload()
            {
                foreach(BasePlayer player in BasePlayer.activePlayerList)
                {
                    CuiHelper.DestroyUi(player, "uiCountDown");
                    CuiHelper.DestroyUi(player, "uiInputField");
                }                
            }
       
            [ChatCommand("ui.countdown")]
            private void cmdChatCountdown(BasePlayer player, string command, string[] args)
            {
                CuiHelper.DestroyUi(player, "uiCountDown");
                CuiHelper.AddUi(player, uiCountDown);
            }

            [ChatCommand("ui.inputfield")]
            private void cmdChatInputField(BasePlayer player, string command, string[] args)
            {
                CuiHelper.DestroyUi(player, "uiInputField");
                CuiHelper.AddUi(player, uiInputField);
            }    
        }
    }
    But InputField does not worked. Who made a mistake? Component developer or i in my plugin.

    See more: GitHub - Facepunch/rust-community: Community Entity to fill Server Side modder requests
     
    Last edited: Apr 15, 2017
    mTrX likes this.
  2. mTrX

    mTrX Scavenger

    Awesome! Oh sorry didn't see they do not work. Gonna try it out.
     
  3. Wulf

    Wulf Community Admin Community Admin Oxide Developer

    That PR was pretty old, so would be surprised if it worked 100%.
     
  4. miRror

    miRror Shack Builder Plugin Developer