pub fn set_timeout<V: IntoVoidResult>(
callback: impl FnMut() -> V + 'static,
millis: u64,
) -> TimerExpand description
ยงExamples
altv::set_timeout(
move || {
altv::log!("this message will be printed once, after 1.5s");
},
1500,
);With error handling
fn something_that_can_fail() -> altv::VoidResult {
Ok(())
}
altv::set_timeout(
move || {
altv::log!("this message will be printed once, after 1.5s");
something_that_can_fail()?;
Ok(())
},
1500,
);Destroying (clearing) timer
let mut timer = altv::set_timeout(
move || {
altv::log!("this message will never be printed");
},
1500,
);
// Returns error if timer was already destroyed
timer.destroy()?;