Rust toolkit for writing SA-MP server plugins and native Open Multiplayer components. A single compiled binary works as a SA-MP plugin and as a first-class Open Multiplayer component, with no extra configuration.
As a component it can also talk to the Open Multiplayer server directly — player and vehicle events delivered by the server itself, entities created and read, players found by id — instead of going through Pawn. See Talking to the Server Directly.
Fork of samp-rs by ZOTTCE. Modernized for Rust edition 2024 and extended with a pure-Rust implementation of the Open Multiplayer component ABI (Itanium and MSVC), without
bindgenor any C/C++ dependency.
Not affiliated. This is an independent, community-maintained project. It is not affiliated with, endorsed by, sponsored by, or otherwise connected to SA-MP, the open.mp (Open Multiplayer) project, or the upstream
samp-rsrepository this fork derives from. It has no relationship with any of them. "SA-MP" and "open.mp" belong to their respective owners and are referenced here solely to describe what this toolkit is compatible with.
rustup target add i686-unknown-linux-gnuCargo.toml — from crates.io:
[lib]
crate-type = ["cdylib"]
[dependencies]
samp = { package = "rust-samp", version = "3" }
log = "0.4"Or via git (any version, including v3.0.0 and earlier, which are not on crates.io):
[dependencies]
samp = { git = "https://github.com/NullSablex/rust-samp.git", tag = "vX.Y.Z" }The package is published as rust-samp to avoid colliding with the
upstream samp-rs fork on the registry. The package = "rust-samp"
alias keeps source-level use samp::prelude::*; imports unchanged.
src/lib.rs:
use samp::prelude::*;
use samp::{native, initialize_plugin, SampPlugin};
#[derive(SampPlugin, Default)]
struct Hello;
impl Hello {
#[native(name = "Hello_Greet")]
fn greet(_amx: &Amx, name: &AmxString, out: UnsizedBuffer, size: usize) -> AmxResult<bool> {
out.write_str(size, &format!("Hello, {}!", &**name))?;
Ok(true)
}
}
initialize_plugin!(type: Hello, natives: [Hello::greet]);cargo build --release --target i686-unknown-linux-gnuDrop the resulting .so into the server's plugins/. Full walkthrough in
docs/first-plugin.md.
| Crate | Purpose |
|---|---|
samp |
Main crate — depend on this one. |
samp-sdk |
Low-level bindings: AMX VM + Open Multiplayer component ABI. |
samp-codegen |
Procedural macros (#[native], initialize_plugin!, SampPlugin). |
Each crate is versioned on its own: a repository release (v3.x.y,
the GitHub tag) bundles whatever crate versions it lists in the
CHANGELOG, so the crate numbers on crates.io need not
match the release number.
Edition 2024, workspace resolver = "3". Target: i686 — both servers
are 32-bit.
| Target | SA-MP | Native Open Multiplayer | Build command |
|---|---|---|---|
i686-unknown-linux-gnu |
✅ | ✅ (Itanium ABI) | cargo build |
i686-pc-windows-msvc |
✅ | ✅ (MSVC ABI) | cargo xwin build --xwin-arch x86 (from Linux) |
i686-pc-windows-gnu |
✅ | ❌ | cargo build --features samp-only |
- (default) — SA-MP exports + Open Multiplayer
ComponentEntryPoint. samp-only— opt out of the Open Multiplayer code path; plugin still loads on Open Multiplayer in legacy mode. Declare it on the plugin assamp-only = ["samp/samp-only"]and build with--features samp-only, so the plugin's own#[cfg(feature = "samp-only")]agrees with the SDK.encoding— string conversion for the code pages servers run (Windows-1250 through 1257, ISO-8859-2, UTF-8 and the rest of the WHATWG set) viaencoding_rs.debug—samp::debug: the AMX_DBG debug-info parser plus the opcode helpers (numbering, instruction sizes, the computed-gotoOpcodeMap) and call-stack walking, for building debuggers and tooling on the VM (see VM Debugging).compression— gzip-compress rotated log archives (LoggerConfig::compress_archives); pulls inflate2.
| Path | Highlights |
|---|---|
examples/hello |
Minimal plugin (#[derive(SampPlugin)], &AmxString, write_str). |
examples/counter |
Stateful plugin: on_tick, Ref<i32>, background work, native open.mp events and entities. |
examples/advanced |
Memcache plugin: custom AmxCell, encoding feature, layered fern. |
examples/sink-demo |
External log sink: end-to-end Sentry integration via the Sink trait. |
examples/omp-showcase |
Test harness: runs every generated open.mp wrapper on a live server — entities, an NPC as player, set/get round trips. |
Full user docs under docs/ (MkDocs Material). Starting points:
- Introduction and Setup.
- First plugin and Plugin anatomy.
- Native Open Multiplayer support and talking to the server directly.
- Logging and VM Debugging.
- API reference and Migration guide.
MIT — see LICENSE.