Scyye-ROUNDSCommonsAndConsole icon

ROUNDSCommonsAndConsole

A framework for adding commands to ROUNDS

Last updated 2 years ago
Total downloads 2505
Total rating 0 
Categories Utilities Patch
Dependency string Scyye-ROUNDSCommonsAndConsole-1.3.0
Dependants 1 other package depends on this package

This mod requires the following mods to function

BossSloth-BetterChat-1.2.0 icon
BossSloth-BetterChat

Reworks the horrible chat system

Preferred version: 1.2.0

README

ROUNDSCommons Commands

PLEASE REPORT ANY BUGS OR GLITCHES IN THE ROUNDS MODDING COMMUNITY DISCORD, IN #bug-reports, AND PING @scyye

How to use commands

Commands are ran by using !command.

There will be a help command shortly, for now, check the logs.

Creation

This section assumes prexisting knowledge on creating ROUNDS mods, for a tutorial on that, see here

Importing dependencies

Just the same way you inport all the DLLs, import ROUNDSCommons.dll into your dependencies

And put:

[BepInDependency("dev.sub5allts.rounds.commons")]

above your main class.

Creating Commands

To create a command, create a class that extends Command:

    public class ExampleCommand : Command
    {
    public override CommandDetails Details => new CommandDetails()
    {
        Name = "example",
        Description = "An example command",
        Scope = CommandScope.Sandbox,
        Aliases = new string[] {
            "command",
            "test"
        }
    };

    public override CommandResponse Execute(CommandEvent e)
    {
        Console.WriteLine("Hello World!");

        return new CommandResponse()
        {
            Success = true,
            Message = "Printed Hello World!",
        };
    }
}

Command Details

Name is the text that goes after "!" when running a command.

Description is the text that will show up in !help when that gets added.

Scope is the scope the command is valid in, either HOST, where only the host can do it, SANDBOX where you can do it in sandbox only, or GLOBAL, where you can do it globally.

Aliases (Optional) is equivelent commands that can be ran to do the same thing.

Execute()

Inside Execute() you can get the executor (Player), the arguments (String[]), and the details (CommandDetails) about the command.

Execute() returns a CommandResponse, these are fairly simple. Success (bool), did the command successfully run? And Message (String), the message to respond to the player with.

Registering Commands

Simply put

CommonsPlugin.instance.commandManager.AddCommand(new ExampleCommand());

inside Awake().

(Replace new ExampleCommand(), with new YourCommandClass())

Make sure ROUNDSCommons is installed, add your mod to your profile, and enjoy your commands!