1. Hello. I've started using C sharp because most plugins are coded using it and I can learn from them. I am trying to make it so when someone says "purge" in the chat it displays privately what Purge means.

    Here's the code:
    Code:
    using Oxide.Core;namespace Oxide.Plugins
    {
        [Info("Purge", "Matthew Lang", 0.1, ResourceId = 0)]
        [Description("Adds a Purge element into the game.")]
        public class TestPlugin : RustPlugin
        {
            void Init()
            {
                Puts("Purge Plugin has loaded.");
            }
            void Unload()
            {
                Puts("Purge Plugin has been unloaded.");
            }        var purge = "Raiding and killing on sight is not allowed, unless there is a purge, which happens every Saturday and Friday.";
            void OnPlayerChat(NetUser netuser, string purge)
            {
                rust.SendChatMessage({ netuser, purge });
            }
        }
    }
    Here's the startup error:

    [Oxide] 2:09 PM [Error] TestPlugin plugin failed to compile!
    [Oxide] 2:09 PM [Error] TestPlugin.cs(24,0): error CS1525: Unexpected symbol `}'
     
  2. Again you are using netuser... netuser is for Rust Legacy...

    player, is for experimental.

    Also to send message to player use
    Code:
    string message = "This is the message";
    SendReply(player, message);
    And check "Auto Reply" to learn how to do if the message contains "purge" and stuff.
     
  3. Ok thank you.
    On the Rust API I click Rust, not Rust Legacy and that is what it shows me. A little misleading.
     
  4. Wulf

    Wulf Community Admin

    You're not clicking on the right game icon, see http://docs.oxidemod.org/rust/?csharp#onplayerchat. There is no Rust Legacy info under the Rust section.
     
  5. Wulf

    Wulf Community Admin

    No worries! Something like the below is likely what you'd want:
    Code:
    using Oxide.Core;namespace Oxide.Plugins
    {
        [Info("Purge", "Matthew Lang", 0.1)]
        [Description("Adds a Purge element into the game.")]
        public class Purge : RustPlugin
        {
            string purge = "Raiding and killing on sight is not allowed, unless there is a purge, which happens every Saturday and Friday";        void OnPlayerChat(ConsoleSystem.Arg arg)
            {
                string message = arg.GetString(0, "text");
                BasePlayer player = (BasePlayer) arg.connection.player;            if (message.Contains("purge"))
                {
                    PrintToChat(player, purge);
                }
            }
        }
    }
    Just make sure to name the file the same as your main class, Purge.cs.
     
  6. Thank you so much for taking your time to do this! This is great. I have one question still, when I use
    string researched = "Congratulations! You got the blueprint.";
    SendReply(player, "RUST RP", researched);

    I get this error:

    [Oxide] 4:53 PM [Error] TestPlugin.cs(30,23): error CS0103: The name `player' does not exist in the current context

    and how do I return the float in OnItemResearchEnd to become a success? so if they player successfully gets the blueprint it only says it, instead of even if he loses it says it?
     
  7. Show me your code so i can tell you what you did wrong.
     
  8. Code:
    using Oxide.Core;namespace Oxide.Plugins
    {
        [Info("Purge", "Matthew Lang", 0.1, ResourceId = 0)]
        [Description("Adds a Purge element into the game.")]
        class TestPlugin : RustPlugin
        {
            void Init()
            {
                Puts("Purge Plugin has loaded.");
            }
            void Unload()
            {
                Puts("Purge Plugin has been unloaded.");
            }        void OnPlayerRespawned(BasePlayer player)
            {
                string kos = "Think you've been killed on sight, and there is no purge? Contact an admin.";
                string tradezone = "You've been respawned at the Trade Zone. This is a safe, non-pvp area.";
                SendReply(player, "RUST RP", kos);
                SendReply(player, "RUST RP", tradezone);
                rust.ForcePlayerPosition(player, 1400, 6, -1882);
            }        void OnItemResearchEnd(ResearchTable table, float chance)
            {
                string researched = "Congratulations! You got the blueprint.";
                SendReply(player, "RUST RP", researched);
            }        string purge = "Raiding and killing on sight is not allowed, unless there is a purge, which happens every Saturday and Friday";        void OnPlayerChat(ConsoleSystem.Arg arg)
            {
                string message = arg.GetString(0, "text");
                BasePlayer player = (BasePlayer) arg.connection.player;            if (message.Contains("purge"))
                {
                    PrintToChat(player, purge);
                }
            }
        }
    }
    [DOUBLEPOST=1438532328][/DOUBLEPOST]I highly appreciate you trying to help me, thank you so much.
     
  9. Of course. You are trying to send a message to player in OnItemResearched, but there is no BasePlayer object with the name player declared.