Skip to main content

An XML RPC client for Trackmania Nations Forever dedicated servers.

Project description

TrackMania Nations Forever Client

This Python client is intended to be used with the TM Nations Forever remote procedure endpoint.

The available methods are documented at ListMethods.

It has been built for the dedicated server version of 2011-02-21.

The hardcoded TrackMania RPC method calls have been AI generated and mostly not tested!

Usage Example

from trackmania_client import TrackManiaClient as TMClient
import asyncio

async def main():
  HOST = 'localhost'
  PORT = 5000

  async with TMClient(HOST, PORT) as client:
    print('Connected!')
    await client.authenticate('SuperAdmin', 'SuperAdmin')
    print('Authenticated!')

    version = await client.get_version()
    print(f'Version: {version}')
    status = await client.get_status()
    print(f'Status: {status}')
    player_list = await client.get_player_list(100, 0)
    print(f'Players: {player_list}')


if __name__ == '__main__':
  asyncio.run(main())

If no response is received after the default timeout of 10 seconds a TimeoutError is raised.

Callback Usage

from trackmania_client import TrackManiaClient as TMClient
import asyncio

def callback_handler(callback: str, data: tuple):
  print(f'Callback: {callback}, {data}')

async def main():
  HOST = 'localhost'
  PORT = 5000

  async with TMClient(HOST, PORT) as client:
    print('Connected!')
    await client.authenticate('SuperAdmin', 'SuperAdmin')
    print('Authenticated!')

    client.register_general_callback_handler(callback_handler)

    result = await client.enable_callbacks()
    print(f'Callbacks enabled: {result}')

    echo = await client.echo()
    print(f'Echo: {echo}')

    client.unregister_general_callback_handler(callback_handler)

    result = await client.disable_callbacks()
    print(f'Callbacks disabled: {result}')

    echo = await client.echo()


if __name__ == '__main__':
  asyncio.run(main())

Output:

Connected!
Authenticated!
Callbacks enabled: True
Callback: TrackMania.Echo, echo param 2
Echo: True
Callbacks disabled: True

Handlers can also be registered to specific callbacks:

from trackmania_client import TrackManiaCallback as TMCallback

client.register_callback_handler(TMCallback.ECHO, echo_callback_handler)
client.unregister_callback_handler(TMCallback.ECHO, echo_callback_handler)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

trackmania-nations-forever-client-0.1.1.tar.gz (12.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file trackmania-nations-forever-client-0.1.1.tar.gz.

File metadata

File hashes

Hashes for trackmania-nations-forever-client-0.1.1.tar.gz
Algorithm Hash digest
SHA256 573ffcae995b6e60d681c4b08fc0fe696c20f5a15c9edd5f7e70479ab1b8935a
MD5 e5760af74172bf2972b7e81bb4f9ea54
BLAKE2b-256 e8f8dd759c131a70e3fc2b4f6c5580748fb9dbdc1c7bb2003d58d7ec316ba5ac

See more details on using hashes here.

File details

Details for the file trackmania_nations_forever_client-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for trackmania_nations_forever_client-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1ba45abbbd2ef3fa55d382cc0317e83431d269ce62a01b1c3cb7633a729b13b6
MD5 13b1b6175517144dc82797d5648fc196
BLAKE2b-256 39777be4ebcc5c9cd81c7e5678337aa501be3d3d3a1971caf7f020d875a581c1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page