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"" } }"; } }}
InfoPanel
Moved
Total Downloads: 55,749 - First Release: Sep 25, 2015 - Last Update: Mar 13, 2018
- 5/5, 160 likes
-
Wulf Community Admin
-
Should I just delete the json and cs files and start a fresh install of InfoPanel? -
Wulf Community Admin
-
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. -
Wulf Community Admin
-
-
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 -
Wulf Community Admin
-
-
Didn't edit the code, only the json file. here are the codes
Attached Files:
-
-
Attached Files:
-
-
Lifesaver, thanks!!
-
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:
-
-
Wulf Community Admin
-
-
Wulf Community Admin
-
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! -
Wulf Community Admin
-