A Zig version of the Rust comparison repo for the open.mp C API.
It demonstrates the full player lifecycle:
- exports
ComponentEntryPoint - initializes the open.mp C API
- registers
onPlayerConnectandonPlayerDisconnect - loads or creates player state from SQLite on connect
- applies persisted state to the live player
- snapshots and saves state on disconnect
include/ompcapi.h vendored open.mp C API header
vendor/sqlite/sqlite3.c vendored SQLite amalgamation
vendor/sqlite/sqlite3.h vendored SQLite header
build.zig shared library + test build
src/main.zig component, lifecycle, SQLite store, tests
zig build -Doptimize=ReleaseFastThe component shared library will be installed under:
zig-out/lib/
zig build testDefault database path:
scriptfiles/players.sqlite3
Override it with:
OPENMP_PLAYER_DB=/path/to/players.sqlite3 ./omp-server- Zig imports
ompcapi.hdirectly with@cImport, so there is no bindgen step. - SQLite is vendored as the amalgamation and compiled directly into the component.
- The unsafe/native boundary is flatter and more explicit than Rust.
- This example keeps DB work synchronous for clarity; for production, consider a worker queue for heavy saves.