Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
4fc735d
convert all functions to open.mp capi's style
Sreyas-Sreelal Jun 25, 2024
8ae6536
Pickup_AddStatic returns bool
Sreyas-Sreelal Jun 25, 2024
d90f2a6
convert whole event system to new capi ones
Sreyas-Sreelal Jun 26, 2024
377365a
null
Sreyas-Sreelal Jun 27, 2024
6c0cfc0
a safer way to pass string
Sreyas-Sreelal Jun 27, 2024
172dde8
fmt
Sreyas-Sreelal Jun 27, 2024
c0c15ca
mutable string
Sreyas-Sreelal Jun 27, 2024
623b4a7
bring back accidentally removed Copy trait
Sreyas-Sreelal Jun 27, 2024
1050cac
generate uid
Sreyas-Sreelal Jun 28, 2024
b81cd7e
fix string allocation
Sreyas-Sreelal Jun 28, 2024
6ad60ea
add playerobject getid and fromid
Sreyas-Sreelal Jun 29, 2024
29f4a1f
fmt
Sreyas-Sreelal Jun 29, 2024
bcfbf55
add option to specify component name and version in entry macro
Sreyas-Sreelal Jun 29, 2024
87fb345
clippy lints ignored for generated code
Sreyas-Sreelal Jun 29, 2024
419e3ec
disable annoying clippy warning on macro expansion (possbile bug in c…
Sreyas-Sreelal Jun 29, 2024
cb56a0b
callback strings
Sreyas-Sreelal Jun 30, 2024
d9fb370
move entry calling to onReady
Sreyas-Sreelal Jun 30, 2024
7d3cc44
change params of create_component
Sreyas-Sreelal Jun 30, 2024
d4622a6
no need of callbacks code gen as we are generating it through python …
Sreyas-Sreelal Jul 5, 2024
4b25c80
change Player::get_id type from usize to i32
Sreyas-Sreelal Aug 18, 2024
a816a0a
fix example code
Sreyas-Sreelal Aug 18, 2024
4e79491
keep the reference of runtime object instead of consuming, facilitati…
Sreyas-Sreelal Aug 21, 2024
432ba8c
use Rc and RefCell instead of Arc and Mutex as we never going to acce…
Sreyas-Sreelal Aug 23, 2024
75848ef
expose PlayerClass struct as well
Sreyas-Sreelal Aug 26, 2024
a7ab30d
use mutex instead of Rc and Cell as callbacks might be called from on…
Sreyas-Sreelal Nov 18, 2024
5f74acf
Revert "use mutex instead of Rc and Cell as callbacks might be called…
Sreyas-Sreelal Feb 23, 2025
21aec42
remove on_console_text from events (this callback can be called from …
Sreyas-Sreelal Feb 23, 2025
ae17a21
Merge branch 'master' of https://github.com/Sreyas-Sreelal/omprs-gdk …
Sreyas-Sreelal Feb 23, 2025
862360c
stupid Rust 2024
Sreyas-Sreelal Feb 23, 2025
8574490
run rustfmt
Sreyas-Sreelal Feb 23, 2025
39fab1d
Fix StringView::get_data crash
0x617374726F May 3, 2025
bbed1ea
Merge pull request #7 from 0xFFFFFFFFFFFFFFFFFF/capi
Sreyas-Sreelal May 4, 2025
3094a31
fix workflow because of stupid rustup updated
Sreyas-Sreelal May 4, 2025
cf185bb
apparantly rustup release log lied..rustup update also need it
Sreyas-Sreelal May 4, 2025
d6c514b
Fix destroying vehicles
0x617374726F May 10, 2025
c36b27f
Don't rely on borrow checker in script events at all
0x617374726F May 13, 2025
34f788d
Merge pull request #8 from 0xFFFFFFFFFFFFFFFFFF/capi
Sreyas-Sreelal May 18, 2025
5feab39
Get rid of undefined behaviour (#9)
0x617374726F Jun 13, 2025
f84d62e
Expose IsPlayerUsingOmp (#10)
0x617374726F Aug 8, 2025
8ac8d80
clippy things
Sreyas-Sreelal Sep 1, 2025
b4cd433
more clipy lints
Sreyas-Sreelal Sep 1, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
sudo apt update
sudo apt install gcc-multilib libssl-dev:i386 zlib1g:i386 -y
if: matrix.os == 'ubuntu-latest'
- run: rustup update ${{ matrix.toolchain }} --no-self-update && rustup default ${{ matrix.toolchain }}
- run: rustup update ${{ matrix.toolchain }} --no-self-update --force-non-host && rustup default ${{ matrix.toolchain }} --force-non-host
- run: cargo build --verbose

rustfmt:
Expand Down
19 changes: 18 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

39 changes: 20 additions & 19 deletions examples/grandlarc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ use std::{
};

use omp::{
classes::CreateClass,
classes,
core::{
DisableInteriorEnterExits, EnableStuntBonusForAll, SetGameModeText, SetNameTagDrawDistance,
SetWeather, SetWorldTime, ShowNameTags, ShowPlayerMarkers,
DisableInteriorEnterExits, EnableStuntBonusForAll, SetGameModeText,
SetNameTagsDrawDistance, SetWeather, SetWorldTime, ShowNameTags, ShowPlayerMarkers,
},
events::Events,
main,
Expand Down Expand Up @@ -43,7 +43,7 @@ struct PlayerData {

struct GrandLarc {
colour_white: Colour,
players_data: HashMap<usize, PlayerData>,
players_data: HashMap<i32, PlayerData>,
class_selection_helper_td: TextDraw,
los_santos_td: TextDraw,
san_fierro_td: TextDraw,
Expand Down Expand Up @@ -239,7 +239,7 @@ impl GrandLarc {

impl Events for GrandLarc {
fn on_player_connect(&mut self, player: Player) {
player.game_text("~w~Grand Larceny", 3000, 4);
player.show_game_text("~w~Grand Larceny", 3000, 4);
player.send_client_message(
self.colour_white,
"Welcome to {88AA88}G{FFFFFF}rand {88AA88}L{FFFFFF}arceny",
Expand Down Expand Up @@ -287,23 +287,23 @@ impl Events for GrandLarc {
player.toggle_clock(false);
}

fn on_player_death(&mut self, player: Player, killer: Option<Player>, _reason: isize) {
fn on_player_death(&mut self, player: Player, killer: Option<Player>, _reason: i32) {
self.players_data
.get_mut(&player.get_id())
.unwrap()
.has_city_selected = false;
if killer.is_none() {
player.reset_money();
} else {
if let Some(killer) = killer {
let playercash = player.get_money();
if playercash > 0 {
killer.unwrap().give_money(playercash);
killer.give_money(playercash);
player.reset_money();
}
} else {
player.reset_money();
}
}

fn on_player_request_class(&mut self, player: Player, _class_id: usize) -> bool {
fn on_player_request_class(&mut self, player: Player, _class_id: i32) -> bool {
if player.is_npc() {
return true;
}
Expand All @@ -321,7 +321,7 @@ impl Events for GrandLarc {
false
}

fn on_player_update(&mut self, player: Player, _now: isize) -> bool {
fn on_player_update(&mut self, player: Player) -> bool {
if player.is_npc() {
return true;
}
Expand Down Expand Up @@ -349,7 +349,7 @@ fn create_all_class() {
82, 83, 84, 85, 87, 88, 89, 91, 92, 93, 95, 96, 97, 98, 99,
];
for x in skins {
CreateClass(
classes::Class::add(
255,
x,
Vector3::new(1759.0189, -1_898.126, 13.5622),
Expand All @@ -365,13 +365,13 @@ fn load_static_vehicles_from_file(path: &str) -> Result<isize, Box<dyn std::erro
let mut count = 0;
for line in lines.map_while(Result::ok) {
let mut seperator = line.split(',');
let modelid: isize = seperator.next().unwrap().parse()?;
let modelid: i32 = seperator.next().unwrap().parse()?;
let x: f32 = seperator.next().unwrap().parse()?;
let y: f32 = seperator.next().unwrap().parse()?;
let z: f32 = seperator.next().unwrap().parse()?;
let rotation: f32 = seperator.next().unwrap().parse()?;
let colour1: isize = seperator.next().unwrap().parse()?;
let colour2: isize = seperator
let colour1: i32 = seperator.next().unwrap().parse()?;
let colour2: i32 = seperator
.next()
.unwrap()
.split(' ')
Expand Down Expand Up @@ -425,7 +425,7 @@ pub fn game_entry() -> Result<(), Box<dyn std::error::Error>> {
SetGameModeText("Grand Larceny");
ShowPlayerMarkers(1);
ShowNameTags(true);
SetNameTagDrawDistance(40.0);
SetNameTagsDrawDistance(40.0);
EnableStuntBonusForAll(false);
DisableInteriorEnterExits();
SetWeather(2);
Expand Down Expand Up @@ -467,10 +467,11 @@ pub fn game_entry() -> Result<(), Box<dyn std::error::Error>> {

let mut total_vehicles = 0;
for file in vehicle_file_list {
total_vehicles += load_static_vehicles_from_file(&format!("vehicles/{file}.txt"))?;
total_vehicles +=
load_static_vehicles_from_file(&format!("scriptfiles/vehicles/{file}.txt"))?;
}

omp::core::Print(&format!("Total vehicles from files: {total_vehicles}"));
omp::core::Log(&format!("Total vehicles from files: {total_vehicles}"));

Ok(())
}
19 changes: 19 additions & 0 deletions examples/grandlarc/src/minigun.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
use omp::{
events::Events,
players::{Player, PlayerBulletData, PlayerWeapon},
terminate_event,
};

pub struct MiniGunDetector {
pub on_player_shot_minigun: fn(player: Player),
}

impl Events for MiniGunDetector {
fn on_player_shot_missed(&mut self, player: Player, bullet_data: PlayerBulletData) -> bool {
if bullet_data.weapon == PlayerWeapon::Minigun {
(self.on_player_shot_minigun)(player);
terminate_event!(true);
}
true
}
}
136 changes: 0 additions & 136 deletions omp-codegen/src/callbacks.rs

This file was deleted.

Loading
Loading