Releases: Sreyas-Sreelal/omprs-gdk
1.1.0
What's Changed
- add
get_id
andget_from_id
methods forGangzones
- fix: NetworkStats: use the correct types to reflect open.mp's struct by @ZantetsukenGT in #2
New Contributors
- @ZantetsukenGT made their first contribution in #2
Full Changelog: 1.0.1...1.1.0
1.0.1
Exposed some of the structs fields to be public
Full Changelog: 1.0.0...1.0.1
1.0.0
-
(fixes #1) Removed following
Player
methods:net_stats__bytes_received
net_stats__bytes_sent
net_stats__connection_status
net_stats__get_connected_time
net_stats__get_ip_port
net_stats__messages_received
net_stats__messages_recv_per_second
net_stats__messages_sent
net_stats__packet_loss_percent
-
Added new
Player
methods:get_net_stats
- returns NetworkStats objectnet_stats_get_ip_port
- returns a NetworkID object
-
Now
register!
macro can be used on multiple objects, works similar to hooks in PAWN. The order of execution of events/callbacks in each "module" depends on the order in whichregister!
is called and the return value of last executed callback is considered to be the final, unless this chain is terminated usingterminate_event!
macro.
use omp::{events::Events, main, register, terminate_event, types::colour::Colour};
struct MyGreeterModule;
impl Events for MyGreeterModule {
fn on_player_connect(&mut self, player: omp::players::Player) {
player.send_client_message(Colour::from_rgba(0xFF000000), "Greetings Player");
}
fn on_player_text(&mut self, player: omp::players::Player, message: String) -> bool {
if message.contains("badword") {
terminate_event!(false);
}
true
}
}
struct MyMainGamemode;
impl Events for MyMainGamemode {
fn on_player_connect(&mut self, player: omp::players::Player) {
player.send_client_message(
Colour::from_rgba(0x00FF0000),
&format!("Player {} connected!!!", player.get_name()),
);
}
fn on_player_text(&mut self, player: omp::players::Player, message: String) -> bool {
true
}
}
#[main]
fn entry() {
register!(MyGreeterModule);
register!(MyMainGamemode);
}
0.2.0
Full Changelog: 0.1.0...0.2.0
0.1.0
First Release of OMPRS
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 dependecies
cargo 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