omprs is a tool to develop open.mp gamemodes and components in Rust.
| Crate | Description |
|---|---|
omp-codegen |
Generates exported functions and FFI related code automatically |
omp-sdk |
GDK crate, that does the core functionality like loading function address, executing, providing necessary types etc |
omp |
The main crate the is supposed to be used by the component or server developers, neatly exposing all of the functionalities and APIs. |
-
Download and install latest open.mp C-API component from here
-
Create a new rust project
cargo new mygm --lib -
Add
ompto dependeciescargo add omp -
Add this to your
Cargo.toml[lib] crate-type = ["cdylib"]
-
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); }
-
Build your gamemode or component
cargo +stable-i686 build -
Put the compile
mygm.dllormygm.sotocomponentsfolder -
Run your server