samp.directory
← Scripts y librerías

Sreyas-Sreelal/omprs-gdk

Rust SDK to write open.mp game modes

Plugin★ 21actualizado hace 23 horasApache-2.0Rust
Abrir en GitHub
Probar en el compilador de Pawn →

Añade sus archivos include, con las librerías de las que depende, al compilador de Pawn de tu navegador, listos para incluirlos en un script.

README.md

omprs

omprs is a tool to develop open.mp gamemodes and components in Rust.

Structure

CrateDescription
omp-codegenGenerates exported functions and FFI related code automatically
omp-sdkGDK crate, that does the core functionality like loading function address, executing, providing necessary types etc
ompThe main crate the is supposed to be used by the component or server developers, neatly exposing all of the functionalities and APIs.

Writing my first gamemode in Rust

  1. Download and install latest open.mp C-API component from here

  2. Create a new rust project cargo new mygm --lib

  3. Add omp to dependecies cargo add omp

  4. Add this to your Cargo.toml

    [lib]
    crate-type = ["cdylib"]
    
  5. Write a basic code like this

    use omp::{events::Events, main, register, types::colour::Colour};
    
    struct MyGM;
    
    impl Events for MyGM {
        fn on_player_connect(&mut self, player: omp::players::Player) {
            player.send_client_message(Colour::from_rgba(0xFFFFFFFF), "Welcome to my server!");
        }
    }
    
    #[main]
    pub fn game_main() {
        register!(MyGM);
    }
    
  6. Build your gamemode or component

    cargo +stable-i686 build

  7. Put the compile mygm.dll or mygm.so to components folder

  8. Run your server

Character Encoding (Non-ASCII Text)

By default, omp passes Rust's UTF-8 strings directly across the FFI boundary (CodePage::UTF8). Because the GTA:SA / SA-MP client expects single-byte Windows ANSI code pages for non-ASCII scripts (such as Windows-1251 for Cyrillic), configure the matching CodePage in your #[main] function:

use omp::{main, register, set_code_page, CodePage};

#[main]
pub fn game_main() {
    set_code_page(CodePage::Windows1251);
    register!(MyGM);
}

componentompopenmprustsamp

Esta página se genera con lo que GitHub publica sobre el repositorio. samp.directory no aloja el código. Informar de un problema con esta ficha

Sreyas-Sreelal/omprs-gdk: Plugin de SA-MP | samp.directory