Crates.io | samp |
lib.rs | samp |
version | 0.1.2 |
source | src |
created_at | 2019-03-16 12:19:29.395383 |
updated_at | 2019-03-20 10:08:07.826191 |
description | Tools to develop SA:MP plugins |
homepage | |
repository | https://github.com/zottce/samp-rs/ |
max_upload_size | |
id | 121353 |
size | 14,101 |
samp-rs is a tool to develop plugins for samp servers written in rust.
it's here! need to find a way to fix docs.rs ...
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.i686
os versions because of samp server arch).Cargo.toml
this:[lib]
crate-type = ["cdylib"] # or dylib
[dependencies]
samp = "0.1.0"
plugin-example
folder.lib.rs
fileuse 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
}
)