1. Hello

    I just started getting into C# (been coding a little bit in the past, small stuff like basic php and such) and I want to get into the oxide modding.

    I want to start with making a very simple plugin that basicly announces in chat when a player respawns from death. I've used the Oxide API site for reference, and found the following code
    Code:
    void OnPlayerRespawned(BasePlayer player)
    {
        Puts("OnPlayerRespawned works!");
    }
    So I downloaded a few plugins that announces to chat and looked at their code. I've ended up with the following
    Code:
    using Oxide.Core.Libraries.Covalence;
    using System.Collections.Generic;
    using Newtonsoft.Json;
    using Oxide.Core;
    using System;namespace PlayerRespawnAnnouncement
    {
        [Info("Player Respawn Announcement", "Maloxan", 0.1)]
        [Description("Mention in chat when player respawns from death")]    class PlayerRespawnAnnouncement
        {
            void OnPlayerRespawned(BasePlayer player)
            {
                Puts("{Player} just respawned from a short temporarily death!");
            }
        }
    }
    
    Now i'm stuck and not sure how to continue. First of all, i've installed the JustDecompile program and looked through Assembly-CSharp.dll for references but not really sure how or what to do with it.

    If you have any inputs on how to continue from here when stuck, please let me know. Much appreciated! I am willing to eventually pay for further assistance with the right help :)
     
  2. Hey there,

    From what I can see what you have is almost correct and here are a few tips

    1. The namespace should be Oxide.Plugins
    2. You need to inherit RustPlugin for it to be registered as a plugin
    3. The Puts command outputs to the server window and not actually to the game
    Here is an edited version which should work how you want, hopefully you can learn from the tips mentioned here. I am using the rust.broadcast method to broadcast to every player ingame.
    Code:
    using Oxide.Core.Libraries.Covalence;
    using System.Collections.Generic;
    using Newtonsoft.Json;
    using Oxide.Core;
    using System;namespace Oxide.Plugins
    {
        [Info("Player Respawn Announcement", "Maloxan", 0.1)]
        [Description("Mention in chat when player respawns from death")]    class PlayerRespawnAnnouncement : RustPlugin
        {
            void OnPlayerRespawned(BasePlayer player)
            {
                rust.BroadcastChat(player.displayName + " just respawned from a short temporary death!", null, null);
            }
        }
    }
     
  3. Wulf

    Wulf Community Admin

    The rust.BroadcastChat is called a library helper, and mainly existed for Lua plugins and such. For C#, you can use methods such as PrintToChat or the Covalence options if desired. What the OP had for the string formatting was fine, it's a newer C# 6 style called string interpolation. While you could use the entire player as a string, player.displayName is likely more of what the OP was looking for, so good catch there. ;)
     
  4. Now, alright! Thanks so much for the replies.

    I copy pasted Kriogenic's code and understood a bit more! I am still confused about the
    Code:
    null, null);
    though. Why does that have to be there?

    Is it possible to check for errors? When I hit "Start" (green arrow / play button) it gives me 30 warnings and 10 errors. I did input the necessary Analyzers as mentioned in a thread somewhere. How do I "finish" it? I mean, I guess there should be generated a .json file to edit for the users. Basicly it should just be one setting to be changed on or off or something, just to make it super simple and easily understandable :)
     
  5. Wulf

    Wulf Community Admin

    The null and null that he added there are sent in lieu of actual values for that method; in this case, they are optional and can be removed.
     
  6. Alright thanks. I get it :)
    Is there any guides available I haven't seen that explains the finishing touches on a plugin? So I can upload it and test it on my own server working.
     
  7. Wulf

    Wulf Community Admin

    There are plenty of C# tutorials around the net. ;)
     
  8. You beast.
    Last short question - If a plugin were to be uploaded to oxidemod as it is right now; would it be accepted or declined? And if declined, on what background? Just curious!
     
  9. Wulf

    Wulf Community Admin

    It depends what it is and if it follows the guidelines and such.
     
  10. Wulf

    Wulf Community Admin

    You do not compile plugins as DLLs; you install them under your oxide/plugins folder as a .cs file. You are seeing a lot of errors though as you do not have a proper project setup. I'd suggest looking up how to add References to the DLLs you need to resolve the errors.
     
  11. It all makes sense now! Thanks
     
  12. Thanks for that, had no idea about string interpolation, so I learned something new. About the BroadcastChat I just copied that line from your stickied thread with the twitter icon thingy, but good to know as I was also using it in my plugin and I will switch it to PrintToChat
     
  13. Wulf

    Wulf Community Admin

    The rust.BroadcastChat does have additional options for passing a userId for an icon, so it can be useful in certain circumstances. It'll eventually be phased out though in favor of others though once we cleanup a bit to focus on C# plugins.