[][src]Crate samp

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

project structure

usage

[lib]
crate-type = ["cdylib"] # or dylib

[dependencies]
samp = "0.2.5"

examples

This example deliberately fails to compile
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
    }
);

Re-exports

pub use samp_codegen::initialize_plugin;
pub use samp_codegen::native;

Modules

amx

Core Amx types with additional functions.

args

Workaround to parse input of natives functions.

cell

Different smart-pointers to work around raw AMX values.

consts

Default AMX constants.

encoding

String encoding.

error

Work with AMX errors.

exports

Types to get exported functions by AMX.

plugin

Contains a plugin interface.

prelude

Most used imports.

raw

Raw C definitions of AMX sturcture.

Macros

exec_public

Execute a public AMX function by name.