1. Hi!

    I am getting the following error when unloading my plugin:

    Code:
    [Oxide] 18:54 [Error] Failed to call hook 'ConsoleUnload' on plugin 'RustCore v1.0.0' (NullReferenceException: Object reference not set to an instance of an object)
    [Oxide] 18:54 [Debug]   at Oxide.Core.Libraries.Timer+TimerInstance.Remove () [0x00000] in <filename unknown>:0
      at Oxide.Core.Libraries.Timer+TimerInstance.Destroy () [0x00000] in <filename unknown>:0
      at Oxide.Core.Libraries.Timer+TimerInstance.OnRemovedFromManager (Oxide.Core.Plugins.Plugin sender, Oxide.Core.Plugins.PluginManager manager) [0x00000] in <filename unknown>:0
      at Oxide.Core.Event`2[T1,T2].Invoke (.T1 arg0, .T2 arg1) [0x00000] in <filename unknown>:0
      at Oxide.Core.Plugins.Plugin.HandleRemovedFromManager (Oxide.Core.Plugins.PluginManager manager) [0x00000] in <filename unknown>:0
      at Oxide.Plugins.CSharpPlugin.HandleRemovedFromManager (Oxide.Core.Plugins.PluginManager manager) [0x00000] in <filename unknown>:0
      at Oxide.Core.Plugins.PluginManager.RemovePlugin (Oxide.Core.Plugins.Plugin plugin) [0x00000] in <filename unknown>:0
      at Oxide.Core.OxideMod.UnloadPlugin (System.String name) [0x00000] in <filename unknown>:0
      at Oxide.Game.Rust.RustCore.ConsoleUnload (.Arg arg) [0x00000] in <filename unknown>:0
      at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (object,object[],System.Exception&)
      at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0
    I have attached the plugin as it is easier than explaining here how it uses the timer library.
    I am using the latest version of oxide, I noticed there were a lot of changes to the timer library. I believe this is an issue with the timer library itself? But I could be wrong and it might be with the way I have created timers to be destroyed later. I have commented out anything called in the unload method within my plugin just out of curiosity but that has made no difference.

    All help is appreciated!
     

    Attached Files:

    Last edited by a moderator: Jun 3, 2016
  2. Wulf

    Wulf Community Admin

    Update Oxide and it should be fixed.
     
  3. @Wulf Awesome work, though I am afraid I now get this NRE, again with unloading:

    Code:
    [Oxide] 19:22 [Error] Exception while calling NextTick callback (NullReferenceException: Object reference not set to an instance of an object)
    [Oxide] 19:22 [Debug]   at Oxide.Core.Libraries.Timer+TimerInstance.Remove () [0x00000] in <filename unknown>:0
      at Oxide.Core.Libraries.Timer+TimerInstance.Destroy () [0x00000] in <filename unknown>:0
      at Oxide.Core.Libraries.Timer+TimerInstance.OnRemovedFromManager (Oxide.Core.Plugins.Plugin sender, Oxide.Core.Plugins.PluginManager manager) [0x00000] in <filename unknown>:0
      at Oxide.Core.Event`2[T1,T2].Invoke (.T1 arg0, .T2 arg1) [0x00000] in <filename unknown>:0
      at Oxide.Core.Plugins.Plugin.HandleRemovedFromManager (Oxide.Core.Plugins.PluginManager manager) [0x00000] in <filename unknown>:0
      at Oxide.Plugins.CSharpPlugin.HandleRemovedFromManager (Oxide.Core.Plugins.PluginManager manager) [0x00000] in <filename unknown>:0
      at Oxide.Core.Plugins.PluginManager.RemovePlugin (Oxide.Core.Plugins.Plugin plugin) [0x00000] in <filename unknown>:0
      at Oxide.Core.OxideMod.UnloadPlugin (System.String name) [0x00000] in <filename unknown>:0
      at Oxide.Plugins.CSharpPluginLoader.<CompileAssembly>m__2 (Oxide.Plugins.Compilation compilation) [0x00000] in <filename unknown>:0
      at Oxide.Plugins.Compilation.<Completed>m__2 () [0x00000] in <filename unknown>:0
      at Oxide.Core.OxideMod.OnFrame (Single delta) [0x00000] in <filename unknown>:0
     
  4. Wulf

    Wulf Community Admin

    What's the output of oxide.version?
     
  5. I was literally just editing my post to add that in :)

    2.0.1998
     
  6. Is this happening because in my plugin I have the variable:
    Code:
    var timerInstance = new Oxide.Core.Libraries.Timer.TimerInstance(null, 1000, 1000, null, this);
    Where the parameter Timer is null?
     
    Last edited by a moderator: Jun 3, 2016
  7. Wulf

    Wulf Community Admin

    That's an example of the WRONG way to use the timer library.., you may want to consider doing it using the normal API, which you can find info about in the Docs. ;)
     
  8. I was using that so that I could store timers in a variable and destroy them later. It was working well before changes had been made.
     
  9. Wulf

    Wulf Community Admin

    You can store a timer in a variable using the actual API, what you are doing is tsk tsk and will likely break other plugins too.
     
  10. Don't you tsk tsk at me! ;)

    I shall do my homework in that case!
     
  11. Wulf

    Wulf Community Admin

    var timerName = timer.Repeat(10f, 0, ... ... etc)...
     
  12. Or you shall do it for me ;)
    Holy crap though why on earth did I ever go about doing it the way I have...
     
  13. Having a slight issue with destroying the timer now.

    In the plugin class scope I have:
    Code:
    Timer GlobalTimer;
    I have in one method:
    Code:
    var GlobalTimer = timer.Once(msgShowDuration, () => destroyGlobalGUI());
    And in another method I have:
    Code:
    if(GlobalTimer != null && !GlobalTimer.Destroyed)
                {
                    Puts("Timer not destroyed");
                    GlobalTimer.Destroy();
                }
    But it always thinks that GlobalTimer is null. Just wandering if anyone can spot what I am doing wrong?
     
  14. Wulf

    Wulf Community Admin

    Are you sure the timer is still set? It's only a Once timer, so once it runs it will be destroyed.
     
  15. You're redeclaring GlobalTimer as local variable and shadowing your GlobalTimer in the class scope.
    What you're looking for is GlobalTimer = timer.Once(msgShowDuration, () => destroyGlobalGUI());.