1.1.8 • Published 1 year ago

squad-rcon v1.1.8

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year 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

1 year ago

1.1.7

1 year ago

1.1.6

1 year ago

1.1.5

1 year ago

1.1.4

1 year ago

1.1.3

1 year ago

1.1.1

1 year ago

1.1.2

1 year ago

1.0.24

2 years ago

1.0.22

2 years ago

1.0.23

2 years ago

1.0.21

2 years ago

1.0.20

2 years ago

1.0.19

2 years ago

1.0.18

2 years ago

1.0.17

2 years ago

1.0.16

2 years ago

1.0.15

2 years ago

1.0.14

2 years ago

1.0.13

2 years ago

1.0.12

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

0.0.1

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

1.0.11

2 years ago

0.0.9

2 years ago

1.0.10

2 years ago

0.0.8

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago