Alright. It seems like this is a question that many people ask but I've not seen a single answer yet that can help me. That's why I really would appreciate if someone could tell me in details on how to create a plugin in C#. I've got the basics of C# and everything but I can't find any guides on how to start developing Oxide Plugins.
Thanks.
- Where do I start?
- What DLLs are needed?
- Etc..
Creating plugins in C#?
Discussion in 'Rust Development' started by Jompe, Dec 20, 2016.
-
Hello,
Where to start => Look at the docs and plugins.
What dll => all from RustDedicated_Data\Managed
etc => got some ideas and look at same plugins. -
-Visual Studios, perhaps with ReSharper
- SEVERAL links including Classes | Oxide or Solved - Getting started in plugin development? | Oxide
Look at simple plugins to begin with and understand the process of developing a plugin. -
- Taken all DLLs from RustDedicated_Data\Managed except the ones inside RustDedicated_Data\Managed\x86 and x64. (68 DLLs in total)
- Started a C# Project and added all DLLs as references by using the browse button.
- I then get a error and all DLLs are not imported. (Counted them in references, to the right inside Visual Studio)
The Error:
Code:A reference to 'C:\Users\Jonathan\Desktop\Rust DLLS\mscorlib.dll' could not be added. This component is already automatically referenced by the build system.
-
You have to deselect system and mscorlib if i remember
-
- I now have all the references that I need.
- What does Puts("Hello.") do? (My understaning is that this will print something to the console?)
- What do I do now? (I've tested around and got this but it does not seem to be working.)
Code:namespace Oxide.Plugins { [Info("Test", "Jompe", 1.0)] public class Class1 : RustPlugin { void Loaded() { Puts("Testing.."); } } }
-
well, your base code should look like
Code:namespace Oxide.Plugins { [Info("PTest", "sami37", "1.0.0")] [Description("New plugin")] class PTest : RustPlugin { void Loaded() { Puts("Loaded"); } } }
-
Alright.. I got it working..
Thanks, really appreciate it!
What I did:
- Change RustPlugin to CovalencePlugin. (What's the difference?)
- Added using Oxide.Core.Libraries.Covalence; as a part of CovalencePlugin.
- Found out that Puts() prints something to the console.
Code:using Oxide.Core.Libraries.Covalence;namespace Oxide.Plugins { [Info("TestPlugin", "Jompe", 1.0)] public class MyPlugin : CovalencePlugin { [Command("test")] void TestCommand(IPlayer player, string command, string[] args) { player.Reply("Test Successful!"); Puts("Testing Puts.."); } } }
-
Wulf Community Admin
-
-
Wulf Community Admin
-
-
Wulf Community Admin
-
-
I've gotten into it more and more now but my new question is now how to get the group that the player currently is in.
-
Wulf Community Admin
Prefix with permission. -
I tried to copy from Github but GetUserData get's marked red..
Code:[LibraryFunction("GetUserGroups")] public string[] GetUserGroups(string id) => GetUserData(id).Groups.ToArray();
-
Wulf Community Admin