1.1.8 • Published 11 days ago

squad-rcon v1.1.8

Weekly downloads
-
License
MIT
Repository
github
Last release
11 days ago

SquadRcon

This library is designed for the game Squad, it will give you the ability to easily connect to Rcon and parse/execute commands. I hope it will be useful to you!

Installation

This is a Node.js module available through the npm registry.

Before installing, download and install Node.js.

If this is a brand new project, make sure to create a package.json first with the npm init command.

Installation is done using the

$ npm install squad-rcon

or

$ yarn add squad-rcon

Quick Start

import { Rcon } from 'squad-rcon';

(async () => {
  try {
    const rcon = new Rcon({
      id: 1,
      host: '127.0.0.1',
      port: 1111,
      password: 'qwerty',
    });

    await rcon.init();

    rcon.on('ListPlayers', (data) => {
      console.log(data);
    });

    rcon.execute('ListPlayers');
  } catch (e: unknown) {
    console.log(e);
  }
})();

API

Initialization

import { Rcon } from 'squad-rcon';

Rcon({
  id: 1,
  host: '127.0.0.1',
  port: 1111,
  password: 'qwerty',
  pingDelay: 60000, // optional
  autoReconnect: true, // optional
  autoReconnectDelay: 60000, // optional
  logEnabled: true, // optional
  chatListeners: {
    onChatMessage: (data: TChatMessage) => null, // optional
    onPlayerWarned: (data: TPlayerWarned) => null, // optional
    onPlayerKicked: (data: TPlayerKicked) => null, // optional
    onPlayerBanned: (data: TPlayerBanned) => null, // optional
    onSquadCreated: (data: TSquadCreated) => null, // optional
    onPossessedAdminCamera: (data: TPossessedAdminCamera) => null, // optional
    onUnPossessedAdminCamera: (data: TUnPossessedAdminCamera) => null, // optional
  }, // optional
});

Rcon return some pre-defined functions:

Functions

FunctionReturnTypeEmitter
initPromisePromise
closePromisePromise
rconEmitterEmitterEventEmitteron()
executePromisePromise<string>on('data')
getListPlayersPromiseTPlayer[]on('ListPlayers')
getListSquadsPromiseTSquad[]on('ListSquads')
getCurrentMapPromiseTMapon('ShowCurrentMap')
getNextSquadsPromiseTMapon('ShowNextMap')

Events Emitter

EventReturnType
ListPlayersresponseTPlayer[]
ListSquadsresponseTSquad[]
ShowCurrentMapresponseTMap
ShowNextMapresponseTMap
CHAT_MESSAGEresponseTChatMessage
POSSESSED_ADMIN_CAMERAresponseTPossessedAdminCamera
UNPOSSESSED_ADMIN_CAMERAresponseTUnPossessedAdminCamera
PLAYER_WARNEDresponseTPlayerWarned
PLAYER_KICKEDresponseTPlayerKicked
SQUAD_CREATEDresponseTSquadCreated
PLAYER_BANNEDresponseTPlayerBanned
dataresponseTRconResponse
errerrorError
connected
close
1.1.8

11 days ago

1.1.7

2 months ago

1.1.6

2 months ago

1.1.5

4 months ago

1.1.4

4 months ago

1.1.3

4 months ago

1.1.1

4 months ago

1.1.2

4 months ago

1.0.24

5 months ago

1.0.22

5 months ago

1.0.23

5 months ago

1.0.21

5 months ago

1.0.20

5 months ago

1.0.19

5 months ago

1.0.18

5 months ago

1.0.17

5 months ago

1.0.16

5 months ago

1.0.15

5 months ago

1.0.14

5 months ago

1.0.13

5 months ago

1.0.12

5 months ago

1.0.9

6 months ago

1.0.8

6 months ago

1.0.7

6 months ago

1.0.6

6 months ago

1.0.5

6 months ago

1.0.4

6 months ago

1.0.3

6 months ago

0.0.1

6 months ago

0.0.3

6 months ago

0.0.2

6 months ago

1.0.11

5 months ago

0.0.9

6 months ago

1.0.10

6 months ago

0.0.8

6 months ago

0.0.5

6 months ago

0.0.4

6 months ago

0.0.7

6 months ago

0.0.6

6 months ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago