1. While working with localization library i found possible bug with oxide in csharp plugins. Variable plugin.Name is baseplugin if call inside class initialization function. Here example with logs:

    Code:
    using System.Collections.Generic;
    using System.Linq;
    using Oxide.Core;
    using Oxide.Core.Libraries;
    using Oxide.Core.Plugins;namespace Oxide.Plugins
    {
        [Info("Test C#", "AlexALX", "0.0.1")]
        public class Test : RustPlugin
        {
            public Test()
            {
                Puts("Class init: "+this.Name);
            }
          
            [HookMethod("Init")]
            void Init()
            {
                Puts("Init hook: "+this.Name);
            }  
        }
      
    }
    Code:
    [Oxide] 9:31 AM [Info] Test was compiled successfully in 140ms
    [Oxide] 9:31 AM [Info] Unloaded plugin Test C# v0.0.1 by AlexALX
    [Oxide] 9:31 AM [Info] Class init: baseplugin
    [Oxide] 9:31 AM [Info] Loaded plugin Test C# v0.0.1 by AlexALX
    [Oxide] 9:31 AM [Info] Init hook: Test
    Not sure if it can be called like "bug" or so, but still reporting, if its not bug then sorry. Also i can just add warning/error in this case for my localization library if function called before plugin inited.
     
    Last edited by a moderator: May 4, 2015
  2. Does not seems to be a bug, constructor is called earlier than initialization of the plugin.

    I would advise not to use constructors, or at least use it just for simple things such as initialization of fields, arrays, collections or so.
    Avoid using constructors for accessing the game API or Oxide API and you will be fine.
     
  3. Constructors should not be used by plugins at all. You can use the Loaded hook instead.
     
  4. Hm, then here is question - how to detect that C# plugin already loaded? I mean not in plugin itself, and in library if it have only Plugin argument. By calling something like if (plugin.Name=="baseplugin") i think is stupid, but i can't find any "IsLoaded" variable or so in Csharp plugin class itself.
     
  5. dude I am trying to reach to you private conversation but it's failed