samp.directory
← Скрипты и библиотеки

Sreyas-Sreelal/omprs-gdk

Rust SDK to write open.mp game modes

Плагин★ 20обновлён нояб. 2025 г.Apache-2.0Rust
Открыть на GitHub

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

componentompopenmprustsamp

Страница собрана из того, что GitHub публикует о репозитории. samp.directory не хранит этот код. Сообщить о проблеме с этой записью