scripthookv-rs

Crates.ioscripthookv-rs
lib.rsscripthookv-rs
version0.3.0
sourcesrc
created_at2021-12-17 17:12:01.027452
updated_at2022-03-26 17:11:03.904918
descriptionRust bindings for ScriptHookV
homepagehttps://github.com/DottieDot/ScriptHookV-rs
repositoryhttps://github.com/DottieDot/ScriptHookV-rs.git
max_upload_size
id499688
size50,258
(DottieDot)

documentation

README

scripthookv-rs

Scripthookv-rs provides Rust bindings for ScriptHookV and GTA 5 natives.

DISCLAIMER: This crate is still in early development and API is subject to change.

Crates

libscripthookv-sys

This crate contains the raw bindings for ScriptHookV without any wrapping.

Installation

Add the following to your cargo.toml dependencies:

libscripthookv-sys = "0.1.0"

scripthookv-rs

This crate contains a wrapped api for ScriptHookV

Installation

Add the following to your cargo.toml dependencies:

scripthookv-rs = "0.3.0"
once_cell = "1.9.0"
winapi = { version = "0.3.9", features = [ "consoleapi", "winuser", "wincon" ] }
async-trait = "0.1.52"

scripthookv-rs-gta

This crate contains a wrapped api for GTA 5 natives. It should be installed together with the scripthookv-rs crate.

Installation

This crate has not been published yet.

Usage

Entrypoint

For your entrypoint you can use the shv_entrypoint macro. This macro generates a DllMain for you.

extern "C" fn script_main() {
  loop {
    // On tick logic

    script_yield();
  }
}

#[shv_entrypoint]
fn entrypoint(module: ModuleHandle) -> ScriptHookV {
  ScriptHookVBuilder::new(module)
    .script(script_main)
    .build()
}

Natives

Natives can be invoked directly with the native_call macro like this:

call_native!(Vehicle, 0xAF35D0D2583051B0, adder_hash, coords, heading, false, false, false);
//           ^^^^^^^  ^^^^^^^^^^^^^^^^^^  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
//       Return type         Native hash                                        Parameters

Alternatively you can use my nativedb to generate wrapping similar to a natives.h file.

Road map

  • Wrap all ScriptHookV functions*.
  • Dedicated readmes for all crates.
  • More elegant wrapping for ScriptHookV.
  • Provide elegant API for most natives.
  • Provide a UI crate similar to LemonUI.
  • Automated tests.

* excluding deprecated functions.

Contributing

Pull requests are always welcome. For major changes, please open an issue first to discuss what you would like to change.

Acknowledgements

License

MIT

Commit count: 66

cargo fmt