Server Admin Port Development
OpenTTD Development Documentation
External Links

OpenTTD GitHub
Contributing to OpenTTD - guidelines
OpenTTD Doxygen

General Reference

Coding style
Compiling OpenTTD
Debugging
Add a setting
Add a squirrel function
Understanding the SaveGame handler
Bumping the savegame version
Doing an OpenTTD release

Language and Strings

Manual of style
Format of langfiles
Using OpenTTD strings
List of special strings

Window System

Using the window system
Colour codes that exist in OpenTTD
Adding a text box
Understanding the widget focus system
GUI style guide

Multiplayer

The OpenTTD TCP protocol
The OpenTTD UDP protocol
Debugging desyncs
Server Admin Port development

Ingame Console

The console window
Console commands
Console variables
Using console scripting
Adding functions/commands to the console
Adding variables to the console
Console development history

Content APIs (modding frameworks)

Graphics and similar (NewGRF)
AI framework (NoAI)
GameScript framework (NoGO)
Social Integration

Other Reference

Map array (landscape grid)
Vehicles
Pathfinding
Train acceleration
Sound IDs

Contents

Overview

The Server Admin Port is available to be connected to from any programming language that has support for sockets. The documentation contained within this page is aimed at helping you get started developing a client (or library).

The OpenTTD GitHub docs contains a guide to OpenTTD's admin network.

Libraries

  1. JOAN is an example written in Java that can do almost everything that the Admin Port offers.
  2. COAN is an example written in C# that is more limited in it's abilities but still offers the basics.
  3. openttd-admin is a golang based library for OpenTTD server administration and includes a remote console interface and a simple command line chat application.

These projects are open source so can be used freely by anyone wishing to write their own Client for the OpenTTD server admin port.
(Please add your own to this list if they are freely available and/or Open Source)

The basics

To be able to connect to the Admin Port on your server there are a couple of things you need to have done.

  1. You will need to set the server_admin_port in Openttd.cfg. This can be anywhere between 0-65535 but must *NOT* be in use by any other programs
  2. You will also need to ensure that you have set the Admin password
    • This is very important because if you do not set the Admin Password OpenTTD will *NOT* start a listener for the Admin Port

Connecting to Admin Port

Once you have got the basics above set up you can now connect.
At this stage you can choose to create your own library if there is not already one your chosen language or you can use on of the existing libraries (see libraries above).
JOAN comes with an example in the form of SimpleConsole which extends the OpenTTD class. While COAN comes with a very limited WinForms application to play with.

Creating your own

Connecting to the admin port requires sending a ADMIN_PACKET_ADMIN_JOIN packet to your server.

Packets

The format of packets sent to the Admin Port are expected to be:
SIZE | TYPE | DATA
When you wish to connect your packet would be something like: 0x1B 0x00 + 0x00 + "password" + 0x00 + "botname" + 0x00 + "version" + 0x00

Field Size
Size 2 bytes
type 1 byte
Example Data
"password" 9 bytes
"botname" 8 bytes
"version" 7 bytes
Total Size 27 Bytes (0x1B)

It is very important to remember to prepend the packet with the size of the packet (remember to +2 for the packet size bytes). In the example above the payload (Type and data is 25 bytes. The +2 for packet size makes it 27)