SA-MP API client for python supporting both query and RCON APIs
Project description
GTA SA-MP client
RCON and query client library for Python
A modern Python library for querying and managing SA-MP servers.
Supported Python version 3.4 or newer. If you require support for Python 2.7, install 2.1 version of the package.
Installation
pip install samp-client
Usage
The library can be easily interfaced using a single SampClient
class:
from samp_client.client import SampClient
with SampClient(address='localhost', port=7777) as client:
print(client.get_server_info())
The library also allows you to run RCON commands as well as queries:
from samp_client.client import SampClient
with SampClient(address='localhost', port=7777, rcon_password='password') as client:
client.rcon_cmdlist()
Query and RCON responses are parsed into native Python structures:
from samp_client.client import SampClient
with SampClient(address='localhost', port=7777, rcon_password='password') as client:
info = client.get_server_info()
print(info)
# ServerInfo(password=True, players=9, max_players=100, hostname='Convoy Trucking', gamemode='Convoy Trucking 3.1.1', language='English')
print(info.gamemode)
# 'Convoy Trucking 3.1.1'
print(client.rcon_get_hostname())
# ServerVar(name='hostname', value='Convoy Trucking', read_only=False)
print(client.rcon_players()[0].ping)
# 26
Examples
Folder example/
contains usage example of the library
Running tests
To run tests:
python -m unittest discover -v
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
samp-client-3.0.tar.gz
(6.9 kB
view hashes)
Built Distributions
Close
Hashes for samp_client-3.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a790ae2720801f58d747c06be4a6720f0fbe22fb4e3d3c804005d8427dbd53fe |
|
MD5 | 9df67173ed019de690de0c3eb547065d |
|
BLAKE2b-256 | 7eae71096ba3b16afece313f1466068ea2cd8698f65e5fea5c238b6b73538ea7 |
Close
Hashes for samp_client-3.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 70a89b93ee779657164a2d0ec562f74e50cc61c7c404446e2fe9dbcd68c83692 |
|
MD5 | 6cf11783e22801d827c586d6ee647b6d |
|
BLAKE2b-256 | e1e477f690a8174ec3dede91406d4dc1000d7f00c6eea90c642e54f050f9c793 |