JsPlanet is a Javascript controller written in TypeScript for Trackmania 2020 dedicated server.
// Import the controller
import { JsPlanet } from "jsplanet";
// Instantiate the controller
const jsPlanet = new JsPlanet("localhost", 5000, "SuperAdmin", "SuperAdmin");
jsPlanet.on("ready", () => {
console.log("JsPlanet is ready to use.");
// Send a message to all players
jsPlanet.chatManager.send("Controller has started.");
});
jsPlanet.on("race", (checkpoint) =>
console.log(
`${checkpoint.player.nickname} has finished in ${checkpoint.time} ms.`,
),
);
// Connect JsPlanet to the Trackmania Xml-RPC server
await jsPlanet.connect();
Ensure a supported NodeJS version is installed with Yarn and install dependencies with Yarn.
Ensure Docker is installed, copy .env.example
to .env
and fulfill it. Start a Trackmania development server with docker compose by running
docker compose -f compose.dev.yml up --build