Using this script, it is possible to allow players in "Hell Let Loose" to switch sides without having to ask the administrator.
Administrators also do not need to leave the game. Anyone can enter the command !switchme
into the game's chat, and they will
automatically switch between Axis or Allied forces. Additionally, the tool has a restriction that can be utilized.
This allows specifying the maximum allowed number of players, after which executing the command is no longer possible.
For example, this could allow switching during seeding, but not afterwards.
ToDo: Execute the following commands after downloading:
- Copy the
.env.dist
file to.env
and enter your values. - Run the command
pip install python-dotenv
. - Copy
troop-exchange.service.dist
to/etc/systemd/system/troop-exchange.service
- Activate and start the service with
sudo systemctl enable troop-exchange.service
andsudo systemctl start troop-exchange.service
.
- Log Monitoring: Continuously monitors the game server log for a specific chat command (
!switchme
). - Player Count Check: Ensures the number of players on the server is below a set maximum before switching a player to the opposing team.
- RCON API Integration: Uses an RCON API to manage team switching on the server.
- Configurable Limits: The maximum number of players on the server before switching is restricted is configurable via environment variables.
- Python 3.8+
- A game server with an RCON API
.env
file with the following environment variables:RCON_API_URL
: The URL for the RCON APIAPI_TOKEN
: The API token for authenticating with the RCON APILOG_FILE_PATH
: Path to the game log file to be monitoredMAX_PLAYERS
: Maximum number of players allowed before the bot stops switching players (optional, default is 40)
-
Clone the repository:
git clone https://github.com/hackletloose/hall-troop-exchange.git cd hall-trop-exchange
-
Install the required Python dependencies:
pip install -r requirements.txt
-
Create a
.env
file in the root directory with the following content:RCON_API_URL=https://your-rcon-api-url API_TOKEN=your-api-token LOG_FILE_PATH=/path/to/your/logfile.log MAX_PLAYERS=40 # Optional, default is 40
-
Run the script:
python troop-exchange.py
-
Monitor Server Logs: The script continuously monitors the log file specified in the
.env
file for the!switchme
command. -
Automatic Team Switching: When a player uses the
!switchme
command in the game chat, the bot checks the total number of players on the server. If the number of players is below the configured maximum, it switches the player to the opposing team. -
Logs and Debugging: The script also prints out messages for actions such as successful player switches or errors during communication with the RCON API.
The following environment variables must be set in the .env
file:
RCON_API_URL
: The base URL for the RCON API that the bot will use to interact with the game server.API_TOKEN
: A token for authenticating requests to the RCON API.LOG_FILE_PATH
: The path to the log file that the bot will monitor.MAX_PLAYERS
: The maximum number of players allowed on the server before the bot stops switching players (default is 40).
requests
: For sending HTTP requests to the RCON APIpython-dotenv
: For loading environment variables from the.env
filesubprocess
: For monitoring the log file in real time
Feel free to fork this repository and create a pull request if you want to contribute to the project. You can also open issues if you encounter any problems or have suggestions for new features.
This project is licensed under the MIT License. See the LICENSE file for more details.