#altv

altv_internal_logger

An internal logger for alt:V module. Not intended for direct use.

71 releases (3 stable)

16.0.0-dev.1 Dec 29, 2023
15.1.0 Oct 22, 2023
15.0.0-rc.4 Aug 24, 2023
15.0.0-rc.1 Jul 23, 2023
0.3.1 Apr 17, 2023

#4 in #altv

Download history 14/week @ 2023-11-04 35/week @ 2023-11-11 183/week @ 2023-11-18 278/week @ 2023-11-25 101/week @ 2023-12-02 18/week @ 2023-12-09 100/week @ 2023-12-16 208/week @ 2023-12-23 17/week @ 2023-12-30 12/week @ 2024-01-06 12/week @ 2024-01-13 9/week @ 2024-01-20 341/week @ 2024-01-27 9/week @ 2024-02-03 273/week @ 2024-02-10 1574/week @ 2024-02-17

2,200 downloads per month
Used in 3 crates (2 directly)

MIT license

7KB


Server-side alt:V API for Rust

crates.io

altv::events::on_player_connect(|event| {
    let name = event.player.name()?;
    altv::log!("player with name: {name} connected!");
    Ok(())
});

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 found when installing or building altv_internal_sdk, try this

Video format of this tutorial if you are more into video tutorials

  1. Create new cargo package with cargo new altv-resource --lib

  2. Configure cargo to compile your crate as cdylib in your Cargo.toml

[lib]
crate-type = ['cdylib']
  1. After that you can install altv crate with: cargo add altv

  2. Next step will be to add main function to your resource (src/lib.rs)

use altv::prelude::*; // Entity, WorldObject traits

#[altv::main] // This is required
fn main() -> impl altv::IntoVoidResult {
    altv::log!("~gl~hello world");
}
  1. Now you can build your resource with cargo build

  2. 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)

  3. Create new alt:V resource, in resources directory of your server

  4. Copy compiled .dll or .so to resource directory

  5. Create resource.toml with this content:

type = 'rs'
main = 'example.dll' # your compiled .dll or .so
  1. Don't forget to add resource to server.toml

  2. Now you can download rust-module .dll or .so from latest release or with cargo-altvup

  3. Copy it to modules directory of your server (if you do not use cargo-altvup)

  4. Add rust-module to server.toml like that:

modules = ['rust-module']
  1. Now if you have done everything correctly, you should see green "hello world" message in server console

Dependencies

~0.1–9MB
~55K SLoC