-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathasync_engine.rs
46 lines (38 loc) · 1.13 KB
/
async_engine.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
use rrplug::{bindings::cvar::convar::FCVAR_GAMEDLL, prelude::*};
pub struct ExamplePlugin;
impl Plugin for ExamplePlugin {
const PLUGIN_INFO: PluginInfo =
PluginInfo::new(c"example", c"EXAMPLLEE", c"EXAMPLE", PluginContext::all());
fn new(_reloaded: bool) -> Self {
Self {}
}
fn on_dll_load(
&self,
engine_data: Option<&EngineData>,
_dll_ptr: &DLLPointer,
engine_token: EngineToken,
) {
let Some(engine_data) = engine_data else {
return;
};
engine_data
.register_concommand(
"set_max_score",
set_max_score,
"this will set the game's max score",
FCVAR_GAMEDLL as i32,
engine_token,
)
.expect("could not create set_max_score concommand");
}
}
entry!(ExamplePlugin);
#[rrplug::concommand]
fn set_max_score(command: CCommandResult) -> Option<()> {
_ = async_execute(AsyncEngineMessage::run_squirrel_func(
"SetScoreLimit",
ScriptContext::SERVER,
command.get_arg(0)?.parse::<i32>().ok()?,
));
None
}