1. Code:
            [ChatCommand("purge")]
            void cmdPurge(BasePlayer player, string command, string[] args)
            {
                SendReply(player, purge);
            }
    
    This works, basically you type /purge and it sends a string to the player. I would like to be able to set parameters or arguments, such as /purge off - because normally, thanks to Wulf's help, whenever someone says 'purge' in the chat it privately messages them with what the purge is, however doing /purge off would of course disable that. Vice versa with /purge on.

    Also, /purge help to see a list of purge commands and /purge about. I recon it's like finding the user input, a switch statement or something but I have no idea how Oxide goes about that. Thanks.
     
  2. Code:
    string arg = args[0];
    if(arg == "help") {
    // bla bla help
    }
    else if(arg == "on") {
    // bla bla on
    }
     
  3. Note that args[0] is the first arg, args[1] the second, args[2] is the third..
     
  4. Thank you very much!
     
  5. No problem.
     
  6. I am trying to make this work, so when they do /purge off it says purgeonoff to false and vice versa. So when it's about to print the message to the player it also checks if purgeonoff is true. But I get this error:
    [Oxide] 10:50 AM [Error] TestPlugin plugin failed to compile!
    [Oxide] 10:50 AM [Error] TestPlugin.cs(52,17): error CS0103: The name `purgeonoff' does not exist in the current context

    Code:
    class TestPlugin : RustPlugin
        {
            void Init()
            {
                Puts("Purge Plugin has loaded.");
                bool purgeonoff = true;
            }
            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, kos);
                SendReply(player, tradezone);
                player.ClientRPCPlayer(null, player, "ForcePositionTo", new object[] { 1400, 6, -1882 });
            }        string purge = "Raiding and killing on sight is not allowed, unless there is a purge, which happens every Wed/Sat/Fri.";        void OnPlayerChat(ConsoleSystem.Arg arg)
            {
                string message = arg.GetString(0, "text");
                BasePlayer player = (BasePlayer) arg.connection.player;            if (message.Contains("purge") && purgeonoff == true)
                {
                    PrintToChat(player, purge);
                }
            }        [ChatCommand("purge")]
            void cmdPurge(BasePlayer player, string command, string[] args)
            {
                string arg = args[0];
                if (arg == "help") {
                    SendReply (player, "Use '/purge off' to disable getting a message when you say 'purge' in chat.\nUse '/purge on' to enable getting a message when you say 'purge' in chat.\nUse /purge about to learn about the purge.");
                } else if (arg == "on") {
                    SendReply (player, "You have enabled Purge help!");
                    purgeonoff = true;
                } else if (arg == "off") {
                    SendReply (player, "You have disabed Purge help!");
                    purgeonoff = false;
                } else if (arg == "about") {
                    SendReply (player, purge);
                }
            }    }
     
  7. Remove the bool line from the Init and type this above the Init.. just not in a hook or cmd.

    private bool purgeonoff = true;
     
  8. Oh okay! It works now. Thank you very much :D
     
  9. No problem :p