Socket
Book a DemoInstallSign in
Socket

node-openttd-admin

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-openttd-admin

A Node.js Library for connecting to Openttd's admin interface.

0.2.4
latest
Source
npmnpm
Version published
Weekly downloads
12
300%
Maintainers
1
Weekly downloads
 
Created
Source

node-openttd-admin

A Node.js Library for connecting to Openttd's admin interface.

Preface

This module can be seen as an update to yorickvP/node-ottdadmin, however its completely rewritten to be a bit more tidy and standard, as well as working on more recent versions of node. I have kept the interface reasonably similar, however, its not a drop-in replacement.

Basic Usage

var ottd = require("node-openttd-admin"),
  ottdConnection =  new ottd.connection();

ottdConnection.connect("myserver.com", 3977);

ottdConnection.on('connect', function(){
  ottdConnection.authenticate("MyBot", "MyPass");
});
ottdConnection.on('welcome', function(data){
  ottdConnection.send_rcon("say \"hello world\"");
  ottdConnection.close();
});

Advanced Usage

Examples can be found in the examples/ folder

Functions

Function NameDescriptionparameters
authenticateSend and authentication request - this must be performed within 10 seconds of the server connectingusername - name of the client (can be null for a default)
password - server admin password
send_rconSend an rcon commandcommand - command to execute on the server
send_chatSend a chat messageaction - an action from enums.Actions
desttype - a destination from enums.DestTypes
id - TODO: Lookup
msg - message body
send_update_frequencySet a new update frequencytype - type of update (enums.UpdateTypes)
frequency - frequency of update (enums.UpdateFrequencies)
send_pingSend a ping requestint32 - 32bit integer that will be returned with pong

Events

Event NameDescriptionOptions
connectCalled when the tcp connection to the server is connectednone
authenticateCalled when successfully authenticated. welcome is more useful for connection howeverversion- I have no idea TODO: Lookup
welcomeCalled when the server sends its "welcome packet", which contains info about the servername - name of the server
version - sematic version of the server. ie- 1.4.0-beta2
dedicated - 0 or 1 depending on whether the server is running as a dedicated server
map - data about the map (seed, landscape, startdate, mapheight, mapwidth)
newgamefired when a new game startsnone
shutdownfired when a new game endsnone
datefired when information about the date is receiveddate - the current date
clientjoinfired when a client joinsid - id of joining client
clientinfoFired when information about the client is receivedid - id of the client
ip - ip address of the client
name - username of the client
lang - language id
joindate - date the player joined the game
company - id of the company that the player is in
clientupdateFired when an update from a client is receivedid - id of the client
ip - ip address of the client
name - username of the client
lang - language id
joindate - date the player joined the game
company - id of the company that the player is in
clientquitfired when a client quitsid - id of the client
clienterrorFired when a client has an errorid - id of the client
err - error
companyinfoFired when info about a company is receivedid - company id
name - company name
manager - company manager
colour - company primary colour
protected - whether the company is password protected
startyear - year of inaugaration
isai - whether the company is ai or a human player
companyupdateFired when an update happens to a companyid - company id
name - company name
manager - company manager
colour - company primary colour
protected - whether the company is password protected
shares - who owns the 4 shares, this is an object with elements 1, 2, 3 and 4.
companyremoveFired when a company is deletedid - company id
reason - reason for deletion (enums.CompanyRemoveReasons)
companyeconomyfired on receiving information about the company's performanceid - company id
money - money of the company
loan - amount the company has borrowed
income - income
lastquarter - value, performance and cargo delivered (cargo) of the last quarter
prevquarter - the same, but for the quarter before.
companystatsFired on receiving information about the assets of a companyvehicles - number of trains, lorries, busses, planes and ships that the company owns
stations - number of stations of each type that the company owns
chatFired on receiving a chat messageaction - what action is included in the message (enums.Actions)
desttype - where the message is aimed at (enums.DestTypes)
id - message id
message - message body
money - amount of money sent if action is GIVE_MONEY
rconFired on receiving the output of an rcon commandcolour - what colour the message is displayed in
output - output of the rcon
rconendFired on receiving the end of an rcon commandcommand - the command that was sent to rcon
consoleFired on receiving outputorigin - origin of the output
output - body of the output
pongFired on receiving ping replyint - integer passed to send_pong

Enums

There are several enums provided,these are taken almost directly from yorickvP/node-ottdadmin. This is just a list of them. Rather than listing all the entries here, please see enums.js

  • UpdateTypes
  • UpdateFrequencies
  • CompanyRemoveReasons
  • Actions
  • DestTypes
  • NetworkErrorCodes

Todo

  • Write initial documentation
  • Look up unknowns in documentation
  • Break up long switch into functions in another file
  • work out some way of doing tests
  • Proof read everything

Thanks To

  • KenjiE20

Keywords

openttd

FAQs

Package last updated on 08 Jul 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.