Write open.mp gamemodes in Python.
pyopenmp brings Python scripting to open.mp, in the spirit of
PySAMP. A tiny native component embeds
CPython; everything else is pure Python that calls the open.mp C-API ($CAPI,
shipped with the server) directly through ctypes. The whole native surface
(772 functions, 91 events) is generated from the C-API specs.
from pyopenmp import on_player_connect, on_player_command_text, colors, Player
@on_player_connect
def welcome(player: Player):
player.send_client_message(colors.GREEN, "Welcome to the server!")
@on_player_command_text
def commands(player: Player, text: str) -> bool:
if text == "/help":
player.send_client_message(colors.YELLOW, "Commands: /help")
return True
return Falsenative/: minimal C component that embeds CPython and starts your gamemode.pyopenmp/: the Python package you copy to the server: entities, events, colors, and the generated bindings.tools/codegen.py: generates the ctypes bindings fromapi.json/events.json.examples/gamemodes/: example gamemode package (with acore/submodule).third_party/open.mp-capi/: vendored C-API specs (MPL-2.0).
Every generated native and event is listed in GENERATED.md.
Download the latest pyopenmp-<version>.zip
and copy the components/ files it contains straight into your server's
components/ folder, no build step needed:
gh release download --repo ricardoofnl/pyopenmp --pattern 'pyopenmp-*.zip'
unzip pyopenmp-*.zip
cp -r components/* /path/to/server/Server/components/The zip's components/ holds pyopenmp_native.so, pyopenmp_native.dll, and the
pyopenmp/ runtime package. Then add your gamemodes/ package at the server
root.
open.mp is 32-bit, so the embedded interpreter and $CAPI are 32-bit. Use a
32-bit Python build (like PySAMP). See docs/testing.md.
Licensed under the Mozilla Public License 2.0.