I'm pretty sure this a common question and has been answered many times but this just isn't working for me.
I'm just starting out with C# so go easy if I ask something stoopid please
I have created two basic plugins, the first plugin is below:
Additional plugins feed data into the first:Code:using System; using System.Linq;using Rust;using Oxide.Plugins; using Oxide.Core.Plugins;namespace Oxide.Plugins { [Info("Something", "Rebajas", "2016.12.17")] [Description("Something")] public class EventLogger : RustPlugin { public void AppendToLog() { Puts("AppendToLog function called"); } }}
My problem at the moment is that I'm not seeing the AppendToLog Puts fire when the OnLootPlayer event triggers. Every example I've seen so far seems the same so I don't really know what else to change.Code:... [PluginReference] Plugin EventLogger; void OnLootPlayer(BasePlayer player, BasePlayer target) { EventLogger?.Call("AppendToLog"); }
Thanks in advance for any help.
Tony.
Solved Calling function from another plugin?
Discussion in 'Rust Development' started by Rebajas, Dec 18, 2016.
-
Got it working!
Had a public class then a public method - didn't like it -
Wulf Community Admin
-
Hey Wulf,
Can you expand upon this a bit?
I want to reference another plugin directly, without having to use [PluginReference]. I want to be able to call public methods from that class as well as use the public data classes inside of it.
How can I go about reference the instance of this plugin?
Thanks!
Adam
[DOUBLEPOST=1482280005][/DOUBLEPOST]Bah, right as i posted this i figured it out.
// Requires: ClassType
at the top.
I'm leaving all this here incase anyone else has the same problem! -
Wulf Community Admin
-
Hey Wulf,
I'm still having some issues.
My script looks like this:
Code:// Requires: OtherClassnamespace Oxide.Plugins { [Info("MyClass", "EinTime", "1.1.1")] class MyClass : RustPlugin { private static OtherClass otherClass; void Loaded() { otherClass = (OtherClass)plugins.Find(nameof(OtherClass)); } } }
Could this be a compilation order issue? Or an issue with getting the OtherClass reference from inside Loaded() ? -
Wulf Community Admin
-
If using // Requires, and not using plugins.Find or a cast how do I get a reference to the instance of OtherClass?
-
Wulf Community Admin
-
Awesome. Thanks so much for your time Wulf!