Solved Writing C# plugins?

Discussion in 'Rust Development' started by sililia, Jun 27, 2015.

  1. Ok, so to cut to the chase, I want to start developing plug-ins For rust Experimental. I want to use C# since, its the fastest language that oxide has as far as i know and plus its the only language i have some experience in. I'd Like to say I have a fair amount experience in C++ but it's not supported by Oxide?

    So the thing is, i dont know where to start when. What do i need to download, and where do could i find oxide api or anything i can use to learn plug-in development . Any help is appreciated

    Best regards
    Sililia
     
  2. Wulf

    Wulf Community Admin

  3. Great!! Thank you very much @Wulf

    One more question, How do and what do i use the Assembly-CSharp.dll for, For compiling or just to look at the code?
     
  4. Wulf

    Wulf Community Admin

    To look at.
     
  5. Is there some more info on the subject, interested myself and would like to have a look at a guide with an easy to understand process, if it is available.

    Going over what Wulf supplied it has confused me, I understand about the link to the code but would like some more info on how it is used.
     
  6. Wulf

    Wulf Community Admin

    That's pretty much it. You'd need to be familiar with C# and decompiling for advanced plugins, else look at existing plugins and the Docs for the basics.
     
  7. Where is a good place to start lol, at the moment I can only edit code I am looking at.

    Sort of have a basic understanding of each symbol because of plugins already available, I just want to know if there is some resources into starting your own and working up from it.
     
  8. There is no real "how-to" docs at the moment. As Wulf has stated, 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)

    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.
     
  9. Well you don't need to, you could just write the .cs files and upload them and hope it works but having the plugin in Visual Studio with all the proper references means you can actually make sure the code compiles and you're not missing references, that you aren't calling functions/properties that don't exist, etc. You'll also get contextual listing of class members which is pretty useful when working with data you don't know.

    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. A good example of this is I tried making a mod to block the hackers using code lock breakers last week before they introduced the new shock thing. Well there's a hook that's called when you open a door, but not one when a user tries a code... There isn't much that can be done from there, it was a dead end with the knowledge I have.

    So back to basics:

    1. Get Visual Studio 2015
    2. Get a decompiler (I use Jetbrain's but there are tons of others)
    3. Get the server files (through SteamCMD)
    4. Create a bogus C# program in which you import all the required references
    5. Make your mod offline, making sure it compiles
    6. Send the cs file online (or test on that local server you downloaded)

    Rince and repeat...
     
  10. Thank you for the information that has helped me a lot for the decompiler i used the link Wulf supplied

    Link: http://www.telerik.com/products/decompiler.aspx

    I am also getting visual studio 2015 community edition, hope that is the one

    and i think its safe to say some kind person out there with the time on there hands if they can write up a guide that has a basic structure to get people started because at the moment its a little overwhelming with getting told I have to understand code and stuff like that yet I have not really got a place that fully explains the code for example the link to WIKI is not helping me at all.

    To the people who already know basic coding, you need to remember, the code to you looks like anyone can easily learn it but to someone like myself its like looking at a car engine and i am a computer tech lol.

    Also when installing Visual studio what features of the package must I have installed?
     
  11. You don't need anything special, the default options for Visual Studio are fine.

    As for the rest take it one bite at a time. Start by downloading some of the simpler mods out there and look at how they are coded. Look at the API documentation on here too. With just that and contextual help from the references you'll already have a good start. From there you have to use all the information you can get at, download a ton of plugins and do searches in the code, search the forums here, use the decompiled assembly to better understand the classes the game uses and how they interact together..

    It's not very complicated.. The only issue is getting off the beaten path because of the lack of available information.
     
  12. Alright so you know I am on the right track, This is what I need to know just so I know I have all the required stuff

    A decompiler: http://www.telerik.com/products/decompiler.aspx

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

    NOTE: Should everything be installed for visual studio when running the installer or do I only need specific things, if specific, what do I select?

    Oxide Api Programming list: http://docs.oxidemod.org/rust/#getting-started

    The server stuff I already know how to do, it's just the programming side of stuff I need to know.

    And wondering if notepad++ can be used?

    If there is anything else I need please let me know thank you.
     
  13. Can't remember what options there are when you install Visual Studio but all you really need is the C# compiler and the IDE. You can probably uncheck everything else and it should work.

    As for Notepad++, of course you can use it but the Visual Studio IDE will give you contextual help and lots of nice tools Notepad++ doesn't have. Just use the IDE, the community edition is free to use for such activities so there's no reason not to use it. Arguably, you could also get Resharper which is a nice tool as well (not free though), but that's just the cherry on the top and definitely not necessary.
     
  14. Thanks man that information helped heaps and thank you everyone for the help as well.


    Update: Just went over that book, OMG so much writing.

    like what do you do to push through this hahahaha like I can read and all but I can only read so much.
     
  15. @Squida
    https://drive.google.com/file/d/0B_u1rzdqYCnzS3l1NE5VRXh1X0k/edit?pli=1

    This is an amazing Book to get a hang of C#, IF you dont like reading then youtube but, most videos dont explain things like that book.

    What i did was load it on my android open it with Kindle's app and when travelling to college i get out my phone and read. You also need to try practice.
    Don't be stupid and think you can learn and make plug-in you'll get confused and end up loosing interest.


    Also one really stupid question
    How do i load All the references for oxide and rust on a project o with visual studio which i can starting working with?

    best regards
    Sililia
     
  16. Thanks for that man, I am one of those people where in order to get information that I need, I will read it, if I must.

    And for the question you asked my guess is that your asking for like text highlighting with oxide and rust program commands? because if so, I am interested as well in knowing that lol at the moment I have visual Studio downloading and installing, did not find this so called IDE I only know IDE as in in the IDE HDD, again only because I am computer tech nerd not programing nerd heh
     
  17. The link you gave me with the dll files where do I find them, in the rust directory?

    I also realized that I have VS 2013, Getting 2015 now and what does Silillia mean when he/she said

    "How do i load All the references for oxide and rust on a project o with visual studio which i can starting working with?"

    UPDATE: managed to find the dll files, still not 100% sure how I am supposed to understand what each part of the script does and how it works with each other.
     
    Last edited by a moderator: Jun 29, 2015
  18. Yeah this is where mine are (rust_server being the root of the server installation):
    Z:\steamcmd\rust_server\RustDedicated_Data\Managed

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

    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.


    Just take any existing mod and copy the file in your project. If you want a super basic example check at my NoDecay mod (http://oxidemod.org/plugins/nodecay.1160/).

    In the documentation for Oxide you'll find all the hooks you can use ("OnXxxxx") and a shell example on the right side, for example:

    Code:
    void LoadDefaultConfig()
    {
        Puts("LoadDefaultConfig works!");
    }
    You can find most of the callable API functions here:
    http://docs.oxidemod.org/rust/#library-functions

    There are others like "Puts" which I'm not sure, I think they're Rust commands more than Oxide commands, could be wrong. I don't know where to get a list of these.
     
  19. Okay I am looking into a mod when using admin protection it also enables invisibility but at the moment I would rather have it as a /command so i can do something basic, is it do-able?

    Plus a big thumbs up to you for making that mod, it's running on my server and it's nifty as.

    And also thank you so much for the reference guide all I need to know now is what references to use and is there somewhere I can save all of them so I can drag and drop what I want?