1. Plugin Development?

    A compiled/mismashed list of steps/notes/resources from others, to understand Oxide C# Plugin Development

    Rust Plugin List ------> Rust | Oxide

    Prequisites
    Developing
    Installing
    Learn C#
    ===========================
    Notes


    1. Get Visual Studio 2015

    Visual studio 2015 Community Edition: https://www.visualstudio.com/en-us/products/vs-2015-product-editions.aspx

    ==========================

    2. Get a decompiler

    Decompile the rust dlls with a tool like Telerik JustDecompiler free .NET decompiler to figure out the methods rust uses and then just call them in your plugin. or Jetbrains

    ===========================

    3. Setup a local development server
    - Get the server files through SteamCMD - Valve Developer Community,
    - http://oxidemod.org/threads/setting-up-a-rust-server-with-windows.5743/

    ===========================

    4. Install Oxide
    - http://oxidemod.org/downloads/oxide-for-rust.1659/

    You need to install Oxide on your local server to have the Oxide references.

    You use the Oxide.Ext.Rust project in the Oxide solution for development and just need the .cs file when you deploy to a server.

    ===========================

    5. Create a bogus C# program
    in which you import all the required references

    You can create your Plugin [mod] within Visual Studio and compile it successfully. You just have to make sure that you have all the references that it requires to work.

    References I normally use for Rust is:

    assembly-CSharp.dll

    Oxide.Core.dll

    Oxide.Ext.CSharp.dll

    Oxide.Game.Rust.dll

    UnityEngine.dll

    Where to find Rust DLLs?

    Yeah this is where mine are (rust_server being the root of the server installation):

    Z:\steamcmd\rust_server\RustDedicated_Data\Managed

    To make the actual plugins you'll need to get an IDE (Visual Studio works well), import all of the references from the rust dedicated managed folder, this allows you to reference all of the ingame stuff, also ensure to reference the oxide rust dll's.From there, look at other plugins to get a basis of understanding how to start coding them. "

    RustDedicated_Data/Managed/Assembly-CSharp.dll (To Look At)

    When you create a new C# project in Visual Studio it will not have references to the Rust or Oxide DLL's. You need these references to be able to compile. To add new references to your empty project, on the right side you'll find the project tree and under your project you'll see a "folder" called references. You can right-click that folder and choose "Add reference". From there, choose "Browse" and browse to the RustDedicated_Data\Managed folder and add all needed references. You might not need all of the ones discussed in the other thread I linked depending on what the mod does, you might even need more than these, you'll see as you go. Having extra references won't hurt so don't worry about that.

    Oxide hook methods are shown in Docs: Oxide API for Rust.

    ==========================

    5. Build your mod offline, making sure it compiles

    It doesn't have to be a console app, could be a windows forms app, dll app, it's quite irrelevant as you'll never really run the resulting assembly. You're only using this project to make sure your code is compilable. When you send the .cs file to your server, Oxide will compile it and load it with it's own compiler/references.

    ==========================

    6. Send the cs file online (or test on that local server you downloaded)
    to server/yourserveridentity/oxide/plugins

    ==========================

    Advice:

    Any methods/functions/etc would need to be found by peeking at existing plugins, or doing your own digging into the Rust DLLs. The only things that Oxide provides right now is hooks, which are standard between plugin languages.

    Any Rust functions can be found in the decompiled Rust DLLs.

    Get a .NET decompiler, Telerik JustDecompiler, and open RustDedicated_Data/Managed/Assembly-CSharp.dll. Pretty much everything is in there, you just need to browse.

    Check out other plugins that are written in the language that you are interested in. Start from something simple.. like display your steamid on /mysteamid

    There are hundreds of plugins, each are an example of ways to do things. The Docs provided are basic and incomplete right now, but combined with the Oxide source and Rust DLL, you have all you really need. There are numerous threads around the forums on how to do various things, and if you get stuck, feel free to ask.

    It's hard to document methods, functions, etc for every game we support, especially when they often change multiple times a month

    There is no real "how-to" docs at the moment. Get a decompiler and look at Assembly-Csharp.dll for all the functions in the game, look at the docs for hooks that are implemented (most of the stuff you need is already hooked)

    A mix of looking at existing mods, reading documentation, browsing decompiled classes and code, etc. That's where we will spend most of our time when making plugins. Perseverance is king here.

    The biggest issue right now with making mods is the scarceness of information... you can look at other mods, you can decompile the game DLL's and get glimpses into what exists and what can be done, but there is no support other than this forum and looking at existing mods. When you start working your way out of what's been done before, it's really a R&D adventure with a lot of walls to hit. For instance Oxide is nice and all and gives you a bunch of hooks to do stuff with, but there's a lot more going on that you'd wish you could hook to.
     
    Last edited by a moderator: Feb 13, 2017
  2. Wulf

    Wulf Community Admin

    Just a few pointers:
    • The recommended project type is a class, as you do not need forms, windows, etc.
    • You do not need to compile your plugin to test it for errors, Visual Studio will show those to you live
    • You can have many of the default references setup by using the Oxide repo and putting your plugin under the plugins folder
    • There is no Oxide.Ext.Rust project, it's Oxide.Core.Rust now. Same goes for Oxide.Ext.CSharp, it's Oxide.Core.CSharp
     
  3. Thanks @Wulf !, I had all these notes in a google doc and thought Itd be a waste not to share them, Id love to re-organize it more and give a legit step by step guide/tutorial, I just wanted to dump it all for now to help any others, if anyone wants to take this info and make it better please please do! Im open to using a wiki or putting this on github or something. For now Ill keep editing this thread. Any admin is totally welcome to edit the thread.
     
  4. Wulf

    Wulf Community Admin

    We have Docs, just not many contributors. We have new documentation in the works as well for down the road.
     
  5. I'd love to see the new documentation that's in the works, is it available anywhere?

    I think this is a two-part problem... first and foremost is the structure of the site. I mean no disrespect by this, but while using a forum software as a CMS is possible (as can be seen here), it's not very practical. It's quite difficult to locate the information I'm seeking even if I've seen it before and know that it exists.

    Secondly is the lack of documentation in regards to the Lang, CUI Helper, Chat (PrintToChat, PrintToConsole, player.Reply, etc), more complex Config structures, and simply knowing how to find the information you're looking for in regards to Rust and Unity (which is where the decompiler comes in handy, but even that requires additional knowledge that beginners may not have and may not know where to start).

    Instructing newcomers to reference other plugins to learn is a rather flawed concept because, 1) they may not know which plugins implement what they need to learn, 2) they may not know what they need to learn, or 3) they may find multiple approaches to their problem and become even more confused as to which approach is best. In my experience, the first few steps are the hardest because you don't know where to look or what you're looking for. Afterwards, sure, it's a great idea to learn by taking a gander at what others have created.

    That said, I've created a starter template (which has the absolute basics) and a more complex boilerplate for myself and decided it'd be worth sharing. I don't work with C# much, so I won't say it's "well written" and don't know if it follows "best practice" but it is what it is and people are welcome to submit PRs to improve it if they wish.

    GitHub - devonzara/Oxide-RustPlugins: A collection of custom plugins for Rust (the game) and some helpful boilerplates.
     
  6. Wulf

    Wulf Community Admin

    uMod - API Overview - a lot is missing right now, mainly just me working on it.

    Try not to link any plugins intended for general use. For development reference it's fine, but we'd like to keep released plugins centralized and not in random threads that would otherwise turn into support threads for them. I know you don't have any in the repo yet, but I imagine there will be with that description. :p
     
  7. Oh, very nice! Rebranding? Looks like a great start but much to be done... Are those docs fetched from markdown files on Github, or?...
     
  8. Wulf

    Wulf Community Admin

    Jekyll + CSS + HTML + JS via GitHub
    GitHub - theumod/umod.org