/rust-server-cli-rcon-scheduler

You can schedule RCON commands for your Rust server with this script.

Primary LanguageJavaScriptMIT LicenseMIT

rust-server-cli-rcon-scheduler

Rust Server CLI RCON Scheduler

Installation

Installing Node.js

Check the instructions how to install Node.js and NPM on your OS: https://nodejs.org/en/download/package-manager/

Tested to be working with Node.js version >= v0.12.18, but I'm pretty sure this should work with pretty much any version of Node.js.

Installing the rust-server-cli-rcon-scheduler

# Clone this repository
git clone https://github.com/kirbo/rust-server-cli-rcon-scheduler.git

# Change directory
cd rust-server-cli-rcon-scheduler

# Install dependencies
npm install

# Edit "rcon.json" file, with your favorite editor, e.g.
nano rcon.json

# Copy any of the "example-*.schedules.json" file and edit it with your favorite editor, e.g.
cp example-schedules.json schedules.json
nano schedules.json

# Make sure you have "+rcon.web true" in your Rust server,
# otherwice this wont work (at least for now)..

# Start the scheduler
npm start

Usage

You can set commands in the schedules.json file via 2 different ways, such as:

[
    {
        "command": "say This message will be send every minute",
        "interval": 1
    }
]

Or if you want the command to be executed after specified time:

[
    {
        "command": "say This message will be sent only once, after the given time below",
        "after": "2017-04-12 17:15:00"
    }
]

The message above will be triggered only once (after the schedules.json has been loaded).

Commands are structured as following:

{
    "command": "say Don't play on Christmas day...",
    "after": "2017-12-24 00:00:00",
    "interval": 5,
    "until": "2017-12-24 23:59:59"
}

command needs to be set in every command. This is RCON command you want to execute. With command you need to set one of the following: interval or after. With after you can also set interval, if you want your command to be intervalled after specified time. With after you can also set interval and until, if you want your command to be intervalled with specified time range.

To be more precise, here are the examples:

This is executed only once:

{
    "command": "say Don't play on Christmas day...",
    "after": "2017-12-24 00:00:00"
}

This is executed every minute after the specified time:

{
    "command": "say Don't play on Christmas day...",
    "after": "2017-12-24 00:00:00",
    "interval": 1
}

This is executed every minute with the range from 00:00 - 23:59 on 24.12.2017:

{
    "command": "say Don't play on Christmas day...",
    "after": "2017-12-24 00:00:00",
    "interval": 1,
    "until": "2017-12-24 23:59:59"
}

after and until can handle Wildcards also, you can set for example:

Execute only once per day after 15:00, every day on july 2017, until 20th of july 18:00:

{
    "command": "say This message was timed to execute only once per day after 00:00, every day on july 2017 after 15:00, until 20th of july 18:00",
    "after": "2017-07-* 15:00",
    "until": "2017-07-20 18:00"
}

Execute after 08:00 until 10:00 every 15 seconds, on 24th of december every year:

{
    "command": "say This message was timed to execute after 08:00 until 10:00 every 15 seconds, on 24th of december every year",
    "after": "*-12-24 08:00",
    "interval": 0.25,
    "until": "*-12-24 10:00"
}

Execute every 15 seconds, on the first day of every month, every year:

{
    "command": "say This message was timed to execute every 15 seconds, on the first day of every month, every year",
    "after": "*-*-01 00:00",
    "interval": 0.25,
    "until": "*-*-02 00:00"
}

You can modify the schedules.json while the script is running. It will check for changes in the file every 10 seconds, so you don't need to restart the script if you make changes. Remember to delete the messages which have the after property set, if you are going to modify the schedules.json on the fly, because they will be triggered again if you don't delete them from the file :)

Exiting the scheduler

Simply press CTRL + C and the scheduler will exit.

Motivation

A man named Simon contacted me via e-mail, because of my other project rust-server-cli-rcon and asked can he execute timed commands with it, so I offered that I can create such tool for him and here it is.

One requirement was that should be possible to set intervals and/or intervals for commands, without the need of installing any mods for the Rust server, so this works without any mods (i.e.: Oxide) on a Vanilla Rust Server. Only thing that you need to do is to install this and set the +rcon.web true when you start your server and you're good to go.

Screenshot(s)

screenshot

Happy scheduling :)