Server-side alt:V API for Rust
on_player_connect;
New server-side Rust module for alt:V platform
Big thanks to the creator of the first Rust module, as their work helped me understand how to start my own module
Client-side part
Work is being done in this branch. Will never be published or released because alt:V does not allow you to use custom client-side modules (.dll) in production
Docs
API documentation can be found here
How to use
Before all this, you need to install LLVM
On Windows set LIBCLANG_PATH as an environment variable pointing to the bin directory of your LLVM install. For example, if you installed LLVM to D:\programs\LLVM, then you'd set the value to be D:\programs\LLVM\bin
If you are on Windows you also need to have installed Visual Studio with MSVC compiler (usually installed with Rust using Rustup)
If you have similar error:
src/alt_bridge.h:5:10: fatal error: 'memory' file not foundwhen installing or building altv_internal_sdk, try this
Video format of this tutorial if you are more into video tutorials
-
Create new cargo package with
cargo new altv-resource --lib -
Configure cargo to compile your crate as
cdylibin yourCargo.toml
[]
= ['cdylib']
-
After that you can install
altvcrate with:cargo add altv -
Next step will be to add main function to your resource (
src/lib.rs)
use *; // Entity, WorldObject traits
// This is required
-
Now you can build your resource with
cargo build -
In
target/debug/you should see the.dllor.soyou just compiled (if you don't see it, make sure you setlib.crate-typeto["cdylib"], see step 2) -
Create new alt:V resource, in
resourcesdirectory of your server -
Copy compiled
.dllor.soto resource directory -
Create
resource.tomlwith this content:
= 'rs'
= 'example.dll' # your compiled .dll or .so
-
Don't forget to add resource to
server.toml -
Now you can download rust-module
.dllor.sofrom latest release or withcargo-altvup -
Copy it to
modulesdirectory of your server (if you do not usecargo-altvup) -
Add
rust-moduletoserver.tomllike that:
= ['rust-module']
- Now if you have done everything correctly, you should see green "hello world" message in server console