5 releases (3 stable)
1.1.0 | Jun 9, 2024 |
---|---|
1.0.1 | Jun 6, 2024 |
1.0.0 | Jun 1, 2024 |
0.2.0 | May 20, 2024 |
0.1.0 | May 6, 2024 |
#362 in Unix APIs
Used in omp
230KB
5K
SLoC
omprs
omprs is a tool to develop open.mp gamemodes in Rust.
Structure
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 players, neatly exposing all of the functionalities and APIs. |
Writing my first gamemode in Rust
-
Download the omprs component from here
-
Place the
Rust.dll
orRust.so
component incomponents
folder -
Create a new rust project
cargo new mygm --lib
-
Add
omp
to 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 the gamemode
cargo +stable-i686 build
-
Put the compile
mygm.dll
ormygm.so
togamemodes
folder -
Goto
config.json
add following to it"rust":{ "gamemode":"mygm" }
-
Run your server
lib.rs
:
GDK crate, that does the core functionality like loading function address, executing, providing necessary types etc
Dependencies
~0.2–35MB
~537K SLoC