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.
This crate contains the raw bindings for ScriptHookV without any wrapping.
Add the following to your cargo.toml
dependencies:
libscripthookv-sys = "0.1.0"
This crate contains a wrapped api for ScriptHookV
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"
This crate contains a wrapped api for GTA 5 natives. It should be installed together with the scripthookv-rs
crate.
This crate has not been published yet.
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 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.
- 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.
Pull requests are always welcome. For major changes, please open an issue first to discuss what you would like to change.
- ScriptHookVDotNet for being a big inspiration for the wrapped native API.
- Salted, Daniel, and ikt for general help.