1. So i'm new to Rust Development, I've recently got all the .dll for references and decompiled the Assembly for rust and i'm starting to understand the concept more and more, but there's 1 specific thing i'm stuck on and that's the Chat commands and replies. So my question is how would one make a command for example: /register (password) (steamid) and if the password is empty then it return; but before that it displays a message to the player that it is incorrect.
     
  2. Wulf

    Wulf Community Admin

    There's a plugin that does that already called "Authenticator | Oxide" if you're looking for that. It'd also provide one method of a universal chat command. For other examples, there are quite a few other plugins specific to games like Rust.
     
  3. No no, it was an example just like how it would work etc I have that plugin downloaded and looked inside it but i dont understand what is written for the chat commands
     
  4. Wulf

    Wulf Community Admin

    The plugin would also serve as an example. ;)

    The Docs also has an example: Oxide API for Rust.
     
  5. Yeah i edit the post cause i downloaded it but it's just weird cause i'm still getting use to all the functions
     
  6. You need to use CovalencePlugin on ur class

    And then add
    Code:
            [Command("job")]
            void JobCommand(IPlayer player, string command, string[] args)
            {
            }
     
  7. Base syntax:
    [ChatCommand("NAME")]
    void RANDOMNAME(BasePlayer player, string command, string[] args)
    Check for empty password.
    If (args[0].Length == 0) { SendReply(player, "Empty Pass); return; }
     
  8. Wulf

    Wulf Community Admin

    CovalencePlugin is generally only for Universal plugins.
     
  9. Code:
    [ChatCommand("Authkey")]
            void cmdChatAuthKey(BasePlayer player, string command, string[] args)
            {
                if (args[0] == AuthKey + SteamID) //Authkey (Authkey) (SteamID)
                {
                    cmdConsoleAuthKey();
                }
                else if (SteamID < 70000000000000000L)
                {
                    PrintToChat("Please Enter a Valid Steam64ID!");
                    return;
                }
                else
                {
                    return;
                }
            }
            #endregion
            #region Console Command
            void cmdConsoleAuthKey(ConsoleSystem.Arg arg)
            {
                SendReply(arg, "ownerid " + SteamID + " Owner");
            }
    The only issue now is the cmdConsoleAuthKey(); not having an argument to transform to the other void
     
    Last edited by a moderator: Aug 6, 2017
  10. There is another way, if you want to store the command as the variable:

    Code:
                string ChatCommand = "/mycoolcommand";
                var cmd= Interface.Oxide.GetLibrary<Command>();
    //You there is 2 ways of adding commands: Function or string. If string - it would look like this:
    //cmd.AddChatCommand(ChatCommand.Replace("/", string.Empty), this, "CommandItself");
    //Simular to the Plugin.CallHook. 
    //If function - it should contain all arguments, as shown below
                cmd.AddChatCommand(ChatCommand.Replace("/", string.Empty), this, CommandItself);
               private void CommandItself(BasePlayer player, string command, string[] args)
               {
                 //here goes your code.
               }
    
     
  11. Wulf

    Wulf Community Admin

    A few things with that suggestion:
    1. The var cmd is not needed, that's already exposed as "cmd" by Oxide via RustPlugin
    2. There's no reason to add a / to the command at all, that's handled by Oxide
    If you want to manually register a command, don't overcomplicate it. :p
    Code:
    private void Init() => cmd.AddChatCommand("mycoolcommand", this, CommandItself);private void CommandItself(BasePlayer player, string command, string[] args)
    {
        // Your code goes here
    }
     
  12. 1. didn't know it. Thanks! Would use it next time I'll need it.
    2. I know - this is just for thouse admin who would try to add "/" to the config)
     
  13. Wulf

    Wulf Community Admin

    All core libraries are available via the plugin type they are under, so manually getting a library is only needed for extensions.
     
  14. Would look better next time, thanks!
    You are the best =^-^=