Zomboid RCON Python Package

A Python package for Project Zomboid RCON

Project Zomboid is an open-world zombie survival simulation game. It’s pretty challenging and vastly popular. One great thing about it is that you can host your own servers for you and your friends to play in and die in the apocalypse together. I run a casual Project Zomboid server and when I found I wanted to execute commands programmatically, It was a little tricky to get up and running. To address this I built a Python library to make it easy!

Enter: ‘zomboid-rcon‘. RCON is a protocol that allows server administrators to remotely execute game server commands. While it’s not used by a lot of games, it’s used by some very popular ones including Minecraft, Rust, Project Zomboid, and more!

Goals & Features

  • To create a simple interface for running Project Zomboid RCON commands via Python
  • To be made accessible via Pypi for easy distribution
  • To have a built-in method for as many (if not all) server commands.
  • To allow for custom commands to be natively used if a wrapper doesn’t already exist.

Tech Stack

Demonstration

In the above demo, I use the ‘example.py‘ file from the Zomboid RCON repo. The first time I run the file it uses the ‘players’ method, which fetches a list of the players currently online. The second time I run the file the ‘help’ method is called, which returns a list of all RCON commands.

To try this code for yourself, use the ‘example.py‘ file from the root directory of the GitHub repo. Be sure to either set your environment variables to match those specified in the file, or to add your server details within the file itself.

Diving Deeper

Zomboid-RCON uses an existing Python library called ‘RCON‘ to send RCON commands to game servers. What Zomboid-RCON does to extend this functionality is it handles request timeouts, requires less code, and has dedicated methods for handling Project Zomboid server commands such as ‘serverMsg’, ‘players’, ‘help’, ‘quit’, and more.

This means an average user can download the Zomboid-RCON package:

pip install zomboid-rcon

And then can be up and running immediately with easy-to-use command methods for their Zomboid server!

from zomboid_rcon import ZomboidRCON

if __name__ == "__main__":
    pz = ZomboidRCON(ip='localhost', password='myPassword')
    
    print(pz.players().response)

Not all RCON commands in Project Zomboid currently have their own dedicated helper methods, but this doesn’t mean any command can be used. There’s a generic ‘command’ method to allow users to execute the command they want without restrictions:

from zomboid_rcon import ZomboidRCON

if __name__ == "__main__":
    pz = ZomboidRCON(ip='localhost', password='myPassword')

    print(pz.command("command", "arg1", "arg2").response)

There is currently a ‘known-issues’ section on the README.md of the Github repo & PYPI page. As of writing this post, there is only 1 known issue which has to do with the timeout functionality and its support for Windows computers.

I’m also intending to gradually add support for more and more command methods until all available Project Zomboid commands are supported.

See My Recent Projects

HermitClock

HermitClock

About the build This project was quite a fun one for me for a few reasons: It's my project, which is always exciting between projects for clients. It's a small project, so it was finished quickly without the risk of burnout. As I primarily work with brochure sites and...

Harwood Hypnotherapy

Harwood Hypnotherapy

About the build As with thegmtim.ca, another website I've built recently for a small business, I used WordPress with the Divi theme. With the needs of the project, it was a priority to keep the build time reasonable, as well as ensure it's easy to alter in the future....

PrismPress Gutenberg block

PrismPress Gutenberg block

As this website is primarily a web development blog and portfolio, I need to be able to display blocks of code to share with readers. While dozens of plugins are available on the WordPress plugin repo, none of them fit my exact requirements. I decided to build one myself so that I could utilise Prism.js, a lightweight…

jackwhitworth.com

jackwhitworth.com

As a web developer, having your own website is essential if you want to showcase your skills and abilities to potential future clients or employers. With that need comes an understandable pressure for your own website to reflect the quality of what you can create for someone else. This very website that you’re on right now is my own personal shop-front…