1.0.2 • Published 3 years ago

scriptserver-command v1.0.2

Weekly downloads
18
License
GPL-3.0
Repository
github
Last release
3 years ago

Deprecated - Moved to @scriptserver/command

npm.io

FYI: This package is an addon for ScriptServer and requires ScriptServer to be set up, please see here for more information.

Installation

While in root directory of your server run:

npm install scriptserver-command

And in your server file:

server.use(require('scriptserver-command'));

Configuration

The prefix scriptserver-command uses for commands is interchangable. What you pass in is parsed as regex, so you can do something as simple as a single character like the default ~, or a wider variety of them with [~!.\].

The following is the default configuration:

const server = new ScriptServer({
  command: {
    prefix: '~'
  }
});

Usage

This module provides the following interface for adding custom server commands to be used in the ingame chat. The provided callback will be invoked when a player types the specified command into chat prefixed with specified prefix. (Defaults to ~).

// Registers the command ~spawn to the following function
server.command('spawn', event => {

  // Person who sent command
  var commandSender = event.player;

  // Command used (in this case, spawn)
  var command = event.command;

  // Array of arguments passed after command (in this case useless)
  var arguments = event.args;

  // Timestamp of when the command was sent
  var timestamp = event.timestamp;

  var spawnLocation = { x: 0, y: 70, z: 0 };

  server.send(`tp ${commandSender} ${spawnLocation.x} ${spawnLocation.y} ${spawnLocation.z}`);
});

This ScriptServer module uses:

1.0.2

3 years ago

1.0.1

4 years ago

1.0.0

6 years ago

0.1.2

8 years ago

0.1.1

8 years ago

0.1.0

8 years ago

0.0.5

8 years ago

0.0.4

8 years ago

0.0.3

9 years ago

0.0.2

9 years ago

0.0.1

9 years ago