https://github.com/pycckue-bnepeg/samp-rs
SA:MP SDK written in Rust
https://github.com/pycckue-bnepeg/samp-rs
amx bindings plugin plugins rust samp samp-plugin samp-sdk sdk
Last synced: about 1 year ago
JSON representation
SA:MP SDK written in Rust
- Host: GitHub
- URL: https://github.com/pycckue-bnepeg/samp-rs
- Owner: Pycckue-Bnepeg
- Created: 2018-02-13T22:09:35.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2024-04-16T07:17:17.000Z (about 2 years ago)
- Last Synced: 2025-04-28T23:45:08.333Z (about 1 year ago)
- Topics: amx, bindings, plugin, plugins, rust, samp, samp-plugin, samp-sdk, sdk
- Language: Rust
- Size: 1.28 MB
- Stars: 49
- Watchers: 4
- Forks: 11
- Open Issues: 3
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
[](https://docs.rs/samp)
[](https://crates.io/crates/samp)
# samp-rs
samp-rs is a tool to develop plugins for [samp](http://sa-mp.com) servers written in rust.
# documentation
it's [here](https://zottce.github.io/samp-rs/samp/index.html)! need to find a way to fix docs.rs ...
# project structure
* `samp` is a glue between crates described below (that's what you need).
* `samp-codegen` generates raw `extern "C"` functions and does whole nasty job.
* `samp-sdk` contains all types to work with amx.
# usage
* [install](https://rustup.rs) rust compiler (supports only `i686` os versions because of samp server arch).
* add in your `Cargo.toml` this:
```toml
[lib]
crate-type = ["cdylib"] # or dylib
[dependencies]
samp = "0.1.2"
```
* write your first plugin
# migration from old versions
* check out [the guide](migration.md)
# examples
* simple memcache plugin in `plugin-example` folder.
* your `lib.rs` file
```rust
use samp::prelude::*; // export most useful types
use samp::{native, initialize_plugin}; // codegen macros
struct Plugin;
impl SampPlugin for Plugin {
// this function executed when samp server loads your plugin
fn on_load(&mut self) {
println!("Plugin is loaded.");
}
}
impl Plugin {
#[native(name = "TestNative")]
fn my_native(&mut self, _amx: &Amx, text: AmxString) -> AmxResult {
let text = text.to_string(); // convert amx string into rust string
println!("rust plugin: {}", text);
Ok(true)
}
}
initialize_plugin!(
natives: [Plugin::my_native],
{
let plugin = Plugin; // create a plugin object
return plugin; // return the plugin into runtime
}
)
```