InfoPanel

Moved

Total Downloads: 55,749 - First Release: Sep 25, 2015 - Last Update: Mar 13, 2018

5/5, 160 likes
  1. Code:
    { using System;
    using System.Collections.Generic;using Oxide.Core.Plugins;namespace Oxide.Plugins
    {
        [Info("ApiTest", "Ghosst", "1.0.0")]
        [Description("OnlinePlayers Counter.")]
        public class ApiTest : RustPlugin
        {        Timer CounterTimer;
            Timer BlinkTimer;
            Timer RandPTimer;        int Count = 0;
            bool IsActive = true;        string RandomPlayerID;        bool RandomPlayername = false;
            bool Blinker = false;
            bool CounterP = false;        List<string> Panels = new List<string> { "BlinkPanel", "CounterPanel", "RandomPlayernamePanel" };        [PluginReference]
            Plugin InfoPanel;
            void Loaded()
            {
                if(InfoPanel)
                {
                    InfoPanelInit();
                }
            }        void OnPluginLoaded(Plugin InfoPanel)
            {
                if (InfoPanel.Title == "InfoPanel")
                {
                    InfoPanelInit();
                }
            }        public void InfoPanelInit()
            {
                //Send Panel names to the infopanel.
                InfoPanel.Call("SendPanelInfo", "ApiTest", Panels);            AddRandomPlayerNamePanel();
                AddBlinkPanel();
                AddCounterPanel();            if (CounterTimer == null & CounterP)
                {
                    CounterTimer = timer.Repeat(5, 0, () => Counter());
                }            if (BlinkTimer == null & Blinker)
                {
                    BlinkTimer = timer.Repeat(5, 0, () => Blink());
                }            if (RandPTimer == null & RandomPlayername)
                {
                    RandPTimer = timer.Repeat(5, 0, () => RandomPlayer());
                }
        
            }        /// <summary>
            /// Load the panel
            /// </summary>
            public void AddRandomPlayerNamePanel()
            {
                RandomPlayername = (bool)InfoPanel.Call("PanelRegister", "ApiTest", "RandomPlayernamePanel", RndPlayerNameCfg);
            }        /// <summary>
            /// Load the panel.
            /// Show the panel everyone.
            /// </summary>
            public void AddBlinkPanel()
            {
                Blinker = (bool)InfoPanel.Call("PanelRegister", "ApiTest", "BlinkPanel", BlinkPCfg);
                InfoPanel.Call("ShowPanel", "ApiTest", "BlinkPanel");
            }        /// <summary>
            /// Load the panel.
            /// Show the panel everyone.
            /// </summary>
            public void AddCounterPanel()
            {
                CounterP = (bool)InfoPanel.Call("PanelRegister", "ApiTest", "CounterPanel", CounterPCfg);
                InfoPanel.Call("ShowPanel", "ApiTest", "CounterPanel");
            }        /// <summary>
            /// Hide or show the panel
            /// </summary>
            public void Blink()
            {
                if(IsActive)
                {
                    IsActive = false;
                    InfoPanel.Call("HidePanel", "ApiTest", "BlinkPanel");
                }
                else
                {
                    IsActive = true;
                    InfoPanel.Call("ShowPanel", "ApiTest", "BlinkPanel");
                }
            }        /// <summary>
            /// Refresh the counter to every active player.
            /// </summary>
            public void Counter()
            {
                Count += 5;            if (InfoPanel && CounterP)
                {
                    InfoPanel.Call("SetPanelAttribute", "ApiTest", "CounterPanelText", "Content", Count.ToString());
                    InfoPanel.Call("SetPanelAttribute", "ApiTest", "CounterPanelText", "FontColor", "0.6 0.1 0.1 1");
                    InfoPanel.Call("RefreshPanel", "ApiTest", "CounterPanel");
                }
            }        /// <summary>
            /// Show his name to a random player. But just only for him.
            /// </summary>
            public void RandomPlayer()
            {
                if(RandomPlayerID != null)
                    InfoPanel.Call("HidePanel", "ApiTest", "RandomPlayernamePanel", RandomPlayerID);            if(BasePlayer.activePlayerList.Count > 0)
                {                var rand = new System.Random();
                    BasePlayer player = BasePlayer.activePlayerList[rand.Next(BasePlayer.activePlayerList.Count)];
                    RandomPlayerID = player.UserIDString;                if (InfoPanel && RandomPlayername)
                    {
                        InfoPanel.Call("SetPanelAttribute", "ApiTest", "RandomPlayernamePanelText", "Content", player.displayName, RandomPlayerID);
                        InfoPanel.Call("SetPanelAttribute", "ApiTest", "RandomPlayernamePanelText", "FontColor", "0.2 0.3 0.5 1", RandomPlayerID);
                        InfoPanel.Call("ShowPanel", "ApiTest", "RandomPlayernamePanel", RandomPlayerID);
                    }
                }
        
            }        /*
                Example Configs. Theres is no required option.
            */        string RndPlayerNameCfg = @"
            {
                ""Autoload"": false,
                ""AnchorX"": ""Left"",
                ""AnchorY"": ""Bottom"",
                ""Available"": true,
                ""BackgroundColor"": ""0.1 0.1 0.1 0.4"",
                ""Dock"": ""BottomPanel"",
                ""Width"": 0.07,
                ""Height"": 0.95,
                ""Margin"": ""0 0 0 0.005"",
                ""Order"": 0,
                ""Image"": {
                  ""AnchorX"": ""Left"",
                  ""AnchorY"": ""Bottom"",
                  ""Available"": true,
                  ""BackgroundColor"": ""0.1 0.1 0.1 0.3"",
                  ""Dock"": ""BottomPanel"",
                  ""Height"": 0.8,
                  ""Margin"": ""0 0.05 0.1 0.05"",
                  ""Order"": 1,
                  ""Url"": ""http://i.imgur.com/dble6vf.png"",
                  ""Width"": 0.22
                },   
                ""Text"": {
                  ""Align"": ""MiddleCenter"",
                  ""AnchorX"": ""Left"",
                  ""AnchorY"": ""Bottom"",
                  ""Available"": true,
                  ""BackgroundColor"": ""0.1 0.1 0.1 0.3"",
                  ""Dock"": ""BottomPanel"",
                  ""FontColor"": ""1 1 1 1"",
                  ""FontSize"": 14,
                  ""Content"": ""APITest Bottom"",
                  ""Height"": 1.0,
                  ""Margin"": ""0 0 0 0"",
                  ""Order"": 2,
                  ""Width"": 0.63
                },
            }";        string BlinkPCfg = @"{}";        string CounterPCfg = @"
            {
                ""Dock"": ""TopPanel"",
                ""Text"": {
                    ""Content"": ""APITest Top""
                }
            }";
        }
    }}
     
  2. Wulf

    Wulf Community Admin

    I'm not sure what that is, but that isn't the plugin's config file.
     
  3. Strange. Im pulling that from oxide>config>InfoPanel.json

    Should I just delete the json and cs files and start a fresh install of InfoPanel?
     
  4. Wulf

    Wulf Community Admin

    Yes, the file you had wasn't a .json file either, it was a plugin.
     
  5. I ended up just deleting all the InfoPanel files and doing a clean install. Had some weird icons last night (white blocks with red question marks) but this morning its all loading fine.

    I read on the last page that you change the messages on InfoPanel in the LANG folder. Looking at our FTP, there is no InfoPanel file in oxide>lang. o_O
     
  6. Wulf

    Wulf Community Admin

    Are you sure you are using the latest version of it?
     
  7. Yeah, downloaded it fresh last night just in case.
     
  8. Just did a fresh install. got this
    Code:
    [Oxide] 3:17 PM [Error] InfoPanel v0.9.3: Failed to load config file (is the config file corrupt?) (After parsing a value an unexpected character was encountered: ". Path 'Messages[0]', line 34, position 5.)
    [Oxide] 3:17 PM [Error] Failed to initialize plugin 'InfoPanel v0.9.3' (JsonReaderException: After parsing a value an unexpected character was encountered: ". Path 'Messages[0]', line 34, position 5.)
    [Oxide] 3:17 PM [Debug]   at Newtonsoft.Json.JsonTextReader.ParsePostValue () [0x00000] in <filename unknown>:0
      at Newtonsoft.Json.JsonTextReader.ReadInternal () [0x00000] in <filename unknown>:0
      at Newtonsoft.Json.JsonReader.ReadAsStringInternal () [0x00000] in <filename unknown>:0
      at Newtonsoft.Json.JsonTextReader.ReadAsString () [0x00000] in <filename unknown>:0
      at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.ReadForType (Newtonsoft.Json.JsonReader reader, Newtonsoft.Json.Serialization.JsonContract contract, Boolean hasConverter) [0x00000] in <filename unknown>:0
      at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateList (IList list, Newtonsoft.Json.JsonReader reader, Newtonsoft.Json.Serialization.JsonArrayContract contract, Newtonsoft.Json.Serialization.JsonProperty containerProperty, System.String id) [0x00000] in <filename unknown>:0
    [Oxide] 3:17 PM [Info] Unloaded plugin InfoPanel v0.9.3 by Ghosst
    [Oxide] 3:17 PM [Info] No previous version to rollback plugin: InfoPanel
     
    Last edited by a moderator: Mar 18, 2016
  9. Wulf

    Wulf Community Admin

    What host are you using? Did you edit anything?
     
  10. Can you upload the InfoPanel.json from the config folder and the InfoPanel_db.json from the data folder so it can be checked
     
  11. Didn't edit the code, only the json file. here are the codes
     

    Attached Files:

  12. Here is your fixed file you forgot the , after "THIS IS DARKTOPIA!!!!"
     

    Attached Files:

  13. Lifesaver, thanks!!
     
  14. Ok, Ive been fighting with changing the messages on InfoPanel for a week now and I'm ready to scream!

    .cs and .json files are attached, I THINK I'm editing the json correctly but the messages are not updating. It still has the stupid LEEEEEEEROY JENKINS there. I've completely removed InfoPanel and performed a fresh install about 5 times and I give up!

    Each time, I download a fresh copy of the json file and edit that and re-add via FireFTP.

    Help!
     

    Attached Files:

  15. Wulf

    Wulf Community Admin

    The messages are in oxide/lang, you do not edit them in the plugin directly.
     
  16. There is no InfoPanel file under lang.

    [​IMG]
     
  17. Wulf

    Wulf Community Admin

    Hmm, I guess it still uses the config for it. Did you reload the plugin after making the changes? Did you validate it first before reloading? A single missing comma or other wrongly formatted entries will cause it to reset to default.
     
  18. While new to Oxide and Rust Admin'ing, I thought I was a fairly savvy guy before this! I've tried everything and made sure to include the same amount of spaces in every line as the default messages. Im literally only changing the 3-4 lines in the "messages" area of the code.

    My last effort will be to try and load the json file from Reply #892 to see if that loads. It apparently works for the that user!
     
  19. Wulf

    Wulf Community Admin

    JSON is a bit finicky. Was the previous file you attached your modified version?
     
  20. Did you reload the plugin after you done the changes in the config