Skip to main content

A SAMP query/RCON client for Python using trio.

Project description

samp_query

CI

samp-query is a Python library for interacting with SA-MP/open.mp servers using the query protocol. It provides functionality to query server information, retrieve player list, show rules, and execute remote console (RCON) commands.

Installation

To install the library, you can use pip:

pip install samp-query

Features

  • Connect to a game server using IP address and port.
  • Retrieve server information including name, player count, maximum players, gamemode, and language.
  • Get a list of players currently on the server with their name and score.
  • Fetch a list of rules and their values set on the server.
  • Execute RCON commands on the server (requires RCON password).

Usage

Here's a basic example of how to use the library:

import trio
from samp_query import Client


async def main():
    client = Client(
        ip='127.0.0.1',
        port=7777,
        rcon_password=None,  # Your rcon password as string
    )
    await client.connect()

    info = await client.info()
    print(f'Server Name: {info.name}')
    print(f'Player Count: {info.players}/{info.max_players}')

    player_list = await client.players()
    print('Players:')

    for player in player_list.players:
        print(f'- {player.name} (Score: {player.score})')

    rule_list = await client.rules()
    print('Rules:')

    for rule in rule_list.rules:
        print(f'- {rule.name}: {rule.value}')

    if client.rcon_password:
        response = await client.rcon('echo Hello, server!')
        print(f'RCON Response: {response}')


trio.run(main)

Make sure to replace '127.0.0.1' and 7777 with the actual IP address and port of the game server you want to connect to. If the server has RCON enabled, provide a password in the rcon_password attribute of the samp_query.Client instance (otherwise keep it None).

Documentation

For more information, you can read the documentation.

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

samp_query-0.3.0.tar.gz (6.6 kB view details)

Uploaded Source

Built Distribution

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

samp_query-0.3.0-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

File details

Details for the file samp_query-0.3.0.tar.gz.

File metadata

  • Download URL: samp_query-0.3.0.tar.gz
  • Upload date:
  • Size: 6.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.10

File hashes

Hashes for samp_query-0.3.0.tar.gz
Algorithm Hash digest
SHA256 d52bc1c996c3f07db75d0d49a3c915d55aa42fc0c90600f2c36240618c07ddf4
MD5 531262cfcb1e164d17a2919888e1343d
BLAKE2b-256 21fadc5b68383664e3bfdcc7c8fb68b8dc4cd14a0c0afc11d3c92ed79cb3a174

See more details on using hashes here.

File details

Details for the file samp_query-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: samp_query-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 7.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.10

File hashes

Hashes for samp_query-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 87f2d1ebd5e525a5fab3a29b6ca1e3d215ce6ae013773c8ef0e306f6873712cf
MD5 6eef23336c6e3be61160714a6a844a90
BLAKE2b-256 bf25c05cba9b38ae6a301d864e98215985f2cbd8627dac34678c4e962b31941c

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