Config Problems

Discussion in 'Rust Development' started by DylanSMR, Apr 4, 2016.

  1. Code:
            void LoadDefaultConfig()
            {
                Config.Clear();
                //Interest//
                Config["Interest - Enabled"] = true;
                Config["Interest - Rate"] = 10.0;
                Config["Interest - Timer"] = 15;
                Config["Interest - IncreaseP"] = 0.5;
                Config["Interest - RaiseM"] = 60;
                Config["Interest - MaxInterest"] = 75.0;
                Config["Interest - MinInterest"] = 10.0;
                Config["Interest - InterestLostOnDeath"] = 1.0;
                //Starting Eco//
                Config["Starter - RustDollars"] = 1000;
                //General Config//
                Config["Economics - MaxRustDollars"] = 1000000;
                Config.Save();
            }        public int InterestTimer = Convert.ToInt32(Config["Interest - Rate"]);      
    
    Returns this when I attempt to launch the plugin-

    Code:
    [Oxide] 16:20 [Error] EnhancedEconomics plugin failed to compile!
    [Oxide] 16:20 [Error] EnhancedEconomics.cs(46,52): error CS0236: A field initializer cannot reference the nonstatic field, method, or property `Oxide.Core.Plugins.Plugin.Config'
     
  2. Wulf

    Wulf Community Admin

    Why does InterestTimer need to be public? Try nothing (default of private) or setting it to private.
     
  3. Set it to nothing as well tried private neither works. Still gives me a error.
     
  4. You need to move it to the Init()

    Code:
    int InterestTimer;void Init()
    {
          InterestTimer = Convert.ToInt32(Config["Interest - Rate"]);
    }