1. I am building quite a complex and large plugin, so i love to split the plugin files like this:

    File A.cs
    Code:
    // Requires: B
    // Requires: Cnamespace Oxide.Plugins
    {
        [Info("A", "Test", "1.0.0")]    public class A : RustPlugin
        {
            B b = new B();
            C c = new C();
          
            void Init()
            {
                b.Setup(this);
                c.Setup(this);
            }
        }
    }
    File B.cs
    Code:
    namespace Oxide.Plugins
    {
        [Info("B", "Test", "1.0.0")]    public class B : RustPlugin
        {
            A a;
          
            public void Setup(A a)
            {
                this.a = a;
            }
          
            void Foo()
            {
                Puts("Foo");
            }
        }
    }
    
    File C.cs
    Code:
    namespace Oxide.Plugins
    {
        [Info("C", "Test", "1.0.0")]    public class C : RustPlugin
        {
            A a;
          
            public void Setup(A a)
            {
                this.a = a;
              
                this.a.b.Foo();
            }
        }
    }
    
    I tried adding
    Code:
    // Requires: A
    to both files C and B, but then it gets stuck because it has to wait on each other.
     
  2. Wulf

    Wulf Community Admin

    If referencing other plugins using // Requires, those methods would need to be public, not private. All dependent plugins will load after their parent has been loaded.
     
  3. I've changed my startpost, making those methods public, however, how can i pass the instance of the parent to its requiring child?
     
  4. Wulf

    Wulf Community Admin

    You just call the methods you want from it based on the namespace used. Basically would use them as you would any other C# reference. If these are actual plugins (you have plugin headers), then they'd need to be in the plugins folder, not include.
     
  5. I am a bit confused, do you have an example?
     
  6. Wulf

    Wulf Community Admin

    If you're calling from B to A, then you'd use A.Init() (assuming Init() is public, not in your example).
     
  7. Ahhh, i see... Got it working now :)

    Foo.cs
    Code:
    // Requires: Bar
    // Requires: Yaynamespace Oxide.Plugins
    {
        [Info("Foo", "Test", "1.0.0")]    public class Foo : RustPlugin
        {       
            public string x = "Hello World!";
           
            public Bar bar = new Bar();
            public Yay yay = new Yay();
       
            void Init()
            {
                bar.Setup(this);
                yay.Setup(this);
            }
        }
    }
    Bar.cs
    Code:
    namespace Oxide.Plugins
    {
        [Info("Bar", "Test", "1.0.0")]    public class Bar : RustPlugin
        {   
            private Foo foo = null;
       
            public void Setup(Foo foo)
            {
                this.foo = foo;
            }
           
            public void DoStuff()
            {
                Puts("Thanks wulf :)");
            }
        }
    }
    Yay.cs
    Code:
    namespace Oxide.Plugins
    {
        [Info("Yay", "Test", "1.0.0")]    public class Yay : RustPlugin
        {   
            private Foo foo = null;
       
            public void Setup(Foo foo)
            {
                this.foo = foo;
               
                this.foo.bar.DoStuff();
            }
        }
    }
    Results in
    Code:
    Foo plugin is waiting for requirements to be loaded: Bar and Yay
    Loaded plugin Yay v1.0.0 by Test
    Foo plugin is waiting for requirements to be loaded: Bar
    Loaded plugin Bar v1.0.0 by Test
    [Bar] Thanks wulf :)
    Loaded plugin Foo v1.0.0 by Test
    Thanks!

    ---

    Then one small other thing, to load plugin requirements i should use
    Code:
    // Requires: Yay
    and when i want plain C# classes i should use
    Code:
    // Require: Yay
    ?