1. So I have this code, and I am trying to change my config value to a float so this will work. However it isn't working, and I don't know enough to know why. Perhaps someone can help?

    Error: Cannot cast from source type to destination type.

    Code:
    Code:
    namespace Oxide.Plugins
    {
        [Info("Quarry Health", "AnExiledGod", 1.0)]
        [Description("Changes the health value of quarries.")]
        public class QuarryHealth : RustPlugin
        {
            protected override void LoadDefaultConfig()
            {
                PrintWarning("Creating a new configuration file.");
                Config.Clear();            Config["quarry_health"] = 2500f;            SaveConfig();
            }        void Loaded()
            {
                var quarries = UnityEngine.Object.FindObjectsOfType<MiningQuarry>();            foreach (MiningQuarry quarry in quarries)
                {
                    quarry.health = (float) Config["quarry_health"];
                }
            }
        }
    }
    
     
  2. Do you have a config file created already? If not you would be trying to convert a null to float.
     
  3. Yes, the config file is created already.
     
  4. Just a thought, is it possible the "Loaded" function is being called before the config is loaded? I've always used "OnServerInitialized" to do stuff. Might be that "Loaded" is called before the config is even loaded.
     
  5. That's a good idea, but OnServerInitalized also didn't work. :(
     
  6. I'll run your code on my test server tonight and see if i can figure it out. Not seeing it now..
     
  7. You will see the issue if you change the config value then reload the plugin. It will give the type cast error.
     
  8. Working fine on my end? I get no error...
     
  9. Alright, still happening for me.

    Steps to Reproduce
    1. Load Plugin. (A message saying new config is being made.)
    2. Open config. Change value to 600.0
    3. Run "oxide.reload QuarryHealth"

    This is when you get the error. For a minute, I was somehow able to get it to work, but it was completely random as far as I could tell.
    [DOUBLEPOST=1435301409][/DOUBLEPOST]Alright, I figured it out. I figured this out before when I made my first plugin, but didn't remember it until now. -_-

    I had the same issue with floats in the past. All I need to do is put this at the top:

    Code:
    public float quarryHealth { get { return Config.Get<float>("quarry_health"); } }
    Then call it like so:

    Code:
    quarry.health = quarryHealth;
    I do appreciate you helping me out, wish I'd remembered sooner, this has been driving me crazy for a while now lol.
     
  10. Weird, I don't see why the other method didn't work for you, works fine on my server.
     
  11. Yeah, I've noticed a few things act weird on my local, not sure what is wrong. might need to refresh my setup.