samp.directory
← Scripts and libraries

zottce/samp-rs

SA:MP SDK written in Rust

Plugin★ 53updated Apr 2024No licenceRust
Open on GitHub

This repository has no licence file. It is public to read, but that alone does not give permission to reuse it.

Try it in the Pawn compiler →

Adds its include files, with the libraries it depends on, to the Pawn compiler in your browser, ready to include in a script.

readme.md

samp-rs

samp-rs is a tool to develop plugins for samp servers written in rust.

documentation

it's here! 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 rust compiler (supports only i686 os versions because of samp server arch).
  • add in your Cargo.toml this:
[lib]
crate-type = ["cdylib"] # or dylib

[dependencies]
samp = "0.1.2"
  • write your first plugin

migration from old versions

examples

  • simple memcache plugin in plugin-example folder.
  • your lib.rs file
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<bool> {
        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
    }
)

amxbindingspluginpluginsrustsampsamp-pluginsamp-sdksdk

This page is built from what GitHub publishes about the repository. samp.directory does not host the code. Report a problem with this listing

zottce/samp-rs: SA-MP Plugin | samp.directory