New server-side Rust module for alt:V platform (WIP)
Big thanks to the creator of the first Rust module, as their work helped me understand how to start my own module
Before start writing your server-side in Rust you need to install LLVM
if you are on Windows, don't forget to set
LIBCLANG_PATH
as an environment variable
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 cdylib
in your Cargo.toml
toml
[lib]
crate-type = ['cdylib']
After that you can install altv
crate with: cargo add altv
Next step will be to add main function to your resource (src/lib.rs
)
```rust
use altv::prelude::*; // Entity, WorldObject traits
fn main() { altv::log!("~gl~hello world"); } ```
Now you can build your resource with cargo build
In target/debug/
you should see the .dll
or .so
you just compiled (if you don't see it, make sure you set lib.crate-type
to ["cdylib"]
, see step 2)
Create new alt:V resource, in resources
directory of your server
Copy compiled .dll
or .so
to resource directory
Create resource.toml
with this content:
toml
type = 'rs'
main = 'example.dll' # your compiled .dll or .so
Don't forget to add resource to server.toml
Now you can download rust-module .dll
or .so
from latest release
Copy it to modules
directory of your server
Add rust-module
to server.toml
like that:
toml
modules = ['rust-module']
Now if you have done everything correctly, you should see green "hello world" message in server console