jmwhitworth's zomboid_rcon git repository banner

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.