1. I'm trying to create a custom help plugin for my server and when I uploaded it to my server, I get this message.
    Screenshot
     
  2. Wulf

    Wulf Community Admin

    I'd need to see the full log and code, but that looks like an error specific to that plugin and something it is trying to cast to.
     
  3. I'm using code from another plugin to help with this, but I figure since I'm the only one using it, there shouldn't be an issue.

    Code:
    using Oxide.Game.Rust.Libraries;
    using Newtonsoft.Json.Linq;
    using Newtonsoft.Json;
    using UnityEngine;
    using System.Linq;
    using Oxide.Core;
    using System;namespace Oxide.Plugins
    {    [Info("Help Text", "Alpha Toon", "1.0.0")]
        class HelpText : RustPlugin
        {        #region Configuration Data        private bool configChanged;        // Plugin settings
            private const string DefaultChatPrefix = "Alpha Gaming";
            private const string DefaultChatPrefixColor = "#008000ff";        public string ChatPrefix { get; private set; }
            public string ChatPrefixColor { get; private set; }        //Plugin options
            private const string DefaultHelpText = "Insert text here";        public string HelpText { get; private set; }        #endregion        private void Init() => LoadConfigValues();
            protected override void LoadDefaultConfig() => PrintWarning("New configuration file created.")        [ChatCommand("help")]
            private void Help(BasePlayer player, string command, string[] args)
            {
                SendMessage(player, HelpText)
            }        private void LoadConfigValues()
            {
                // Plugin settings
                ChatPrefix = GetConfigValue("Settings", "ChatPrefix", DefaultChatPrefix);
                ChatPrefixColor = GetConfigValue("Settings", "ChatPrefixColor", DefaultChatPrefixColor);
               
                //Plugin options
                HelpText = GetConfigValue("Messages", "HelpText", DefaultHelpText);            if (!configChanged) return;
                PrintWarning("Configuration file updated.");
                SaveConfig();
            }        private T GetConfigValue<T>(string category, string setting, T defaultValue)
            {
                var data = Config[category] as Dictionary<string, object>;
                object value;
                if (data == null)
                {
                    data = new Dictionary<string, object>();
                    Config[category] = data;
                    configChanged = true;
                }
                if (data.TryGetValue(setting, out value)) return (T)Convert.ChangeType(value, typeof(T));
                value = defaultValue;
                data[setting] = value;
                configChanged = true;
                return (T)Convert.ChangeType(value, typeof(T));
            }        private void SetConfigValue<T>(string category, string setting, T newValue)
            {
                var data = Config[category] as Dictionary<string, object>;
                object value;
                if (data != null && data.TryGetValue(setting, out value))
                {
                    value = newValue;
                    data[setting] = value;
                    configChanged = true;
                }
                SaveConfig();
            }        private void SendMessage(BasePlayer player, string message, params object[] args) => player?.SendConsoleCommand("chat.add", -1, string.Format($"<color={ChatPrefixColor}>{ChatPrefix}</color>: {message}", args), 1.0);
        }
    }
    
     
  4. Wulf

    Wulf Community Admin

    Since the error in your screenshot isn't lining up to the code you showed me, I'm going to assume something is wrong with your config with a config option not being what the compiler expects it to be. You may want to trim it down and start with the basics to understand everything that is happening in the plugin.
     
  5. After adding the plugin to the server, it didn't seem to create a config/.json file.
     
  6. Wulf

    Wulf Community Admin

    That would also point toward there being an issue with the config code in the plugin. ;)
     
  7. I'm just going to scrap the idea of having a config file for myself as I guess it's more complicated that it seems to me. I think it'll be easier for me just to add what I want directly into the file. Thanks for the help though.
     
  8. Wulf

    Wulf Community Admin

    There are easier ways to make a config, a lot of the plugins do a lot of advanced checking that you likely don't need.
     
  9. If I'm not mistaken then you're missing multiple semicolons:
    protected override void LoadDefaultConfig() => PrintWarning("New configuration file created.")
    SendMessage(player, HelpText)
     
  10. Wulf

    Wulf Community Admin

    Good eye! ;)
     
  11. I have found an alternative to what I originally was using, but the config file is left blank even though I defined what should be put into the file.
     
  12. Wulf

    Wulf Community Admin

    Your plugin may be fixed by what sqroot noticed above, but if a config isn't being generated, the file was likely already created so you'd need to tell the plugin to update it by checking or forcing it to load again.
     
  13. Fixed it myself.
     
    Last edited by a moderator: Jun 9, 2016