Doesn't seem to load on startupFixed
Hello !
The plugin has been running on my server for a very long time! I want to let you know that:
There are problems I tested!
1 The plugin does not load itself on the restart server, it must be loaded manually!
2 Only sometimes does not read the settings (config)
ex I set the following cfg:
{
  "Add auto turret to heli": false,
  "Allow minicopter push": true,
  "Allow Minis to Land on Cargo": true,
  "Auto turret uses battery": false,
  "Drop Storage Loot On Death": true,
  "Fuel per Second": 0.25,
  "Large Storage Containers": 0,
  "Large Storage Lockable": true,
  "Large Storage Size (Max 42)": 42,
  "Lift Fraction": 0.25,
  "Light: Add Nightitme Tail Light": true,
  "Light: Add Searchlight to heli": true,
  "Mini Turret Range (Default 30)": 30.0,
  "Pitch Torque Scale": 400.0,
  "Reload Storage": false,
  "Restore Defaults": true,
  "Roll Torque Scale": 200.0,
  "Seconds to pause flyhack when dismount from heli.": 1,
  "Storage Containers": 0,
  "Yaw Torque Scale": 400.0
}​


the o.reload MiniCopterOptions command:

Unloaded plugin Mini-Copter Options v2.0.31 by Pho3niX90
[Mini-Copter Options] Applying settings except storage modifications to existing MiniCopters.
[Mini-Copter Options] Defaults for copters saved as
fuelPerSecond = 0.5
liftFraction = 0.25
torqueScale = (1600.0, 1600.0, 800.0)
Loaded plugin Mini-Copter Options v2.0.31 by Pho3niX90
Same here, I have to manually load it after each start up
yes but the big problem is here:
torqueScale = (1600.0, 1600.0, 800.0)
does not load my settings:
Pitch Torque Scale ": 400.0,
Roll Torque Scale ": 200.0,
Yaw Torque Scale ": 400.0
If it shows that it was Unloaded, it was indeed loaded already. If you simply mean that it isn't taking effect, that is an entirely different matter.
not sir! the server has been restarted and the plugin does not load, I gave the manual command to reload "o.reload"
but my configuration is not respected by the plugin! I am running a server with over 120 plugins I am somewhat familiar with the settings and I know how it works! I am not an expert in this so I am writing here!
The reload command as you used it is only used when a plugin is already loaded. If a plugin was not loaded on startup, only the load command would work and it wouldn't show that the plugin was unloaded. 
The code of this plugin seems mildly confusing so the fix isn't obvious without investing more time. The plugin author is not allowing patches from other developers via uMod and the GitHub link link goes nowhere (possibly a private repo).

I seem to have found two bugs.
  1. Changing settings and reloading the plugin does not apply the settings to minicopters that were already spawned. This appears to be due to the fact that the OnServerInitialized() method has unreachable code, so the log statement "Applying settings except storage modifications to existing MiniCopters" is misleading as it is doing no such thing.
  2. Loading a save or reloading the plugin will capture incorrect defaults. The plugin captures defaults so that minicopters can be restored to vanilla when the plugin is unloaded. However, while loading a save, the OnEntitySpawned() hook is called for all minicopters, which sets their settings to match the plugin configuration. This is done before OnServerInitialized() which captures the defaults, so the captured defaults correspond to an existing mini, which may reflect the current configuration or a previous configuration due to the other bug above.
