Skip to main content

Python class for interacting with Project Zomboid servers using RCON

Project description

Zomboid-rcon: Python RCON for Project Zomboid Servers

Version: 1.2.0

Zomboid-rcon enables you to easily communicate with your Project Zomboid servers via RCON. With zomboid-rcon, you can send commands to your server, manage players, and more, all from within your Python script.

Installation

To get started, simply install zomboid-rcon using pip:

pip install zomboid-rcon

Usage

Using zomboid-rcon is easy. Here's a basic example:

from zomboid_rcon import ZomboidRCON

if __name__ == "__main__":
    pz = ZomboidRCON(ip='localhost', port=12345, password='myPassword')
    command = pz.serverMsg("You dead yet?")
    print(command.response)

This example connects to a server running on your local machine and sends the message "You dead yet?".

Zomboid-rcon provides several built-in methods for common server management tasks, such as getting a list of connected players:

from zomboid_rcon import ZomboidRCON

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

This example prints a list of all players currently connected to the server.

Available Commands

Zomboid-rcon provides built-in methods for the available RCON commands within Project Zomboid.

General Commands

  • additem("user", "item") : Items can be found on the PZ wiki: https://pzwiki.net/wiki/Items
  • addvehicle("user") : Spawns a vehicle.
  • addxp("user", "perk", xp) : Gives XP to a player.
  • alarm() : Sounds a building alarm at the admin's position. Must be in a room.
  • changeoption("option", "newOption") : Changes a server option.
  • chopper() : Places a helicopter event on a random player.
  • changepwd("pwd", "newPwd") : Changes your password.
  • createhorde("number") : Spawns a horde near a player.
  • godmode("user") : Makes a player invincible.
  • gunshot() : Makes a gunshot noise near the player.
  • help() : Brings up the help menu. (Lists native RCON commands. For all zomboid_rcon commands, refer to this list)
  • invisible("user") : Makes a player invisible to zombies.
  • noclip("user") : Allows a player to pass through solid objects.
  • quit() : Saves and quits the server.
  • releasesafehouse() : Releases a safehouse you own.
  • reloadlua("filename") : Reload a lua script on the server.
  • reloadoptions() : Reloads server options.
  • replay("user", [-record | -play | -stop], "filename") : Records and plays a replay for a moving player.
  • save() : Saves the current world.
  • sendpulse() : Toggles sending server performance info to the client.
  • showoptions() : Shows a list of current server options and values.
  • startrain() : Starts rain on the server.
  • stoprain() : Stops rain on the server.
  • teleport("user", "toUser") : Teleports to a player.
  • teleportto(x, y, z) : Teleports to certain coordinates.

Moderation Commands

  • addalltowhitelist() : Adds all current users connected with a password to the whitelist.
  • adduser("user", "pwd") : Adds a new user to the whitelist.
  • addusertowhitelist("user") : Adds a single user connected with a password to the whitelist.
  • removeuserfromwhitelist("user") : Removes a single user connected with a password to the whitelist.
  • banid("SteamID") : Bans a Steam ID.
  • unbanid("SteamID") : Unbans a Steam ID.
  • banuser("user") : Bans a user.
  • unbanuser("user") : Unbans a user.
  • checkModsNeedUpdate() : Indicates whether a mod has been updated. Writes answer to log file.
  • grantadmin("user") : Gives admin rights to a user.
  • removeadmin("user") : Removes admin rights to a user.
  • kickuser("user") : Kicks a user from the server.
  • players() : Lists all connected players.
  • servermsg("message") : Broadcast a message to all players. (Spaces are replaced with underscores for compatibility)
  • setaccesslevel("user", [admin | moderator | overseer | gm | observer]) : Set the access/permission level of a player.
  • voiceban("user", [-true | -false]) : Ban a user from using the voice feature.

Command not listed?

You can execute any custom command using the command method:

pz.command("command", "arg1", "arg2", "etc")

Demonstration

Zomboid RCON demonstration GIF

Known Issues

Please note that zomboid-rcon uses the timeout_decorator package, which is currently only compatible with Unix/Linux systems. As a result, timeouts may cause errors on Windows machines. We are actively working on finding an alternative solution for Windows users.

Contributing

We welcome contributions from anyone! If you would like to contribute to the project, please open an issue or submit a pull request on Github.

Testing

Tests can be ran using unittest:

python -m unittest ./tests/*.py

License

Zomboid-rcon is licensed under the GPL-3.0 license.

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

zomboid_rcon-1.2.0.tar.gz (45.6 kB view details)

Uploaded Source

Built Distribution

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

zomboid_rcon-1.2.0-py3-none-any.whl (33.4 kB view details)

Uploaded Python 3

File details

Details for the file zomboid_rcon-1.2.0.tar.gz.

File metadata

  • Download URL: zomboid_rcon-1.2.0.tar.gz
  • Upload date:
  • Size: 45.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.24

File hashes

Hashes for zomboid_rcon-1.2.0.tar.gz
Algorithm Hash digest
SHA256 dffd9059f6e6036d36184742537aedf9b4614373c88d540847b440b683d62570
MD5 ae3250522be7853e031abe29b42ed94d
BLAKE2b-256 724de9eb7e371dd93133d45ad34a0929315f2420d62b446806385d37ddaf2d79

See more details on using hashes here.

File details

Details for the file zomboid_rcon-1.2.0-py3-none-any.whl.

File metadata

  • Download URL: zomboid_rcon-1.2.0-py3-none-any.whl
  • Upload date:
  • Size: 33.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.24

File hashes

Hashes for zomboid_rcon-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4674b5332d273f35905bd2b29c7b957ce930e43b88ad195eee03fb5ec3906137
MD5 86599fc99fcb61f218905982f95ce5fc
BLAKE2b-256 6997635584c34355324bf8ebf8c81df6790018b8a742aecf2111c12b549f64da

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