rust-samp

CI License: MIT dependency status Benchmarks

rust-samp

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.

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 bindgen or any C/C++ dependency.

Quickstart

rustup target add i686-unknown-linux-gnu

Cargo.toml:

[lib]
crate-type = ["cdylib"]

[dependencies]
samp = { git = "https://github.com/NullSablex/rust-samp.git", tag = "v3.0.0" }

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-gnu

Drop the resulting .so into the server’s plugins/. Full walkthrough in docs/first-plugin.md.

Workspace

Crate Version Purpose
samp 3.0.0 Main crate — depend on this one.
samp-sdk 3.0.0 Low-level bindings: AMX VM + Open Multiplayer component ABI.
samp-codegen 1.3.0 Procedural macros (#[native], initialize_plugin!, SampPlugin).

Edition 2024, workspace resolver = "3". Target: i686 — both servers are 32-bit.

Platform matrix

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

Feature flags

Examples

Path Highlights
examples/hello Minimal plugin (#[derive(SampPlugin)], &AmxString, write_str).
examples/counter Stateful plugin with on_tick, Ref<i32>, full constructor block.
examples/advanced Memcache plugin: custom AmxCell, encoding feature, layered fern.

Documentation

Full user docs under docs/ (MkDocs Material). Starting points:

License

MIT — see LICENSE.