omp_gdk/scripting/core/
events.rs1#![allow(clippy::all)]
2
3use crate::{events::EventArgs, runtime::each_module, types::stringview::StringView};
4
5#[repr(C)]
6pub struct OnTickArgs {
7 elapsed: *const i32,
8}
9
10#[no_mangle]
11pub unsafe extern "C" fn OMPRS_OnTick(args: *const EventArgs<OnTickArgs>) {
12 let api_calls: Vec<_> =
13 crate::runtime::API_QUEUE.with_borrow_mut(|queue| std::mem::take(queue));
14 for callback in api_calls {
16 callback();
17 }
18
19 each_module(move |mut script| {
20 script.on_tick(*(*(*args).list).elapsed);
21 None
22 });
23}
24
25#[repr(C)]
26pub struct OnConsoleTextArgs {
27 command: *const StringView,
28 parameters: *const StringView,
29}
30
31#[repr(C)]
43pub struct OnRconLoginAttemptArgs {
44 address: *const StringView,
45 password: *const StringView,
46 success: *const bool,
47}
48
49#[no_mangle]
50pub unsafe extern "C" fn OMPRS_OnRconLoginAttempt(
51 args: *const EventArgs<OnRconLoginAttemptArgs>,
52) -> bool {
53 each_module(move |mut script| {
54 Some(script.on_rcon_login_attempt(
55 (*(*(*args).list).address).get_data(),
56 (*(*(*args).list).password).get_data(),
57 *(*(*args).list).success,
58 ))
59 })
60 .unwrap()
61}