perfectly true !
I am also seeing this behavior when the server is started, the plugin does not load and produces this error
Failed to initialize plugin 'MiniCopterOptions v2.0.31' (NullReferenceException: Object reference not set to an instance of an object)
  at Oxide.Plugins.MiniCopterOptions.Loaded () [0x00021] in <35c4943ad92f4db9a1166b2116095c1a>:0
  at Oxide.Plugins.MiniCopterOptions.DirectCallHook (System.String name, System.Object& ret, System.Object[] args) [0x00038] in <35c4943ad92f4db9a1166b2116095c1a>:0
  at Oxide.Plugins.CSharpPlugin.InvokeMethod (Oxide.Core.Plugins.HookMethod method, System.Object[] args) [0x00079] in <d09a1f46ca2f4432811bcfe45ad13c7b>:0
  at Oxide.Core.Plugins.CSPlugin.OnCallHook (System.String name, System.Object[] args) [0x000d8] in <cf88a28c7fb44d36890d85a78331cc9d>:0
  at Oxide.Plugins.CSharpPlugin.HandleAddedToManager (Oxide.Core.Plugins.PluginManager manager) [0x0006e] in <d09a1f46ca2f4432811bcfe45ad13c7b>:0
Unloaded plugin Mini-Copter Options v2.0.31 by Pho3niX90​
If I then manually load the plugin after the server starts, the plugin loads.
ALANMAN
I am also seeing this behavior when the server is started, the plugin does not load and produces this error
Failed to initialize plugin 'MiniCopterOptions v2.0.31' (NullReferenceException: Object reference not set to an instance of an object)
  at Oxide.Plugins.MiniCopterOptions.Loaded () [0x00021] in <35c4943ad92f4db9a1166b2116095c1a>:0
  at Oxide.Plugins.MiniCopterOptions.DirectCallHook (System.String name, System.Object& ret, System.Object[] args) [0x00038] in <35c4943ad92f4db9a1166b2116095c1a>:0
  at Oxide.Plugins.CSharpPlugin.InvokeMethod (Oxide.Core.Plugins.HookMethod method, System.Object[] args) [0x00079] in <d09a1f46ca2f4432811bcfe45ad13c7b>:0
  at Oxide.Core.Plugins.CSPlugin.OnCallHook (System.String name, System.Object[] args) [0x000d8] in <cf88a28c7fb44d36890d85a78331cc9d>:0
  at Oxide.Plugins.CSharpPlugin.HandleAddedToManager (Oxide.Core.Plugins.PluginManager manager) [0x0006e] in <d09a1f46ca2f4432811bcfe45ad13c7b>:0
Unloaded plugin Mini-Copter Options v2.0.31 by Pho3niX90​
If I then manually load the plugin after the server starts, the plugin loads.
That is likely caused by the plugin trying to handle TOD stuff before the server has made them available.

This code:
            if (config.lightTail) {
                time = TOD_Sky.Instance;
                sunrise = time.SunriseTime;
                sunset = time.SunsetTime;

                time.Components.Time.OnHour += OnHour;
            }​

... should be moved inside the existing OnServerInitialized() hook further down the plugin.

        void OnServerInitialized() {
            if (config.lightTail) {
                time = TOD_Sky.Instance;
                sunrise = time.SunriseTime;
                sunset = time.SunsetTime;

                time.Components.Time.OnHour += OnHour;
            }

            PrintWarning("Applying settings except storage modifications to existing MiniCopters.");
            foreach (var copter in UnityEngine.Object.FindObjectsOfType<MiniCopter>()) {
                // Nab the default values off the first minicopter.
                if (copterDefaults.Equals(default(MiniCopterDefaults))) {
                    StoreMiniCopterDefaults(copter);
                    break;
                }

                if (config.landOnCargo) copter.gameObject.AddComponent<MiniShipLandingGear>();

                ModifyMiniCopter(copter, config.reloadStorage);
            }
        }

Loaded() should also be changed to Init(), as there's no need to delay that to after the plugin has loaded.

The first change appears to allow the plugin to load. But when I change Loaded () to Init() I get this error:

Error while compiling: MiniCopterOptions.cs(553,22): error CS0111: A member `Oxide.Plugins.MiniCopterOptions.Init()' is already defined. Rename this member or use different parameter types
That's because there's already an Init() method in the plugin, so instead of just renaming Loaded() to Init(), the contents of Loaded() should be merged into Init().
Thanks for the reply. That is beyond my limited understanding of plugins and code in general. It does technically work now without the last part changed.
This should now be resolved in v2.0.35
Locked automatically